Skip to content

Commit

Permalink
Merge pull request #360 from miRemid/main
Browse files Browse the repository at this point in the history
feat: Support qbittorrent to use category as download path
  • Loading branch information
qingchoulove authored Nov 13, 2023
2 parents 5784350 + 2385641 commit 149b2d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions .config/download_provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ qbittorrent:
username: admin
password: adminadmin
verify_webui_certificate: false
use_auto_torrent_management: false
priority: 3
tags:
- kubespider
Expand Down
2 changes: 2 additions & 0 deletions docs/zh/user_guide/qbittorrent_download_provider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ qbittorrent:
tags:
- kubespider
category: kubespider
use_auto_torrent_management: false
```
其中:
Expand All @@ -95,6 +96,7 @@ qbittorrent:
* `priority`: 下载提供器优先级,数字越小,优先级越高,下载资源时按优先级尝试,无法下载或下载失败时切换下载器。
* `tags`: 触发下载时使用的tag,可用于资源分类,不需要时可留空或不设置。
* `category`: 触发下载时使用的category,可用于资源分类,不需要时可留空或不设置。
* `use_auto_torrent_management`: 必须配置category选项,触发下载时,使用category作为保存目录

#### 3.1 来自订阅源的配置

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, name: str, config_reader: AbsConfigReader) -> None:
self.verify_webui_certificate = False
self.download_tags = ['']
self.download_category = ''
self.use_auto_torrent_management = False

def get_provider_type(self) -> str:
return self.provider_type
Expand Down Expand Up @@ -65,10 +66,13 @@ def send_torrent_task(self, task: Task) -> TypeError:
logging.info('Start torrent download:%s, path:%s', task.url, download_path)
tags = task.extra_param('tags', self.download_tags)
category = task.extra_param('category', self.download_category)
use_auto_torrent_management = task.extra_param('use_auto_torrent_management', self.use_auto_torrent_management)
if not category:
use_auto_torrent_management = False
try:
logging.info('Create download task category:%s, tags:%s', category, tags)
ret = self.client.torrents_add(torrent_files=task.url, save_path=download_path, category=category,
tags=tags)
tags=tags, use_auto_torrent_management=use_auto_torrent_management)
logging.info('Create download task results:%s', ret)
return None
except Exception as err:
Expand All @@ -81,9 +85,12 @@ def send_magnet_task(self, task: Task) -> TypeError:
download_path = os.path.join(self.download_base_path, task.path)
tags = task.extra_param('tags', self.download_tags)
category = task.extra_param('category', self.download_category)
use_auto_torrent_management = task.extra_param('use_auto_torrent_management', self.use_auto_torrent_management)
if not category:
use_auto_torrent_management = False
try:
logging.info('Create download task category:%s, tags:%s', category, tags)
ret = self.client.torrents_add(urls=task.url, save_path=download_path, category=category, tags=tags)
ret = self.client.torrents_add(urls=task.url, save_path=download_path, category=category, tags=tags, use_auto_torrent_management=use_auto_torrent_management)
logging.info('Create download task results:%s', ret)
return None
except Exception as err:
Expand Down Expand Up @@ -111,6 +118,7 @@ def load_config(self) -> TypeError:
self.verify_webui_certificate = cfg['verify_webui_certificate']
self.download_tags = cfg.get('tags', [])
self.download_category = cfg.get('category')
self.use_auto_torrent_management = cfg['use_auto_torrent_management']
self.client = qbittorrentapi.Client(
self.http_endpoint_host,
self.http_endpoint_port,
Expand Down

0 comments on commit 149b2d5

Please sign in to comment.