mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-05-04 21:03:31 +08:00
- 区分 Consts 和 Settings,取代 Env - 独立 downloader module,为便于后续提供多下载器支持 - 加入命令行选项,提供 debug 模式 - 其他细节
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
import os.path
|
|
import requests
|
|
from qbittorrentapi import Client
|
|
from bs4 import BeautifulSoup
|
|
import logging
|
|
|
|
from conf import settings
|
|
from const import FULL_SEASON_SUPPORT_GROUP
|
|
from downloader import getClient
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class FullSeasonGet:
|
|
def __init__(self, group, bangumi_name, season):
|
|
self.torrents = None
|
|
self.bangumi_name = bangumi_name
|
|
self.group = group
|
|
self.season = season
|
|
self.client = getClient()
|
|
|
|
def get_season_rss(self):
|
|
if self.season == "S01":
|
|
season = ""
|
|
else:
|
|
season = self.season
|
|
season = requests.get(
|
|
f"https://mikanani.me/RSS/Search?searchstr={self.group}+{self.bangumi_name}+{season}"
|
|
)
|
|
soup = BeautifulSoup(season.content, "xml")
|
|
self.torrents = soup.find_all("enclosure")
|
|
|
|
def add_torrents(self):
|
|
for torrent in self.torrents:
|
|
self.client.torrents_add(
|
|
urls=torrent["url"],
|
|
save_path=str(
|
|
os.path.join(settings.download_path, self.bangumi_name, self.season)
|
|
),
|
|
category="Bangumi",
|
|
)
|
|
|
|
def run(self):
|
|
if self.group in FULL_SEASON_SUPPORT_GROUP:
|
|
self.get_season_rss()
|
|
self.add_torrents()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
a = FullSeasonGet("Lilith-Raws", "Shijou Saikyou no Daimaou", "S01")
|
|
a.run()
|
|
for torrent in a.torrents:
|
|
logger.debug(torrent["url"])
|