Skip to content

Commit

Permalink
fix: Unified plugin style. #25
Browse files Browse the repository at this point in the history
  • Loading branch information
huihuimoe committed Mar 28, 2019
1 parent 8e024d6 commit ae7456c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion config-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ const hdh = new HDH({
// save to path
await this.download(s).to(qBittorrentWatchPath)
// using qBittorrent API
await qBittorrent(s, { category: 'Movies' })
const result = await this.download(s).to(savePath)
await qBittorrent(result, {
category: 'Movies',
savepath: '/opt/Movies',
})
},
})

Expand Down
8 changes: 4 additions & 4 deletions plugins/qBittorrent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addOptions as IaddOptions, connect } from 'qbittorrent-api'
import { IRequireStatus } from '../typings/application'
import { IDownloadToRetn } from '../bootstrap'

export interface IqBittorrentConnectOptions {
host: string
Expand All @@ -13,7 +13,7 @@ export default (connectOptions: IqBittorrentConnectOptions, globalAddOptions: Ia
connectOptions.username,
connectOptions.password,
)
return async (status: IRequireStatus, addOptions: IaddOptions = {}) => {
return async (file: IDownloadToRetn, addOptions: IaddOptions = {}) => {
// test is login
await new Promise((resolve, rejects) => {
instance.transferInfo((e, data) => {
Expand All @@ -23,10 +23,10 @@ export default (connectOptions: IqBittorrentConnectOptions, globalAddOptions: Ia
})
})

console.log(`Pushing ${status.id} to qBittorrent using qBittorrent API...`)
console.log(`Pushing ${file.filename} to qBittorrent using qBittorrent API...`)
await new Promise((resolve, rejects) => {
instance.add2(
status.downLink,
file.path,
{
...globalAddOptions,
...addOptions,
Expand Down

0 comments on commit ae7456c

Please sign in to comment.