Пример #1
0
def update_trakt(release_key):
    """

    :param release_key:
    :type release_key: BaseReleaseKey|TVReleaseKey|TVDailyReleaseKey|MovieReleaseKey
    """
    session = Session()
    media_info = None

    try:
        if release_key.media_type == constants.MEDIA_TV:
            if release_key.daily:
                info = trakt.show_episode_summary_daily(
                    release_key.name, release_key.day, release_key.month, release_key.year
                )
            else:
                info = trakt.show_episode_summary(release_key.name, release_key.season, release_key.episode)
            raise_unless(info, exceptions.ApiError, "Failed to fetch metadata for: {}".format(release_key))
            media_info = _update_trakt_tv(session, info)
        elif release_key.media_type == constants.MEDIA_MOVIE:
            info = trakt.movie_summary(release_key.name)
            raise_unless(info, exceptions.ApiError, "Failed to fetch metadata for: {}".format(release_key))
            media_info = _update_trakt_movie(session, info)
        else:
            return None
        session.commit()
    except DBAPIError as e:
        log.exception("Error querying media info")
        session.rollback()
    except exceptions.ApiError as e:
        log.warn(e.message)
    except Exception as e:
        log.exception("Could not update trakt info")
    return media_info
Пример #2
0
def update_trakt(release_key):
    """

    :param release_key:
    :type release_key: BaseReleaseKey|TVReleaseKey|TVDailyReleaseKey|MovieReleaseKey
    """
    session = Session()
    media_info = None

    try:
        if release_key.media_type == constants.MEDIA_TV:
            if release_key.daily:
                info = trakt.show_episode_summary_daily(
                    release_key.name, release_key.day, release_key.month, release_key.year
                )
            else:
                info = trakt.show_episode_summary(release_key.name, release_key.season, release_key.episode)
            raise_unless(info, exceptions.ApiError, "Failed to fetch metadata for: {}".format(release_key))
            media_info = _update_trakt_tv(session, info)
        elif release_key.media_type == constants.MEDIA_MOVIE:
            info = trakt.movie_summary(release_key.name)
            raise_unless(info, exceptions.ApiError, "Failed to fetch metadata for: {}".format(release_key))
            media_info = _update_trakt_movie(session, info)
        else:
            return None
        session.commit()
    except DBAPIError as e:
        log.exception("Error querying media info")
        session.rollback()
    except exceptions.ApiError as e:
        log.warn(e.message)
    except Exception as e:
        log.exception("Could not update trakt info")
    return media_info
Пример #3
0
 def test_show_episode_summary(self):
     with tapedeck.use_cassette(self.track("test_show_episode_summary_a"), before_record=strip_key):
         daily_summary = trakt.show_episode_summary_daily("The Daily Show", 9, 9, 2014)
     self.assertEqual(daily_summary['episode']['number'], 149)
     self.assertEqual(daily_summary['episode']['season'], 19)
     with tapedeck.use_cassette(self.track("test_show_episode_summary_b"), before_record=strip_key):
         summary = trakt.show_episode_summary(self.show, self.season, self.episode)
     self.assertEqual(summary.get('episode', {}).get('season', 0), self.season)
     self.assertEqual(summary.get('episode', {}).get('number', 0), self.episode)
Пример #4
0
 def test_show_episode_summary(self):
     with tapedeck.use_cassette(self.track("test_show_episode_summary_a"),
                                before_record=strip_key):
         daily_summary = trakt.show_episode_summary_daily(
             "The Daily Show", 9, 9, 2014)
     self.assertEqual(daily_summary['episode']['number'], 149)
     self.assertEqual(daily_summary['episode']['season'], 19)
     with tapedeck.use_cassette(self.track("test_show_episode_summary_b"),
                                before_record=strip_key):
         summary = trakt.show_episode_summary(self.show, self.season,
                                              self.episode)
     self.assertEqual(
         summary.get('episode', {}).get('season', 0), self.season)
     self.assertEqual(
         summary.get('episode', {}).get('number', 0), self.episode)