mirror of
https://github.com/g0ldyy/comet.git
synced 2026-01-12 01:16:12 +01:00
feat: fix a few useless things
This commit is contained in:
@@ -27,15 +27,15 @@ async def get_kitsu_metadata(session: aiohttp.ClientSession, id: str):
|
|||||||
if end_date and len(end_date) >= 4:
|
if end_date and len(end_date) >= 4:
|
||||||
year_end = int(end_date[:4])
|
year_end = int(end_date[:4])
|
||||||
|
|
||||||
if year is None:
|
# if year is None:
|
||||||
created_at = attributes.get("createdAt")
|
# created_at = attributes.get("createdAt")
|
||||||
if created_at and len(created_at) >= 4:
|
# if created_at and len(created_at) >= 4:
|
||||||
year = int(created_at[:4])
|
# year = int(created_at[:4])
|
||||||
|
|
||||||
if year_end is None:
|
# if year_end is None:
|
||||||
updated_at = attributes.get("updatedAt")
|
# updated_at = attributes.get("updatedAt")
|
||||||
if updated_at and len(updated_at) >= 4:
|
# if updated_at and len(updated_at) >= 4:
|
||||||
year_end = int(updated_at[:4])
|
# year_end = int(updated_at[:4])
|
||||||
|
|
||||||
return title, year, year_end
|
return title, year, year_end
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ class MetadataScraper:
|
|||||||
aliases = await anime_mapper.get_aliases(full_media_id)
|
aliases = await anime_mapper.get_aliases(full_media_id)
|
||||||
logger.log(
|
logger.log(
|
||||||
"SCRAPER",
|
"SCRAPER",
|
||||||
f"📜 Found {len(aliases['ez'])} Anime title aliases for {media_id}",
|
f"📜 Found {len(aliases.get('ez', []))} Anime title aliases for {media_id}",
|
||||||
)
|
)
|
||||||
if aliases:
|
if aliases:
|
||||||
return aliases
|
return aliases
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class AnimeMapper:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.loaded = False
|
self.loaded = False
|
||||||
self._refresh_lock = asyncio.Lock()
|
self._refresh_lock = asyncio.Lock()
|
||||||
|
self._refresh_task = None
|
||||||
|
|
||||||
self.anime_imdb_ids = set()
|
self.anime_imdb_ids = set()
|
||||||
self._aod_url = "https://github.com/manami-project/anime-offline-database/releases/latest/download/anime-offline-database-minified.json"
|
self._aod_url = "https://github.com/manami-project/anime-offline-database/releases/latest/download/anime-offline-database-minified.json"
|
||||||
@@ -56,7 +57,9 @@ class AnimeMapper:
|
|||||||
await self._load_provider_ids()
|
await self._load_provider_ids()
|
||||||
|
|
||||||
if await self._is_cache_stale():
|
if await self._is_cache_stale():
|
||||||
asyncio.create_task(self._refresh_from_remote(background=True))
|
self._refresh_task = asyncio.create_task(
|
||||||
|
self._refresh_from_remote(background=True)
|
||||||
|
)
|
||||||
|
|
||||||
self.loaded = True
|
self.loaded = True
|
||||||
logger.log(
|
logger.log(
|
||||||
@@ -371,7 +374,7 @@ class AnimeMapper:
|
|||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.error(f"Failed to persist anime mapping cache: {exc}")
|
logger.error(f"Failed to persist anime mapping cache: {exc}")
|
||||||
|
return 0, 0
|
||||||
|
|
||||||
|
|
||||||
anime_mapper = AnimeMapper()
|
anime_mapper = AnimeMapper()
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ class AsyncClientWrapper:
|
|||||||
if not self._curl_session:
|
if not self._curl_session:
|
||||||
self._curl_session = CurlSession(
|
self._curl_session = CurlSession(
|
||||||
headers=self.headers,
|
headers=self.headers,
|
||||||
impersonate=self.impersonate or "chrome",
|
impersonate=self.impersonate,
|
||||||
timeout=self.timeout,
|
timeout=self.timeout,
|
||||||
)
|
)
|
||||||
return self._curl_session
|
return self._curl_session
|
||||||
|
|||||||
Reference in New Issue
Block a user