当前位置: 首页>>代码示例>>Python>>正文


Python utils.extract_ids函数代码示例

本文整理汇总了Python中trakt.utils.extract_ids函数的典型用法代码示例。如果您正苦于以下问题:Python extract_ids函数的具体用法?Python extract_ids怎么用?Python extract_ids使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了extract_ids函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: search_by_id

def search_by_id(query, id_type='imdb'):
    """Perform a search query by using a Trakt.tv ID or other external ID

    :param query: Your search string
    :param id_type: The type of object you're looking for. Must be one of
        'trakt-movie', 'trakt-show', 'trakt-episode', 'imdb', 'tmdb', 'tvdb' or
        'tvrage'
    """
    valids = ('trakt-movie', 'trakt-show', 'trakt-episode', 'imdb', 'tmdb',
              'tvdb', 'tvrage')
    if id_type not in valids:
        raise ValueError('search_type must be one of {}'.format(valids))
    data = yield 'search?id={query}&id_type={id_type}'.format(
        query=slugify(query), id_type=id_type)

    for media_item in data:
        extract_ids(media_item)

    results = []
    for d in data:
        if 'episode' in d:
            from trakt.tv import TVEpisode
            show = d.pop('show')
            extract_ids(d['episode'])
            results.append(TVEpisode(show['title'], **d['episode']))
        elif 'movie' in d:
            from trakt.movies import Movie
            results.append(Movie(**d.pop('movie')))
        elif 'show' in d:
            from trakt.tv import TVShow
            results.append(TVShow(**d.pop('show')))
        elif 'person' in d:
            from trakt.people import Person
            results.append(Person(**d.pop('person')))
    yield results
开发者ID:yoursvivek,项目名称:PyTrakt,代码行数:35,代码来源:sync.py

示例2: _build

 def _build(self, data):
     extract_ids(data)
     for key, val in data.items():
         if hasattr(self, '_' + key):
             setattr(self, '_' + key, val)
         else:
             setattr(self, key, val)
开发者ID:mampersat,项目名称:PyTrakt,代码行数:7,代码来源:tv.py

示例3: _build

 def _build(self, data):
     extract_ids(data)
     for key, val in data.items():
         try:
             setattr(self, key, val)
         except AttributeError as ae:
             if not hasattr(self, '_' + key):
                 raise ae
开发者ID:TheJake123,项目名称:PyTrakt,代码行数:8,代码来源:people.py

示例4: popular_shows

def popular_shows():
    data = yield 'shows/popular'
    shows = []
    for show in data:
        data = show.get('ids', {})
        extract_ids(data)
        data['year'] = show['year']
        shows.append(TVShow(show['title'], **data))
    yield shows
开发者ID:mampersat,项目名称:PyTrakt,代码行数:9,代码来源:tv.py

示例5: get

    def get(cls, title, creator):
        """Returns a single custom :class:`UserList`

        :param title: Name of the list.
        """
        data = yield 'users/{user}/lists/{id}'.format(user=creator,
                                                      id=slugify(title))
        extract_ids(data)
        yield UserList(creator=creator, **data)
开发者ID:mampersat,项目名称:PyTrakt,代码行数:9,代码来源:users.py

示例6: trending_shows

def trending_shows():
    """All :class:`TVShow`'s being watched right now"""
    data = yield 'shows/trending'
    to_ret = []
    for show in data:
        show_data = show.pop('show')
        ids = show_data.pop('ids')
        extract_ids(ids)
        show_data['watchers'] = show.get('watchers')
        to_ret.append(TVShow(**show_data))
    yield to_ret
开发者ID:mampersat,项目名称:PyTrakt,代码行数:11,代码来源:tv.py

示例7: get_recommended_movies

def get_recommended_movies():
    """Get a list of :class:`Movie`'s recommended based on your watching
    history and your friends. Results are returned with the top recommendation
    first.
    """
    data = yield 'recommendations/movies'
    movies = []
    for movie in data:
        extract_ids(movie)
        movies.append(Movie(**movie))
    yield movies
开发者ID:TheJake123,项目名称:PyTrakt,代码行数:11,代码来源:movies.py

示例8: seasons

 def seasons(self):
     """A list of :class:`TVSeason` objects representing all of this show's
     seasons
     """
     if self._seasons is None:
         data = yield (self.ext + '/seasons?extended=full')
         self._seasons = []
         for season in data:
             extract_ids(season)
             self._seasons.append(TVSeason(self.title, **season))
     yield self._seasons
开发者ID:mampersat,项目名称:PyTrakt,代码行数:11,代码来源:tv.py

示例9: watchlist_movies

 def watchlist_movies(self):
     """Returns all watchlist movies of :class:`User`.
     """
     if self._movie_watchlist is None:
         data = yield 'users/{username}/watchlist/movies'.format(
             username=self.username,
         )
         self._movie_watchlist = []
         for movie in data:
             mov = movie.pop('movie')
             extract_ids(mov)
             self._movie_watchlist.append(Movie(**mov))
         yield self._movie_watchlist
     yield self._movie_watchlist
开发者ID:mampersat,项目名称:PyTrakt,代码行数:14,代码来源:users.py

示例10: movie_collection

 def movie_collection(self):
     """All :class:`Movie`'s in this :class:`User`'s library collection.
     Collection items might include blu-rays, dvds, and digital downloads.
     Protected users won't return any data unless you are friends.
     """
     if self._movie_collection is None:
         ext = 'users/{username}/collection/movies?extended=metadata'
         data = yield ext.format(username=self.username)
         self._movie_collection = []
         for movie in data:
             mov = movie.pop('movie')
             extract_ids(mov)
             self._movie_collection.append(Movie(**mov))
     yield self._movie_collection
开发者ID:mampersat,项目名称:PyTrakt,代码行数:14,代码来源:users.py

示例11: updated_movies

def updated_movies(timestamp=None):
    """Returns all movies updated since a timestamp. The server time is in PST.
    To establish a baseline timestamp, you can use the server/time method. It's
    recommended to store the timestamp so you can be efficient in using this
    method.
    """
    ts = timestamp or now()
    data = yield 'movies/updates/{start_date}'.format(start_date=ts)
    to_ret = []
    for movie in data:
        mov = movie.pop('movie')
        extract_ids(mov)
        mov.update({'updated_at': movie.pop('updated_at')})
        to_ret.append(Movie(**mov))
    yield to_ret
开发者ID:TheJake123,项目名称:PyTrakt,代码行数:15,代码来源:movies.py

示例12: watchlist_shows

 def watchlist_shows(self):
     """Returns all watchlist shows of :class:`User`.
     """
     if self._show_watchlist is None:
         data = yield 'users/{username}/watchlist/shows'.format(
             username=self.username,
         )
         self._show_watchlist = []
         for show in data:
             show_data = show.pop('show')
             extract_ids(show_data)
             show_data.update(show)
             self._show_watchlist.append(TVShow(**show_data))
         yield self._show_watchlist
     yield self._show_watchlist
开发者ID:mampersat,项目名称:PyTrakt,代码行数:15,代码来源:users.py

示例13: watched_shows

 def watched_shows(self):
     """Watched profess for all :class:`TVShow`'s in this :class:`User`'s
     collection.
     """
     if self._watched_shows is None:
         data = yield 'users/{user}/watched/shows'.format(
             user=self.username
         )
         self._watched_shows = []
         for show in data:
             show_data = show.pop('show')
             extract_ids(show_data)
             show_data.update(show)
             self._watched_shows.append(TVShow(**show_data))
     yield self._watched_shows
开发者ID:mampersat,项目名称:PyTrakt,代码行数:15,代码来源:users.py

示例14: watched_movies

 def watched_movies(self):
     """Watched profess for all :class:`Movie`'s in this :class:`User`'s
     collection.
     """
     if self._watched_movies is None:
         data = yield 'users/{user}/watched/movies'.format(
             user=self.username
         )
         self._watched_movies = []
         for movie in data:
             movie_data = movie.pop('movie')
             extract_ids(movie_data)
             movie_data.update(movie)
             self._watched_movies.append(Movie(**movie_data))
     yield self._watched_movies
开发者ID:mampersat,项目名称:PyTrakt,代码行数:15,代码来源:users.py

示例15: test_extract_ids

def test_extract_ids():
    """verify that id dicts can be correctly extracted"""
    ids = dict(trakt=443, tvdb=4851180, imdb='tt3500614', tmdb=988123,
               tvrage=None)
    input_dict = {'ids': ids}
    result = extract_ids(input_dict)
    assert result == ids
开发者ID:TheJake123,项目名称:PyTrakt,代码行数:7,代码来源:test_utils.py


注:本文中的trakt.utils.extract_ids函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。