Ejemplo n.º 1
0
    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'
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
    def get(self, session=None):
        args = lookup_parser.parse_args()
        try:
            result = at.lookup_series(session=session, **args)
        except LookupError as e:
            return {'status': 'error',
                    'message': e.args[0]
                    }, 404

        return jsonify(result.to_dict())
Ejemplo n.º 4
0
    def get(self, session=None):
        args = lookup_parser.parse_args()
        try:
            result = at.lookup_series(session=session, **args)
        except LookupError as e:
            return {'status': 'error',
                    'message': e.args[0]
                    }, 404

        return jsonify(result.to_dict())
Ejemplo n.º 5
0
 def get(self, session=None):
     args = lookup_parser.parse_args()
     include_actors = args.pop('include_actors')
     try:
         series = at.lookup_series(session=session, **args)
     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),
     return jsonify(result)
Ejemplo n.º 6
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(**lookupargs)

            assert movie.imdb_id == entry['imdb_id']
            assert movie.title.lower() == entry['movie_name'].lower()
Ejemplo n.º 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(**lookupargs)

            assert movie.imdb_id == entry['imdb_id']
            assert movie.title.lower() == entry['movie_name'].lower()
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
 def lazy_watched_lookup(self, config, style, entry):
     """Does the lookup for this entry and populates the entry fields."""
     if style == 'episode':
         lookup = lookup_series
         id = entry.get('trakt_show_id', eval_lazy=True)
     else:
         lookup = lookup_movie
         id = entry.get('trakt_movie_id', eval_lazy=True)
     with Session() as session:
         lookupargs = {'trakt_id': id,
                       'session': session}
         try:
             item = lookup(**lookupargs)
             if style == 'episode':
                 item = item.get_episode(entry['series_season'], entry['series_episode'])
             watched = ApiTrakt.watched(config['username'], style, item, entry.get('title'),
                                        account=config.get('account'))
         except LookupError as e:
             log.debug(e.args[0])
         else:
             entry['trakt_watched'] = watched
     return entry
Ejemplo n.º 10
0
    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_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'