Exemple #1
0
 def __post_init__(self):
     if isinstance(self.season, str):
         self.season = int(self.season)
     if isinstance(self.episode, str):
         self.episode = int(self.episode)
     if isinstance(self.date, str):
         self.date = parse_date(self.date)
Exemple #2
0
 def _search_tvdb_date(self, id_tvdb: int, release_date: date):
     release_date = parse_date(release_date)
     found = False
     for meta in self._search_id(id_tvdb):
         if meta.date and meta.date == release_date:
             found = True
             yield meta
     if not found:
         raise MnamerNotFoundException
Exemple #3
0
 def _search_tvdb_date(self, id_tvdb: str, release_date: date,
                       language: Optional[Language]):
     release_date = parse_date(release_date)
     found = False
     for meta in self._search_id(id_tvdb, language=language):
         if meta.date and meta.date == release_date:
             found = True
             yield meta
     if not found:
         raise MnamerNotFoundException
Exemple #4
0
 def _search_series_date(self, series: str, release_date: date):
     release_date = parse_date(release_date)
     series_data = tvdb_search_series(self.token, series, cache=self.cache)
     tvdb_ids = [entry["id"] for entry in series_data["data"]][:5]
     found = False
     for tvdb_id in tvdb_ids:
         try:
             yield from self._search_tvdb_date(tvdb_id, release_date)
             found = True
         except MnamerNotFoundException:
             continue
     if not found:
         raise MnamerNotFoundException
Exemple #5
0
def tvmaze_episodes_by_date(
    id_tvmaze: Union[str, int],
    air_date: Union[datetime.date, str],
    cache: bool = True,
    attempt: int = 1,
) -> dict:
    """
    Retrieves all episodes from this show that have aired on a specific date.
    Useful for daily shows that don't adhere to a common season numbering.

    Online docs: https://www.tvmaze.com/api#episodes-by-date
    """
    url = f"http://api.tvmaze.com/shows/{id_tvmaze}/episodesbydate"
    parameters = {"date": parse_date(air_date)}
    status, content = request_json(url, parameters, cache=cache)
    if status == 443 and attempt <= MAX_RETRIES:  # pragma: no cover
        sleep(attempt * 2)
        return tvmaze_episodes_by_date(id_tvmaze, air_date, cache, attempt + 1)
    elif status == 404:
        raise MnamerNotFoundException
    elif status != 200 or not content:  # pragma: no cover
        raise MnamerNetworkException
    return content