mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-11-28 23:25:01 +08:00
ci(lint): fix lambda assignment error
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from module.network import RequestContent
|
||||
|
||||
|
||||
search_url = lambda e: f"https://api.bgm.tv/search/subject/{e}?responseGroup=large"
|
||||
def search_url(e):
|
||||
return f"https://api.bgm.tv/search/subject/{e}?responseGroup=large"
|
||||
|
||||
|
||||
def bgm_parser(title):
|
||||
|
||||
@@ -2,8 +2,8 @@ import re
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
|
||||
from module.network import RequestContent
|
||||
from module.conf import TMDB_API
|
||||
from module.network import RequestContent
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -16,16 +16,15 @@ class TMDBInfo:
|
||||
year: str
|
||||
|
||||
|
||||
LANGUAGE = {
|
||||
"zh": "zh-CN",
|
||||
"jp": "ja-JP",
|
||||
"en": "en-US"
|
||||
}
|
||||
LANGUAGE = {"zh": "zh-CN", "jp": "ja-JP", "en": "en-US"}
|
||||
|
||||
search_url = lambda e: \
|
||||
f"https://api.themoviedb.org/3/search/tv?api_key={TMDB_API}&page=1&query={e}&include_adult=false"
|
||||
info_url = lambda e, key: \
|
||||
f"https://api.themoviedb.org/3/tv/{e}?api_key={TMDB_API}&language={LANGUAGE[key]}"
|
||||
|
||||
def search_url(e):
|
||||
return f"https://api.themoviedb.org/3/search/tv?api_key={TMDB_API}&page=1&query={e}&include_adult=false"
|
||||
|
||||
|
||||
def info_url(e, key):
|
||||
return f"https://api.themoviedb.org/3/tv/{e}?api_key={TMDB_API}&language={LANGUAGE[key]}"
|
||||
|
||||
|
||||
def is_animation(tv_id, language) -> bool:
|
||||
@@ -42,7 +41,7 @@ def get_season(seasons: list) -> int:
|
||||
for season in seasons:
|
||||
if re.search(r"第 \d 季", season.get("season")) is not None:
|
||||
date = season.get("air_date").split("-")
|
||||
[year, _ , _] = date
|
||||
[year, _, _] = date
|
||||
now_year = time.localtime().tm_year
|
||||
if int(year) <= now_year:
|
||||
return int(re.findall(r"\d", season.get("season"))[0])
|
||||
@@ -63,16 +62,30 @@ def tmdb_parser(title, language) -> TMDBInfo | None:
|
||||
break
|
||||
url_info = info_url(id, language)
|
||||
info_content = req.get_json(url_info)
|
||||
season = [{"season": s.get("name"), "air_date": s.get("air_date"), "poster_path": s.get("poster_path")} for s in info_content.get("seasons")]
|
||||
season = [
|
||||
{
|
||||
"season": s.get("name"),
|
||||
"air_date": s.get("air_date"),
|
||||
"poster_path": s.get("poster_path"),
|
||||
}
|
||||
for s in info_content.get("seasons")
|
||||
]
|
||||
last_season = get_season(season)
|
||||
original_title = info_content.get("original_name")
|
||||
official_title = info_content.get("name")
|
||||
year_number = info_content.get("first_air_date").split("-")[0]
|
||||
return TMDBInfo(id, official_title, original_title, season, last_season, str(year_number))
|
||||
return TMDBInfo(
|
||||
id,
|
||||
official_title,
|
||||
original_title,
|
||||
season,
|
||||
last_season,
|
||||
str(year_number),
|
||||
)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
title = "鬼灭之刃"
|
||||
print(tmdb_parser(title, "zh"))
|
||||
print(tmdb_parser(title, "zh"))
|
||||
|
||||
Reference in New Issue
Block a user