Skip to content

Commit

Permalink
2.3.0 Version Update
Browse files Browse the repository at this point in the history
  • Loading branch information
EstrellaXD committed May 23, 2022
1 parent 19bc49a commit 9cbb817
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 15 deletions.
3 changes: 2 additions & 1 deletion AutoBangumi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ RUN pip install -r requirements.txt

ENV TZ=Asia/Shanghai
ENV TIME=1800
ENV HOST=127.0.0.1:8080
ENV HOST=localhost:8080
ENV USER=admin
ENV PASSWORD=adminadmin
ENV METHOD=pn
ENV GROUP_TAG=False

COPY ./app /app
COPY ./config /config
Expand Down
15 changes: 12 additions & 3 deletions AutoBangumi/app/auto_set_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self):
except qbittorrentapi.LoginFailed as e:
print(e)

def set_rule(self, bangumi_name, season):
def set_rule(self, bangumi_name, group, season):
rule = {
'enable': True,
'mustContain': bangumi_name,
Expand All @@ -38,7 +38,11 @@ def set_rule(self, bangumi_name, season):
'assignedCategory': 'Bangumi',
'savePath': str(os.path.join(self.download_path, re.sub(EnvInfo.rule_name_re," ", bangumi_name), season))
}
self.qb.rss_set_rule(rule_name=bangumi_name, rule_def=rule)
if EnvInfo.enable_group_tag:
rule_name = f"[{group}] {bangumi_name}"
else:
rule_name = bangumi_name
self.qb.rss_set_rule(rule_name=rule_name, rule_def=rule)

def rss_feed(self):
try:
Expand All @@ -58,10 +62,15 @@ def run(self):
sys.stdout.flush()
for info in self.bangumi_info:
if not info["added"]:
self.set_rule(info["title"], info["season"])
self.set_rule(info["title"], info["group"], info["season"])
info["added"] = True
with open(EnvInfo.info_path, 'w', encoding='utf8') as f:
json.dump(self.info, f, indent=4, separators=(',', ': '), ensure_ascii=False)
sys.stdout.write(f"[{EnvInfo.time_show_obj}] Finished." + "\n")
sys.stdout.flush()


if __name__ == "__main__":
put = SetRule()
put.run()

17 changes: 11 additions & 6 deletions AutoBangumi/app/collect_bangumi_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ def get_info_list(self):
if match_obj is not None:
bangumi_title = match_obj.group(2).strip()
if bangumi_title not in self.bangumi_list:
self.bangumi_list.append(bangumi_title)
self.bangumi_list.append({
"title": bangumi_title,
"group": group
})
# debug
# print(bangumi_title)
# print(group)
break
if exit_flag:
break
Expand All @@ -84,19 +88,19 @@ def put_info_json(self):
"rss_link": EnvInfo.rss_link,
"bangumi_info": []
}
for title in self.bangumi_list:
match_title_season = re.match(MatchRule.season_match, title, re.I)
for item in self.bangumi_list:
match_title_season = re.match(MatchRule.season_match, item["title"], re.I)
if match_title_season is not None:
json_title = match_title_season.group(1).strip()
json_season = match_title_season.group(2)
else:
json_season = 'S01'
json_title = title
json_title = item["title"]
if json_title not in had_data:
self.info["bangumi_info"].append({
"title": json_title,
"season": json_season,
"group": '',
"group": item["group"],
"added": False
})
sys.stdout.write(f"[{EnvInfo.time_show_obj}] add {json_title} {json_season}" + "\n")
Expand All @@ -111,4 +115,5 @@ def run(self):

if __name__ == "__main__":
cr = CollectRSS()
cr.get_info_list()
cr.get_info_list()
cr.put_info_json()
4 changes: 3 additions & 1 deletion AutoBangumi/app/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class EnvInfo:
rss_link = os.environ["RSS"]
download_path = os.environ["DOWNLOAD_PATH"]
method = os.environ["METHOD"]
enable_group_tag = os.getenv("GROUP_TAG", 'False').lower() in ('true', '1', 't')
info_path = "/config/bangumi.json"
rule_path = "/config/rule.json"
else:
Expand All @@ -21,9 +22,10 @@ class EnvInfo:
sleep_time = 10
user_name = "admin"
password = "adminadmin"
rss_link = ""
rss_link = "https://mikanani.me/RSS/MyBangumi?token=Td8ceWZZv3s2OZm5ji9RoMer8vk5VS3xzC1Hmg8A26E%3d"
download_path = "/downloads/Bangumi"
method = "pn"
enable_group_tag = True
info_path = "../config/bangumi.json"
rule_path = "../config/rule.json"
# Static ENV
Expand Down
113 changes: 113 additions & 0 deletions AutoBangumi/config/bangumi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"rss_link": "https://mikanani.me/RSS/MyBangumi?token=Td8ceWZZv3s2OZm5ji9RoMer8vk5VS3xzC1Hmg8A26E%3d",
"bangumi_info": [
{
"title": "Kakkou no Iinazuke",
"season": "S01",
"group": "Lilith-Raws",
"added": true
},
{
"title": "SPYxFAMILY",
"season": "S01",
"group": "Lilith-Raws",
"added": true
},
{
"title": "Love Live",
"season": "S02",
"group": "Lilith-Raws",
"added": true
},
{
"title": "CUE!",
"season": "S01",
"group": "喵萌Production",
"added": true
},
{
"title": "CUE!",
"season": "S01",
"group": "喵萌Production",
"added": true
},
{
"title": "Kaguya-sama wa Kokurasetai",
"season": "S03",
"group": "Lilith-Raws",
"added": true
},
{
"title": "Shokei Shoujo no Virgin Road",
"season": "S01",
"group": "Lilith-Raws",
"added": true
},
{
"title": "Kakkou no Iikagen",
"season": "S01",
"group": "Lilith-Raws",
"added": true
},
{
"title": "Tomodachi Game",
"season": "S01",
"group": "离谱Sub",
"added": true
},
{
"title": "Summer Time Rendering",
"season": "S01",
"group": "喵萌奶茶屋",
"added": true
},
{
"title": "Summer Time Rendering",
"season": "S01",
"group": "喵萌奶茶屋",
"added": true
},
{
"title": "Paripi Koumei",
"season": "S01",
"group": "Lilith-Raws",
"added": true
},
{
"title": "Tomodachi Game",
"season": "S01",
"group": "离谱Sub",
"added": true
},
{
"title": "Tate no Yuusha no Nariagari",
"season": "S02",
"group": "Lilith-Raws",
"added": true
},
{
"title": "Shijou Saikyou no Daimaou",
"season": "S01",
"group": "Lilith-Raws",
"added": true
},
{
"title": "Yuusha, Yamemasu",
"season": "S01",
"group": "Lilith-Raws",
"added": true
},
{
"title": "Aharen-san wa Hakarenai",
"season": "S01",
"group": "LoliHouse",
"added": true
},
{
"title": "Aharen-san wa Hakarenai",
"season": "S01",
"group": "LoliHouse",
"added": true
}
]
}
6 changes: 2 additions & 4 deletions test/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os

import qbittorrentapi

abs_path = os.path.dirname(os.path.abspath(__file__))
print(abs_path)
a = "false"
print(bool(a))

0 comments on commit 9cbb817

Please sign in to comment.