This commit is contained in:
EstrellaXD
2022-05-17 00:17:09 +08:00
parent 6344ad22c6
commit a01807af11
8 changed files with 134 additions and 58 deletions

View File

@@ -1 +1,41 @@
import qbittorrentapi
import qbittorrentapi
import json
import os
with open("config.json") as f:
info = json.load(f)
with open("bangumi.json") as f:
bangumi_info = json.load(f)
rss_link = info["rss_link"]
host_ip = "192.168.31.10:8181"
user_name = "admin"
password = "adminadmin"
def set_rule(bangumi_name, season):
qb = qbittorrentapi.Client(host=host_ip, username=user_name, password=password)
try:
qb.auth_log_in()
except qbittorrentapi.LoginFailed as e:
print(e)
rule = {
'enable': False,
'mustContain': bangumi_name,
'mustNotContain': '720',
'useRegx': True,
'episodeFilter': '',
'smartFilter': False,
'previouslyMatchedEpisodes': [],
'affectedFeeds': [rss_link],
'ignoreDays': 0,
'lastMatch': '',
'addPaused': False,
'assignedCategory': 'Bangumi',
'savePath': os.path.join('/downloads', bangumi_name, season)
}
qb.rss_set_rule(rule_name=bangumi_name, rule_def=rule)
if __name__ == "__main__":
for info in bangumi_info:
set_rule(info["title"], info["season"])

View File

@@ -1,41 +1,58 @@
[
{
"title": "Kawaii dake ja Nai Shikimori-san "
"title": "simple",
"season": ""
},
{
"title": "Kakkou no Iinazuke "
"title": "Kawaii dake ja Nai Shikimori-san",
"season": ""
},
{
"title": "SPYxFAMILY "
"title": "Kakkou no Iinazuke",
"season": ""
},
{
"title": "Love Live虹咲学园 学园偶像同好会 S02 "
"title": "SPYxFAMILY",
"season": ""
},
{
"title": "CUE!"
"title": "Love Live虹咲学园 学园偶像同好会",
"season": "S02"
},
{
"title": "Kaguya-sama wa Kokurasetai S03 "
"title": "CUE!",
"season": ""
},
{
"title": "Shokei Shoujo no Virgin Road "
"title": "Kaguya-sama wa Kokurasetai",
"season": "S03"
},
{
"title": "Kakkou no Iikagen "
"title": "Shokei Shoujo no Virgin Road",
"season": ""
},
{
"title": "Summer Time Rendering"
"title": "Kakkou no Iikagen",
"season": ""
},
{
"title": "Paripi Koumei "
"title": "Summer Time Rendering",
"season": ""
},
{
"title": "Tate no Yuusha no Nariagari S02 "
"title": "Paripi Koumei",
"season": ""
},
{
"title": "Shijou Saikyou no Daimaou "
"title": "Tate no Yuusha no Nariagari",
"season": "S02"
},
{
"title": "Yuusha, Yamemasu "
"title": "Shijou Saikyou no Daimaou",
"season": ""
},
{
"title": "Yuusha, Yamemasu",
"season": ""
}
]

View File

@@ -33,7 +33,7 @@ for a in item:
matchObj = re.match(rule, name, re.I)
if matchObj is not None:
new_name = re.sub(r'\[|\]', '', f'{matchObj.group(1)}')
new_name = re.split(r'/', new_name)[-1].lstrip()
new_name = re.split(r'/', new_name)[-1].strip()
if new_name not in bangumi_title:
bangumi_title.append(new_name)
@@ -44,13 +44,20 @@ had_data = []
for data in bangumi_info:
had_data.append(data["title"])
season_rules = r'S\d'
season_rules = r'(.*)(S.\d)'
for title in bangumi_title:
a = re.match(season_rules, title, re.I)
if a is not None:
title = a.group(1).strip()
season = a.group(2).strip()
else:
season = ''
if title not in had_data:
bangumi_info.append({
"title": title
"title": title,
"season": season
})
print(f"add {title}")
print(f"add {title} {season}")
with open("bangumi.json", 'w', encoding='utf8') as f:

View File

@@ -1,6 +1,10 @@
import re
name = "Tate no Yuusha no Nariagari S02 "
name = "Tate no Yuusha no Nariagari S02"
season_rules = r'S(\d{0,3}|\d{1,3}\.\d{1,2})'
a = re.match(season_rules, name)
print(a)
season_rules = r'(.*)(S.\d)'
a = re.match(season_rules, name, re.I)
if a is not None:
print(a.group(1))
print(a.group(2))
else:
print(name)