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


Python VideoMetadata.imdb方法代码示例

本文整理汇总了Python中MythTV.VideoMetadata.imdb方法的典型用法代码示例。如果您正苦于以下问题:Python VideoMetadata.imdb方法的具体用法?Python VideoMetadata.imdb怎么用?Python VideoMetadata.imdb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MythTV.VideoMetadata的用法示例。


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

示例1: buildList

# 需要导入模块: from MythTV import VideoMetadata [as 别名]
# 或者: from MythTV.VideoMetadata import imdb [as 别名]
def buildList(query, opts):
    # TEMPORARY FIX:
    # replace all dashes from queries to work around search behavior
    # as negative to all text that comes afterwards
    query = query.replace('-',' ')

    from MythTV.tmdb3 import searchMovie
    from MythTV import VideoMetadata
    from lxml import etree
    results = searchMovie(query)
    tree = etree.XML(u'<metadata></metadata>')
    mapping = [['runtime',      'runtime'],     ['title',       'originaltitle'],
               ['releasedate',  'releasedate'], ['tagline',     'tagline'],
               ['description',  'overview'],    ['homepage',    'homepage'],
               ['userrating',   'userrating'],  ['popularity',  'popularity']]

    count = 0
    for res in results:
        m = VideoMetadata()
        for i,j in mapping:
            if getattr(res, j):
                setattr(m, i, getattr(res, j))
        m.inetref = str(res.id)
        m.imdb = str(res.imdb).lstrip("t")

        if res.title:
            m.title = res.title

        #TODO:
        # should releasedate and year be pulled from the country-specific data
        # or should it be left to the default information to cut down on
        # traffic from searches
        if res.releasedate:
            m.year = res.releasedate.year
        if res.backdrop:
            b = res.backdrop
            m.images.append({'type':'fanart', 'url':b.geturl(),
                             'thumb':b.geturl(b.sizes()[0])})
        if res.poster:
            p = res.poster
            m.images.append({'type':'coverart', 'url':p.geturl(),
                             'thumb':p.geturl(p.sizes()[0])})
        tree.append(m.toXML())
        count += 1
        if count >= 60:
            # page limiter, dont want to overload the server
            break

    sys.stdout.write(etree.tostring(tree, encoding='UTF-8', pretty_print=True,
                                    xml_declaration=True))
    sys.exit(0)
开发者ID:,项目名称:,代码行数:53,代码来源:

示例2: buildSingle

# 需要导入模块: from MythTV import VideoMetadata [as 别名]
# 或者: from MythTV.VideoMetadata import imdb [as 别名]
def buildSingle(inetref, opts):
    from MythTV.tmdb3 import Movie
    from MythTV import VideoMetadata
    from lxml import etree
    try:
      if len(inetref) == 7:
        movie = Movie.fromIMDB(inetref)
      else:
        movie = Movie(inetref)
    except:
      sys.exit(1)

    tree = etree.XML(u'<metadata></metadata>')
    mapping = [['runtime',      'runtime'],     ['title',       'originaltitle'],
               ['releasedate',  'releasedate'], ['tagline',     'tagline'],
               ['description',  'overview'],    ['homepage',    'homepage'],
               ['userrating',   'userrating'],  ['popularity',  'popularity'],
               ['budget',       'budget'],      ['revenue',     'revenue']]
    m = VideoMetadata()
    for i,j in mapping:
        if getattr(movie, j):
            setattr(m, i, getattr(movie, j))

    if movie.title:
        m.title = movie.title

    releases = movie.releases.items()

    if opts.country:
        try:
            # resort releases with selected country at top to ensure it
            # is selected by the metadata libraries
            index = zip(*releases)[0].index(opts.country)
            releases.insert(0, releases.pop(index))
        except ValueError:
            pass
        else:
            m.releasedate = releases[0][1].releasedate

    m.inetref = str(movie.id)
    m.imdb = str(movie.imdb).lstrip("t")
    if movie.collection:
        m.collectionref = str(movie.collection.id)
    if movie.releasedate:
        m.year = movie.releasedate.year
    for country, release in releases:
        if release.certification:
            m.certifications[country] = release.certification
    for genre in movie.genres:
        m.categories.append(genre.name)
    for studio in movie.studios:
        m.studios.append(studio.name)
    for country in movie.countries:
        m.countries.append(country.name)
    for cast in movie.cast:
        d = {'name':cast.name, 'character':cast.character, 'department':'Actors',
             'job':'Actor', 'url':'http://www.themoviedb.org/people/{0}'.format(cast.id)}
        if cast.profile: d['thumb'] = cast.profile.geturl()
        m.people.append(d)
    for crew in movie.crew:
        d = {'name':crew.name, 'job':crew.job, 'department':crew.department,
             'url':'http://www.themoviedb.org/people/{0}'.format(crew.id)}
        if crew.profile: d['thumb'] = crew.profile.geturl()
        m.people.append(d)
    for backdrop in movie.backdrops:
        m.images.append({'type':'fanart', 'url':backdrop.geturl(),
                        'thumb':backdrop.geturl(backdrop.sizes()[0])})
    for poster in movie.posters:
        m.images.append({'type':'coverart', 'url':poster.geturl(),
                        'thumb':poster.geturl(poster.sizes()[0])})
    tree.append(m.toXML())
    sys.stdout.write(etree.tostring(tree, encoding='UTF-8', pretty_print=True,
                                    xml_declaration=True))
    sys.exit()
开发者ID:,项目名称:,代码行数:76,代码来源:


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