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

Python MythTV.VideoMetadata类代码示例

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

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



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

示例1: buildCollection

def buildCollection(inetref, opts):
    from MythTV.tmdb3.tmdb_exceptions import TMDBRequestInvalid
    from MythTV.tmdb3 import Collection
    from MythTV import VideoMetadata
    from lxml import etree
    collection = Collection(inetref)
    tree = etree.XML(u'<metadata></metadata>')
    m = VideoMetadata()
    m.collectionref = str(collection.id)
    try:
        m.title = collection.name
    except TMDBRequestInvalid:
        sys.stdout.write(etree.tostring(tree, encoding='UTF-8', pretty_print=True,
                                        xml_declaration=True))
        sys.exit()
    if collection.backdrop:
        b = collection.backdrop
        m.images.append({'type':'fanart', 'url':b.geturl(),
                  'thumb':b.geturl(b.sizes()[0])})
    if collection.poster:
        p = collection.poster
        m.images.append({'type':'coverart', 'url':p.geturl(),
                  'thumb':p.geturl(p.sizes()[0])})
    tree.append(m.toXML())
    sys.stdout.write(etree.tostring(tree, encoding='UTF-8', pretty_print=True,
                                    xml_declaration=True))
    sys.exit()
开发者ID:adicarlo,项目名称:mythtv,代码行数:27,代码来源:tmdb3.py


示例2: buildList

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:
        if res is None:
            continue

        m = VideoMetadata()
        for i, j in mapping:
            if getattr(res, j):
                setattr(m, i, getattr(res, j))
        m.inetref = str(res.id)

        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:,项目名称:,代码行数:57,代码来源:


示例3: buildList

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)

        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:aravilife,项目名称:mythtv-stabilize2,代码行数:50,代码来源:tmdb3.py


示例4: buildCollection

def buildCollection(inetref, language):
    collection = Collection(inetref)
    tree = etree.XML(u'<metadata></metadata>')
    m = VideoMetadata()
    m.collectionref = str(collection.id)
    m.title = collection.name
    if collection.backdrop:
        m.images.append({'type':'fanart', 'url':collection.backdrop.geturl(),
                  'thumb':collection.backdrop.geturl(collection.backdrop.sizes()[0])})
    if collection.poster:
        m.images.append({'type':'coverart', 'url':collection.poster.geturl(),
                  'thumb':collection.poster.geturl(collection.poster.sizes()[0])})
    tree.append(m.toXML())
    sys.stdout.write(etree.tostring(tree, encoding='UTF-8', pretty_print=True))
    sys.exit()
开发者ID:,项目名称:,代码行数:15,代码来源:


示例5: buildSingle

def buildSingle(inetref, opts):
    from MythTV.tmdb3.tmdb_exceptions import TMDBRequestInvalid
    from MythTV.tmdb3 import Movie
    from MythTV import VideoMetadata
    from lxml import etree

    import re
    if re.match('^0[0-9]{6}$', inetref):
        movie = Movie.fromIMDB(inetref)
    else:
        movie = Movie(inetref)

    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:
        try:
            if getattr(movie, j):
                setattr(m, i, getattr(movie, j))
        except TMDBRequestInvalid:
            sys.stdout.write(etree.tostring(tree, encoding='UTF-8', pretty_print=True,
                                            xml_declaration=True))
            sys.exit()

    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 IndexError, ValueError:
            pass
        else:
            m.releasedate = releases[0][1].releasedate
开发者ID:shyamalschandra,项目名称:mythtv,代码行数:43,代码来源:tmdb3.py


示例6: buildSingle

def buildSingle(inetref, language):
    movie = Movie(inetref)
    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:
        setattr(m, i, getattr(movie, j))
    m.inetref = str(movie.id)
    m.year = movie.releasedate.year
    for country, release in movie.releases.items():
        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 is not None: 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(cast.id)}
        if crew.profile is not None: 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))
    sys.exit()
开发者ID:daveyboyc,项目名称:mythtv,代码行数:41,代码来源:tmdb3.py


示例7: buildSingle

def buildSingle(inetref, opts):
    from MythTV.tmdb3 import Movie
    from MythTV import VideoMetadata
    from lxml import etree

    import re
    if re.match('^0[0-9]{6}$', inetref):
        movie = Movie.fromIMDB(inetref)
    else:
        movie = Movie(inetref)

    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)
    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]),
                        'height':str(backdrop.height),
                        'width':str(backdrop.width)})
    for poster in movie.posters:
        m.images.append({'type':'coverart', 'url':poster.geturl(),
                        'thumb':poster.geturl(poster.sizes()[0]),
                        'height':str(poster.height),
                        'width':str(poster.width)})
    tree.append(m.toXML())
    sys.stdout.write(etree.tostring(tree, encoding='UTF-8', pretty_print=True,
                                    xml_declaration=True))
    sys.exit()
开发者ID:imclab,项目名称:mythtv,代码行数:76,代码来源:tmdb3.py


示例8: buildSingle

def buildSingle(inetref, opts):
    from MythTV.tmdb3 import Movie
    from MythTV import VideoMetadata
    from lxml import etree

    import re

    if re.match("^0[0-9]{6}$", inetref):
        movie = Movie.fromIMDB(inetref)
    else:
        movie = Movie(inetref)

    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)
    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:,项目名称:,代码行数:88,代码来源:


示例9: buildList

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('-',' ')
    query = query.strip() # trim extra whitespace
    # extract year from name -- note that we require a space before the year
    # so we don't confuse movie names for years (example: "2012 - 2009",
    # a 2009 movie); also note that we accept optional paranthesis around
    # the year:
    yearRegex = re.compile(r"\s\(?((19|20)[0-9]{2})\)?$")
    year = yearRegex.search(query)
    if year is not None:
        year = year.group(1)
    # if no year was found, we'll pass year=None to searchMovie,
    # which is the default anyway

    # get rid of the year (if any) from the query text, because
    # it causes bad TMDB results
    query = yearRegex.sub("", query)
    query = query.strip()

    from MythTV.tmdb3 import searchMovie
    from MythTV import VideoMetadata
    from lxml import etree
    results = iter(searchMovie(query, locale=None, adult=False, year=year))
    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
    while True:
        try:
            res = results.next()
        except StopIteration:
            # end of results
            break
        except IndexError:
            # unexpected end of results
            # we still want to return whatever we have so far
            break

        if res is None:
            # faulty data, skip it and continue
            continue

        m = VideoMetadata()
        for i,j in mapping:
            if getattr(res, j):
                setattr(m, i, getattr(res, j))
        m.inetref = str(res.id)

        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:chrisaljoudi,项目名称:mythtv,代码行数:80,代码来源:tmdb3.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python database.DBCache类代码示例发布时间:2022-05-24
下一篇:
Python conversions.copy函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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