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


Python meta.import_tmdb函数代码示例

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


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

示例1: movies_batch_add_to_library

def movies_batch_add_to_library():
    """ Batch add movies to library """
    movie_batch_file = plugin.get_setting(SETTING_MOVIES_BATCH_ADD_FILE_PATH)
    if xbmcvfs.exists(movie_batch_file):
        try:
            f = open(xbmc.translatePath(movie_batch_file), 'r')
            r = f.read()
            f.close()
            ids = r.split('\n')
        except: return plugin.notify(msg='Movies Batch Add File', title='Not found', delay=3000, image=get_icon_path("movies"))
        library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER))
        import_tmdb()
        for id in ids:
            if "," in id:
                csvs = id.split(',')
                for csv in csvs:
                    if not str(csv).startswith("tt") and csv != "":
                        movie = tmdb.Movies(csv).info()
                        id = movie.get('imdb_id')
                    batch_add_movies_to_library(library_folder, id)
            else:
                if not str(id).startswith("tt") and id != "":
                    movie = tmdb.Movies(id).info()
                    id = movie.get('imdb_id')
                batch_add_movies_to_library(library_folder, id)
        os.remove(xbmc.translatePath(movie_batch_file))
        if xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH)): 
            xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/batch_add_to_library)")
            return True
        else:
            xbmc.sleep(1000)
            plugin.notify(msg='Added movie strm-files', title='Starting library scan', delay=3000, image=get_icon_path("movies"))
            scan_library(type="video")
            return True
    elif xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH)): xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/batch_add_to_library)")
开发者ID:noobsandnerds,项目名称:noobsandnerds,代码行数:35,代码来源:movies.py

示例2: movies_genre

def movies_genre(id, page):
    """ Movies by genre id """
    import_tmdb()
    result = tmdb.Genres(id).movies(id=id, language=LANG, page=page)
    items = list_tmdb_movies(result)
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
开发者ID:noobsandnerds,项目名称:noobsandnerds,代码行数:7,代码来源:movies.py

示例3: movies_add_to_library

def movies_add_to_library(src, id):
    """ Add movie to library """
    library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER))
    date = None
    if src == "tmdb":
        import_tmdb()
        movie = tmdb.Movies(id).info()
        date = date_to_timestamp(movie.get('release_date'))
        imdb_id = movie.get('imdb_id')
        if imdb_id:
            src = "imdb"
            id = imdb_id
    players = active_players("movies")
    if plugin.get_setting(SETTING_MOVIES_DEFAULT_AUTO_ADD, bool) == True:
        player = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    else:
        players.insert(0, ADDON_SELECTOR)
        players.insert(0, ADDON_DEFAULT)
        selection = dialogs.select(_("Play with..."), [p.title for p in players])
        if selection == -1:
            return
        player = players[selection]
    # setup library folder
    library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER))
    # add to library
    if plugin.get_setting(SETTING_MOVIES_DEFAULT_AUTO_ADD, bool) == True:
        add_movie_to_library(library_folder, src, id, play_plugin=plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode))
    else:
        add_movie_to_library(library_folder, src, id, play_plugin=ADDON_DEFAULT.id)
    scan_library(type="video")
开发者ID:noobsandnerds,项目名称:noobsandnerds,代码行数:30,代码来源:movies.py

示例4: tmdb_movies_search_term

def tmdb_movies_search_term(term, page):
    """ Perform search of a specified <term>"""
    import_tmdb()
    result = tmdb.Search().movie(query=term, language = LANG, page = page)
    items = list_tmdb_movies(result)
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
开发者ID:noobsandnerds,项目名称:noobsandnerds,代码行数:7,代码来源:movies.py

示例5: tmdb_movies_most_popular

def tmdb_movies_most_popular(page):
    """ Most popular movies """
    import_tmdb()    
    result = tmdb.Movies().popular(language=LANG, page=page)
    items = list_tmdb_movies(result)
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
开发者ID:noobsandnerds,项目名称:noobsandnerds,代码行数:7,代码来源:movies.py

示例6: get_episode_parameters

def get_episode_parameters(show, season, episode):
    import_tmdb()
    if season in show and episode in show[season]:
        season_obj = show[season]
        episode_obj = show[season][episode]
    else:
        return
    # Get parameters
    parameters = {'id': show['id'], 'season': season, 'episode': episode}
    show_info = get_tvshow_metadata_tvdb(show, banners=True)
    network = show.get('network', '')
    parameters['network'] = network
    if network:
        parameters['network_clean'] = re.sub("(\(.*?\))", "", network).strip()
    else:
        parameters['network_clean'] = network
    parameters['showname'] = show['seriesname']
    parameters['clearname'] = re.sub("(\(.*?\))", "", show['seriesname']).strip()
    parameters['urlname'] = urllib.quote(to_utf8(parameters['clearname']))
    articles = ['a ', 'A ', 'An ', 'an ', 'The ', 'the ']
    parameters['sortname'] = parameters['clearname']
    for article in articles:
        if to_utf8(parameters['clearname']).startswith(article): parameters['sortname'] = to_utf8(parameters['clearname']).replace(article,'')
    parameters['shortname'] = parameters['clearname'][1:-1]
    try:
        parameters['absolute_number'] = int(episode_obj.get('absolute_number'))
    except:
        parameters['absolute_number'] = "na"
    parameters['title'] = episode_obj.get('episodename', str(episode))
    parameters['urltitle'] = urllib.quote(to_utf8(parameters['title']))
    parameters['firstaired'] = episode_obj.get('firstaired')
    parameters['year'] = show.get('year', 0)
    parameters['imdb'] = show.get('imdb_id', '')
    parameters['epid'] = episode_obj.get('id')
#    parameters['score'] = show['rating']
#    parameters['vote_count'] = show['ratingcount']
#    parameters['runtime'] = show['runtime']
#    parameters['duration'] = int(show['runtime']) * 60
#    parameters['plot'] = show['overview']
#    parameters['banner'] = "http://thetvdb.com/banners/graphical/" + str(show['id']) + "-g2.jpg"
    parameters['poster'] = "http://thetvdb.com/banners/posters/" + str(show['id']) + "-2.jpg"
    parameters['fanart'] = "http://thetvdb.com/banners/fanart/original/" + str(show['id']) + "-2.jpg"
    parameters['thumbnail'] = "http://thetvdb.com/banners/episodes/" + str(show['id']) + "/" + str(parameters['epid']) + ".jpg"
#    parameters['trailer'] = "plugin://script.extendedinfo/?info=playtvtrailer&tvdb_id=" + str(show['id'])
    try:
        genre = [x for x in show['genre'].split('|') if not x == '']
    except:
        genre = []
    parameters['genre'] = " / ".join(genre)
    is_anime = False
    if parameters['absolute_number'] and parameters['absolute_number'] != '0' and "animation" in parameters['genre'].lower():
        tmdb_results = tmdb.Find(show['id']).info(external_source="tvdb_id") or {}
        for tmdb_show in tmdb_results.get("tv_results", []):
            if "JP" in tmdb_show['origin_country']:
                is_anime = True
    if is_anime:
        parameters['name'] = u'{showname} {absolute_number}'.format(**parameters)
    else:
        parameters['name'] = u'{showname} S{season:02d}E{episode:02d}'.format(**parameters)
    return parameters
开发者ID:noobsandnerds,项目名称:noobsandnerds,代码行数:60,代码来源:tvshows.py

示例7: movies_related

def movies_related(id, page):
    import_tmdb()
    movie = tmdb.Movies(id).info()
    imdb_id = movie.get('imdb_id')
    from trakt import trakt
    results, pages = trakt.trakt_get_related_movies_paginated(imdb_id, page)
    return list_trakt_items(results, pages, page)
开发者ID:vphuc81,项目名称:MyRepository,代码行数:7,代码来源:movies.py

示例8: tmdb_tv_genres

def tmdb_tv_genres():
    import_tmdb()
    result = tmdb.Genres().list_tv(language=LANG)
    genres= dict([(i['id'], i['name']) for i in result['genres'] \
            if i['name'] is not None])
    if genres:
        return genres
    return None
开发者ID:OpenELEQ,项目名称:testing.meta,代码行数:8,代码来源:base.py

示例9: movies_related

def movies_related(id):
    import_tmdb()
    movie = tmdb.Movies(id).info()
    imdb_id = movie.get('imdb_id')
    from trakt import trakt
    results = trakt.trakt_get_related_movies_paginated(imdb_id)
    items = list_trakt_movies_related(results)
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
开发者ID:noobsandnerds,项目名称:noobsandnerds,代码行数:9,代码来源:movies.py

示例10: guide_movies_play

def guide_movies_play(src, id, mode="external"):
    import_tmdb()
    tmdb_id = None
    if src == "tmdb": tmdb_id = id
    elif src == "imdb":
        info = tmdb.Find(id).info(external_source="imdb_id")
        try: tmdb_id = info["movie_results"][0]["id"]
        except (KeyError, TypeError): pass
    if tmdb_id: play_movie_from_guide(tmdb_id, mode)
    else: plugin.set_resolved_url()
开发者ID:noobsandnerds,项目名称:noobsandnerds,代码行数:10,代码来源:movies.py

示例11: play_movie

def play_movie(tmdb_id, mode):
    import_tmdb()
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'context':
        play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_movie_player_plugin_from_library(tmdb_id)
        if not play_plugin or play_plugin == "default":
            play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER, unicode)
    else:
        play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("movies")
    else: players = get_players("movies")
    players = [p for p in players if p.id == play_plugin] or players
    if not players:
        xbmc.executebuiltin( "Action(Info)")
        action_cancel()
        return
    # Get movie data from TMDB
    movie = tmdb.Movies(tmdb_id).info(language=LANG, append_to_response="external_ids,videos")
    movie_info = get_movie_metadata(movie)
    # Get movie ids from Trakt
    trakt_ids = get_trakt_ids("tmdb", tmdb_id, movie['original_title'],
                    "movie", parse_year(movie['release_date']))
    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        if lang == LANG:
            tmdb_data = movie
        else:
            tmdb_data = tmdb.Movies(tmdb_id).info(language=lang)
        params[lang] = get_movie_parameters(tmdb_data)
        if trakt_ids != None:
            params[lang].update(trakt_ids)
        params[lang]['info'] = movie_info
        params[lang] = to_unicode(params[lang])
    # Go for it
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        movie = tmdb.Movies(tmdb_id).info(language=LANG)
        action_play({
            'label': movie_info['title'],
            'path': link,
            'info': movie_info,
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': movie_info['poster'],
            'poster': movie_info['poster'],
            'properties' : {'fanart_image' : movie_info['fanart']},
        })
开发者ID:vphuc81,项目名称:MyRepository,代码行数:54,代码来源:movies.py

示例12: get_episode_parameters

def get_episode_parameters(show, season, episode):
    import_tmdb()
    
    if season in show and episode in show[season]:
        episode_obj = show[season][episode]
    else:
        dialogs.ok(_("Episode info not found"), "No tvdb information found for {0} - S{1}E{2}".format(
            show['seriesname'], season, episode))
        return
    
    # Get parameters
    parameters = {'id': show['id'], 'season': season, 'episode': episode}
    
    network = show.get('network', '')
    
    parameters['network'] = network
    if network:
        parameters['network_clean'] = re.sub("(\(.*?\))", "", network).strip()
    else:
        parameters['network_clean'] = network
        
    parameters['showname'] = show['seriesname']
    #parameters['clearname'], _ = xbmc.getCleanMovieTitle(parameters['showname'])
    parameters['clearname'] = re.sub("(\(.*?\))", "", show['seriesname']).strip()

    parameters['absolute_number'] = episode_obj.get('absolute_number')
    parameters['title'] = episode_obj.get('episodename', str(episode))
    parameters['firstaired'] = episode_obj.get('firstaired')
    parameters['year'] = show.get('year', 0)
    parameters['imdb'] = show.get('imdb_id', '')    

    try:
        genre = [x for x in show['genre'].split('|') if not x == '']
    except:
        genre = []
    parameters['genre'] = " / ".join(genre)

    is_anime = False
    if parameters['absolute_number'] and \
     parameters['absolute_number'] != '0' and \
     "animation" in parameters['genre'].lower():
        tmdb_results = tmdb.Find(show['id']).info(external_source="tvdb_id") or {}
        for tmdb_show in tmdb_results.get("tv_results", []):
            if "JP" in tmdb_show['origin_country']:
                is_anime = True
        
    if is_anime:
        parameters['name'] = u'{showname} {absolute_number}'.format(**parameters)
    else:
        parameters['name'] = u'{showname} S{season:02d}E{episode:02d}'.format(**parameters)

    return parameters
开发者ID:OpenELEQ,项目名称:meta4kodi,代码行数:52,代码来源:tvshows.py

示例13: get_episode_parameters

def get_episode_parameters(show, season, episode):
    import_tmdb()
    
    episode_obj = show[season][episode]
    
    # Get parameters
    parameters = {'id': show['id'], 'season': season, 'episode': episode}
    
    network = show.get('network', '')
    
    parameters['network'] = network
    parameters['network_clean'] = re.sub("(\(.*?\))", "", network).strip()
    
    parameters['showname'] = show['seriesname']
    #parameters['clearname'], _ = xbmc.getCleanMovieTitle(parameters['showname'])
    parameters['clearname'] = re.sub("(\(.*?\))", "", network).strip()

    parameters['absolute_number'] = episode_obj.get('absolute_number')
    parameters['title'] = episode_obj.get('episodename', str(episode))
    parameters['firstaired'] = episode_obj.get('firstaired')
    parameters['year'] = show.get('year', 0)
    parameters['imdb'] = show.get('imdb_id', '')    

    try:
        genre = [x for x in show['genre'].split('|') if not x == '']
    except:
        genre = []
    parameters['genre'] = " / ".join(genre)

    is_anime = False
    if parameters['absolute_number'] and \
     parameters['absolute_number'] != '0' and \
     "animation" in parameters['genre'].lower():
        tmdb_results = tmdb.Find(show['id']).info(external_source="tvdb_id") or {}
        for tmdb_show in tmdb_results.get("tv_results", []):
            if "JP" in tmdb_show['origin_country']:
                is_anime = True
        
    if is_anime:
        parameters['name'] = u'{showname} {absolute_number}'.format(**parameters)
    else:
        parameters['name'] = u'{showname} S{season:02d}E{episode:02d}'.format(**parameters)

    for key, value in parameters.items():
        if isinstance(value, basestring):
            parameters[key + "_+"] = value.replace(" ", "+")
            # Hack for really bad addons
            parameters[key + "_escaped"] = value.replace(" ", "%2520")

    return parameters
开发者ID:itzikg,项目名称:meta4kodi,代码行数:50,代码来源:tvshows.py

示例14: movies_add_to_library_parsed

def movies_add_to_library_parsed(src, id, player):
    library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode))
    date = None
    if src == "tmdb":
        import_tmdb()
        movie = tmdb.Movies(id).info()
        date = date_to_timestamp(movie.get('release_date'))
        imdb_id = movie.get('imdb_id')
        if imdb_id:
            if imdb_id != None and imdb_id != "":
                src = "imdb"
                id = imdb_id
    add_movie_to_library(library_folder, src, id, player)
    scan_library(type="video")
开发者ID:vphuc81,项目名称:MyRepository,代码行数:14,代码来源:movies.py

示例15: guide_movies_play_by_name

def guide_movies_play_by_name(name, lang = "en"):
    import_tmdb()
    from meta.utils.text import parse_year
    items = tmdb.Search().movie(query=name, language=lang, page=1)["results"]
    if not items: return dialogs.ok(_("Movie not found"), "{0} {1}".format(_("No movie information found on TMDB for"), name))
    if len(items) > 1:
        selection = dialogs.select(_("Choose Movie"), ["{0} ({1})".format(
            to_utf8(s["title"]),
            parse_year(s["release_date"])) for s in items])
    else: selection = 0
    if selection != -1:
        id = items[selection]["id"]
        guide_movies_play("tmdb", id, "default")
        if plugin.get_setting(SETTING_MOVIES_PLAYED_BY_ADD, converter=bool) == True: movies_add_to_library("tmdb", id)
开发者ID:noobsandnerds,项目名称:noobsandnerds,代码行数:14,代码来源:movies.py


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