コード例 #1
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'
コード例 #2
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(series.translate)
     return jsonify(result)
コード例 #3
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:
         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)
コード例 #4
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)
コード例 #5
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:
         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(series.translate)
     return jsonify(result)
コード例 #6
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'