コード例 #1
0
 def lazy_user_ratings_lookup(self, config, style, entry):
     """Does the ratings lookup for this entry and populates the entry fields."""
     if style in ['show', 'episode', 'season']:
         lookup = lookup_series
         trakt_id = entry.get('trakt_show_id', eval_lazy=True)
     else:
         lookup = lookup_movie
         trakt_id = entry.get('trakt_movie_id', eval_lazy=True)
     with Session() as session:
         lookupargs = {'trakt_id': trakt_id,
                       'session': session}
         try:
             item = lookup(**lookupargs)
             if style in ['show', 'episode', 'season']:
                 rating_style = style
                 if style == 'show':
                     rating_style = 'series'
                 elif style == 'episode':
                     rating_style = 'ep'
                 # fetch episode data if style is not series
                 if style in ['episode', 'season']:
                     item = item.get_episode(entry['series_season'], entry['series_episode'], session)
                 rating = ApiTrakt.user_ratings(style, item, entry.get('title'),
                                                username=config.get('username'),
                                                account=config.get('account'))
                 entry['trakt_{}_user_rating'.format(rating_style)] = rating
             else:
                 movie_rating = ApiTrakt.user_ratings(style, item, entry.get('title'),
                                                      username=config.get('username'),
                                                      account=config.get('account'))
                 entry['trakt_movie_user_rating'] = movie_rating
         except LookupError as e:
             log.debug(e.args[0])
     return entry
コード例 #2
0
ファイル: test_trakt.py プロジェクト: Ken4scholars/Flexget
    def test_search_results(self, execute_task):
        task = execute_task('test_search_result')
        entry = task.entries[0]
        print(entry['trakt_series_name'].lower())
        assert entry['trakt_series_name'].lower() == 'Shameless'.lower(
        ), 'lookup failed'
        with Session() as session:
            assert task.entries[1]['trakt_series_name'].lower(
            ) == 'Shameless'.lower(), 'second lookup failed'

            assert len(session.query(TraktShowSearchResult).all()
                       ) == 1, 'should have added 1 show to search result'

            assert len(session.query(TraktShow).all()
                       ) == 1, 'should only have added one show to show table'
            assert session.query(TraktShow).first().title == 'Shameless', 'should have added Shameless and' \
                                                                          'not Shameless (2011)'
            # change the search query
            session.query(TraktShowSearchResult).update(
                {'search': "shameless.s01e03.hdtv-flexget"})
            session.commit()

            lookupargs = {'title': "Shameless.S01E03.HDTV-FlexGet"}
            series = ApiTrakt.lookup_series(**lookupargs)

            assert series.tvdb_id == entry[
                'tvdb_id'], 'tvdb id should be the same as the first entry'
            assert series.id == entry[
                'trakt_show_id'], 'trakt id should be the same as the first entry'
            assert series.title.lower() == entry['trakt_series_name'].lower(
            ), 'series name should match first entry'
コード例 #3
0
ファイル: trakt_lookup.py プロジェクト: jacaru/flexget
 def lazy_watched_lookup(self, config, style, entry):
     """Does the lookup for this entry and populates the entry fields."""
     if style in ['show', 'episode', 'season']:
         lookup = lookup_series
         trakt_id = entry.get('trakt_show_id', eval_lazy=True)
     else:
         lookup = lookup_movie
         trakt_id = entry.get('trakt_movie_id', eval_lazy=True)
     with Session() as session:
         lookupargs = {'trakt_id': trakt_id, 'session': session}
         try:
             item = lookup(**lookupargs)
             if style == 'episode':
                 item = item.get_episode(entry['series_season'],
                                         entry['series_episode'], session)
             if style == 'season':
                 item = item.get_season(entry['series_season'], session)
             watched = ApiTrakt.watched(style,
                                        item,
                                        entry.get('title'),
                                        username=config.get('username'),
                                        account=config.get('account'))
         except LookupError as e:
             log.debug(e)
         else:
             entry['trakt_watched'] = watched
     return entry
コード例 #4
0
ファイル: test_trakt.py プロジェクト: BackSlasher/Flexget
    def test_search_results(self, execute_task):
        task = execute_task('test_search_results')
        entry = task.entries[0]
        assert entry['movie_name'].lower() == 'Harry Potter and The Philosopher\'s Stone'.lower(), 'lookup failed'
        with Session() as session:
            assert len(session.query(TraktMovieSearchResult).all()) == 1, 'should have added one movie to search result'

            # change the search query
            session.query(TraktMovieSearchResult).update({'search': "harry.potter.and.the.philosopher's"})
            session.commit()

            lookupargs = {'title': "harry.potter.and.the.philosopher's"}
            movie = ApiTrakt.lookup_movie(**lookupargs)

            assert movie.imdb_id == entry['imdb_id']
            assert movie.title.lower() == entry['movie_name'].lower()
コード例 #5
0
 def get(self, title, session=None):
     args = lookup_parser.parse_args()
     include_actors = args.pop('include_actors')
     include_translations = args.pop('include_translations')
     kwargs = args
     kwargs['title'] = title
     try:
         movie = at.lookup_movie(session=session, **kwargs)
     except LookupError as e:
         return {'status': 'error', 'message': e.args[0]}, 404
     result = movie.to_dict()
     if include_actors:
         result["actors"] = list_actors(movie.actors)
     if include_translations:
         result["translations"] = get_translations(movie.translate)
     return jsonify(result)
コード例 #6
0
 def get(self, title, session=None):
     args = lookup_parser.parse_args()
     include_actors = args.pop('include_actors')
     include_translations = args.pop('include_translations')
     kwargs = args
     kwargs['title'] = title
     try:
         movie = at.lookup_movie(session=session, **kwargs)
     except LookupError as e:
         raise NotFoundError(e.args[0])
     result = movie.to_dict()
     if include_actors:
         result['actors'] = list_actors(movie.actors)
     if include_translations:
         result['translations'] = get_translations_dict(movie.translations, 'movie')
     return jsonify(result)
コード例 #7
0
    def test_search_results(self, execute_task):
        task = execute_task('test_search_results')
        entry = task.entries[0]
        assert entry['movie_name'].lower() == 'Harry Potter and The Philosopher\'s Stone'.lower(), 'lookup failed'
        with Session() as session:
            assert len(session.query(TraktMovieSearchResult).all()) == 1, 'should have added one movie to search result'

            # change the search query
            session.query(TraktMovieSearchResult).update({'search': "harry.potter.and.the.philosopher's"})
            session.commit()

            lookupargs = {'title': "harry.potter.and.the.philosopher's"}
            movie = ApiTrakt.lookup_movie(session=session, **lookupargs)

            assert movie.imdb_id == entry['imdb_id']
            assert movie.title.lower() == entry['movie_name'].lower()
コード例 #8
0
 def get(self, title, session=None):
     """Trakt series lookup"""
     args = lookup_parser.parse_args()
     include_actors = args.pop('include_actors')
     include_translations = args.pop('include_translations')
     kwargs = args
     kwargs['title'] = title
     try:
         series = at.lookup_series(session=session, **kwargs)
     except LookupError as e:
         raise NotFoundError(e.args[0])
     result = series.to_dict()
     if include_actors:
         result['actors'] = list_actors(series.actors)
     if include_translations:
         result['translations'] = get_translations_dict(series.translations, 'show')
     return jsonify(result)
コード例 #9
0
 def get(self, title, session=None):
     """Trakt movie lookup"""
     args = lookup_parser.parse_args()
     include_actors = args.pop('include_actors')
     include_translations = args.pop('include_translations')
     kwargs = args
     kwargs['title'] = title
     try:
         movie = at.lookup_movie(session=session, **kwargs)
     except LookupError as e:
         raise NotFoundError(e.args[0])
     result = movie.to_dict()
     if include_actors:
         result['actors'] = list_actors(movie.actors)
     if include_translations:
         result['translations'] = get_translations_dict(movie.translations, 'movie')
     return jsonify(result)
コード例 #10
0
 def get(self, title, session=None):
     args = lookup_parser.parse_args()
     include_actors = args.pop('include_actors')
     include_translations = args.pop('include_translations')
     kwargs = args
     kwargs['title'] = title
     try:
         series = at.lookup_series(session=session, **kwargs)
     except LookupError as e:
         return {'status': 'error',
                 'message': e.args[0]
                 }, 404
     result = series.to_dict()
     if include_actors:
         result['actors'] = list_actors(series.actors)
     if include_translations:
         result['translations'] = get_translations_dict(series.translations, 'show')
     return jsonify(result)
コード例 #11
0
ファイル: trakt_lookup.py プロジェクト: Davst/Flexget
 def get(self, title, session=None):
     args = lookup_parser.parse_args()
     include_actors = args.pop('include_actors')
     include_translations = args.pop('include_translations')
     kwargs = args
     kwargs['title'] = title
     try:
         movie = at.lookup_movie(session=session, **kwargs)
     except LookupError as e:
         return {'status': 'error',
                 'message': e.args[0]
                 }, 404
     result = movie.to_dict()
     if include_actors:
         result["actors"] = list_actors(movie.actors)
     if include_translations:
         result["translations"] = get_translations(movie.translate)
     return jsonify(result)
コード例 #12
0
ファイル: trakt_lookup.py プロジェクト: ghyster/Flexget
 def lazy_watched_lookup(self, config, style, entry):
     """Does the lookup for this entry and populates the entry fields."""
     if style == 'show' or style == 'episode':
         lookup = lookup_series
         trakt_id = entry.get('trakt_show_id', eval_lazy=True)
     else:
         lookup = lookup_movie
         trakt_id = entry.get('trakt_movie_id', eval_lazy=True)
     with Session() as session:
         lookupargs = {'trakt_id': trakt_id,
                       'session': session}
         try:
             item = lookup(**lookupargs)
             if style == 'episode':
                 item = item.get_episode(entry['series_season'], entry['series_episode'], session)
             watched = ApiTrakt.watched(style, item, entry.get('title'), username=config.get('username'),
                                        account=config.get('account'))
         except LookupError as e:
             log.debug(e.args[0])
         else:
             entry['trakt_watched'] = watched
     return entry
コード例 #13
0
ファイル: test_trakt.py プロジェクト: BackSlasher/Flexget
    def test_search_results(self, execute_task):
        task = execute_task('test_search_result')
        entry = task.entries[0]
        print(entry['trakt_series_name'].lower())
        assert entry['trakt_series_name'].lower() == 'Shameless'.lower(), 'lookup failed'
        with Session() as session:
            assert task.entries[1]['trakt_series_name'].lower() == 'Shameless'.lower(), 'second lookup failed'

            assert len(session.query(TraktShowSearchResult).all()) == 1, 'should have added 1 show to search result'

            assert len(session.query(TraktShow).all()) == 1, 'should only have added one show to show table'
            assert session.query(TraktShow).first().title == 'Shameless', 'should have added Shameless and' \
                                                                          'not Shameless (2011)'
            # change the search query
            session.query(TraktShowSearchResult).update({'search': "shameless.s01e03.hdtv-flexget"})
            session.commit()

            lookupargs = {'title': "Shameless.S01E03.HDTV-FlexGet"}
            series = ApiTrakt.lookup_series(**lookupargs)

            assert series.tvdb_id == entry['tvdb_id'], 'tvdb id should be the same as the first entry'
            assert series.id == entry['trakt_show_id'], 'trakt id should be the same as the first entry'
            assert series.title.lower() == entry['trakt_series_name'].lower(), 'series name should match first entry'
コード例 #14
0
    def on_task_start(self, task, config):
        if not isinstance(config, dict):
            config = {}

        self.trakt = ApiTrakt(username=config.get('username'), account=config.get('account'))