• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.extract_ids函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: show_collection

 def show_collection(self):
     """All :class:`TVShow`'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._show_collection is None:
         ext = 'users/{username}/collection/shows?extended=metadata'
         data = yield ext.format(username=self.username)
         self._show_collection = []
         for show in data:
             s = show.pop('show')
             extract_ids(s)
             sh = TVShow(**s)
             sh._seasons = [TVSeason(show=sh.title, **sea)
                            for sea in show.pop('seasons')]
             self._show_collection.append(sh)
     yield self._show_collection
开发者ID:mampersat,项目名称:PyTrakt,代码行数:17,代码来源:users.py


示例17: create

    def create(cls, name, creator, description=None, privacy='private',
               display_numbers=False, allow_comments=True):
        """Create a new custom class:`UserList`. *name* is the only required
        field, but the other info is recommended.

        :param name: Name of the list.
        :param description:	Description of this list.
        :param privacy:	Valid values are 'private', 'friends', or 'public'
        :param display_numbers: Bool, should each item be numbered?
        :param allow_comments: Bool, are comments allowed?
        """
        args = {'name': name, 'privacy': privacy,
                'display_numbers': display_numbers,
                'allow_comments': allow_comments}
        if description is not None:
            args['description'] = description
        data = yield 'users/{user}/lists'.format(user=creator), args
        extract_ids(data)
        yield UserList(creator=creator, user=creator, **data)
开发者ID:mampersat,项目名称:PyTrakt,代码行数:19,代码来源:users.py


示例18: search

def search(query, search_type='movie', year=None):
    """Perform a search query against all of trakt's media types

    :param query: Your search string
    :param search_type: The type of object you're looking for. Must be one of
        'movie', 'show', 'episode', or 'person'
    """
    valids = ('movie', 'show', 'episode', 'person')
    if search_type not in valids:
        raise ValueError('search_type must be one of {}'.format(valids))
    uri = 'search?query={query}&type={type}'.format(
        query=slugify(query), type=search_type)

    if year is not None:
        uri += '&year={}'.format(year)

    data = yield uri

    for media_item in data:
        extract_ids(media_item)

    # Need to do imports here to prevent circular imports with modules that
    # need to import Scrobblers
    if search_type == 'movie':
        from trakt.movies import Movie
        yield [Movie(**d.pop('movie')) for d in data]
    elif search_type == 'show':
        from trakt.tv import TVShow
        yield [TVShow(**d.pop('show')) for d in data]
    elif search_type == 'episode':
        from trakt.tv import TVEpisode
        episodes = []
        for episode in data:
            show = episode.pop('show')
            extract_ids(episode['episode'])
            episodes.append(TVEpisode(show.get('title', None),
                                      **episode['episode']))
        yield episodes
    elif search_type == 'person':
        from trakt.people import Person
        yield [Person(**d.pop('person')) for d in data]
开发者ID:yoursvivek,项目名称:PyTrakt,代码行数:41,代码来源:sync.py


示例19: lists

 def lists(self):
     """All custom lists for this :class:`User`. Protected :class:`User`'s
     won't return any data unless you are friends. To view your own private
     lists, you will need to authenticate as yourself.
     """
     if self._lists is None:
         data = yield 'users/{username}/lists'.format(
             username=self.username
         )
         self._lists = [UserList(creator=self.username, user=self,
                        **extract_ids(ul)) for ul in data]
     yield self._lists
开发者ID:mampersat,项目名称:PyTrakt,代码行数:12,代码来源:users.py


示例20: watching

    def watching(self):
        """The :class:`TVEpisode` or :class:`Movie` this :class:`User` is
        currently watching. If they aren't watching anything, a blank object
        will be returned. Protected users won't return any data unless you are
        friends.
        """
        data = yield 'users/{user}/watching'.format(user=self.username)

        # if a user isn't watching anything, trakt returns a 204
        if data is None or data == '':
            yield None

        media_type = data.pop('type')
        if media_type == 'movie':
            movie_data = data.pop('movie')
            extract_ids(movie_data)
            movie_data.update(data)
            yield Movie(**movie_data)
        else:  # media_type == 'episode'
            ep_data = data.pop('episode')
            extract_ids(ep_data)
            sh_data = data.pop('show')
            ep_data.update(data, show=sh_data.get('title'))
            yield TVEpisode(**ep_data)
开发者ID:mampersat,项目名称:PyTrakt,代码行数:24,代码来源:users.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python trans.translate函数代码示例发布时间:2022-05-27
下一篇:
Python summary.SummaryMapper类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap