コード例 #1
0
ファイル: tvshows.py プロジェクト: itzikg/meta4kodi
def make_tvshow_item(tvdb_show, tmdb_show=None):
    tvdb_info = get_tvshow_metadata_tvdb(tvdb_show)
    tmdb_info = get_tvshow_metadata_tmdb(tmdb_show)
    
    info = {}
    info.update(tvdb_info)
    info.update(dict((k,v) for k,v in tmdb_info.iteritems() if v))
    
    # Prefer translated info
    if LANG != "en":
        for key in ('name', 'title', 'plot'):
            if is_ascii(info.get(key,'')) and not is_ascii(tvdb_info.get(key,'')):
                info[key] = tvdb_info[key]
                        
    tvdb_id = info['tvdb_id']
    
    context_menu = [
     (   
      _("Add to library"),
      "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id))
     ),
     (
      _("Show info"), 'Action(Info)'
     )
    ]
             
    return {'label': info['title'],
            'path': plugin.url_for(tv_tvshow, id=tvdb_id),
            'context_menu': context_menu,
            'thumbnail': info['poster'],
            'icon': "DefaultVideo.png",
            'poster': info['poster'],
            'properties' : {'fanart_image' : info['fanart']},
            'info_type': 'video',
            'info': info}
コード例 #2
0
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
コード例 #3
0
ファイル: tvshows.py プロジェクト: itzikg/meta4kodi
def list_seasons_tvdb(id):
    import_tvdb()
    id = int(id)
    
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)
    
    context_menu = [ ( _("Show info"), 'Action(Info)' ) ]
    
    items = []
    for (season_num, season) in show.items():
        if season_num == 0 or not season.has_aired():
            continue
        
        season_info = get_season_metadata_tvdb(show_info, season)
        
        items.append({'label': u"%s %d" % (_("Season"), season_num),
                      'path': plugin.url_for(tv_season, id=id, season_num=season_num),
                      'context_menu': context_menu,
                      'info': season_info,
                      'thumbnail': season_info['poster'],
                      'icon': "DefaultVideo.png",
                      'poster': season_info['poster'],
                      'properties' : {'fanart_image' : season_info['fanart']},
                      })
    return items
コード例 #4
0
def list_episodes_tvdb(id, season_num):
    import_tvdb()
    id = int(id)
    season_num = int(season_num)
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)
    title = show_info['name']
    season = show[season_num]
    season_info = get_season_metadata_tvdb(show_info, season, banners=True)
    items = []
    for (episode_num, episode) in season.items():
        if episode_num == 0 or not episode.has_aired(flexible=True):
            break
        episode_info = get_episode_metadata_tvdb(season_info, episode)
        if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): context_menu = [(_("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay"), "RunScript(script.qlickplay,info=episodeinfo,tvshow={0},season={1},episode={2})".format(title, season_num, episode_num)), (_("TV trailer"),"RunScript(script.qlickplay,info=playtvtrailer,tvdb_id={0})".format(id)), (_("Recommended tv shows (TMDb)"),"ActivateWindow(10025,plugin://script.qlickplay/?info=similartvshows&tvdb_id={0})".format(id))]
        elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): context_menu = [(_("Extended episode info"), "RunScript(script.extendedinfo,info=episodeinfo,tvshow={0},season={1},episode={2})".format(title, season_num, episode_num)), (_("TV trailer"),"RunScript(script.extendedinfo,info=playtvtrailer,tvdb_id={0})".format(id)), (_("Recommended tv shows (TMDb)"),"ActivateWindow(10025,plugin://script.extendedinfo/?info=similartvshows&tvdb_id={0})".format(id))]
        else: context_menu = []
        context_menu.append((_("Select stream..."),"PlayMedia({0})".format(plugin.url_for("tv_play", id=id, season=season_num, episode=episode_num, mode='select'))))
        context_menu.append((_("Add to list"), "RunPlugin({0})".format(plugin.url_for("lists_add_episode_to_list", src='tvdb', id=id, season=season_num, episode = episode_num))))
        context_menu.append((_("Show info"),'Action(Info)'))
        items.append({'label': episode_info.get('title'),
                      'path': plugin.url_for("tv_play", id=id, season=season_num, episode=episode_num, mode='default'),
                      'context_menu': context_menu,
                      'info': episode_info,
                      'is_playable': True,
                      'info_type': 'video',
                      'stream_info': {'video': {}},
                      'thumbnail': episode_info['poster'],
                      'poster': season_info['poster'],
                      'icon': "DefaultVideo.png",
                      'properties' : {'fanart_image' : episode_info['fanart']},
                      })
    return items
コード例 #5
0
def list_episodes_tvdb(id, season_num):
    import_tvdb()
    id = int(id)
    season_num = int(season_num)

    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)

    season = show[season_num]
    season_info = get_season_metadata_tvdb(show_info, season, banners=True)

    items = []
    for (episode_num, episode) in season.items():
        if episode_num == 0 or not episode.has_aired(flexible=True):
            break

        episode_info = get_episode_metadata_tvdb(season_info, episode)

        context_menu = [(_("Select stream..."), "PlayMedia({0})".format(
            plugin.url_for("tv_play",
                           id=id,
                           season=season_num,
                           episode=episode_num,
                           mode='select'))), (_("Show info"), 'Action(Info)')]

        items.append({
            'label':
            episode_info.get('title'),
            'path':
            plugin.url_for("tv_play",
                           id=id,
                           season=season_num,
                           episode=episode_num,
                           mode='default'),
            'context_menu':
            context_menu,
            'info':
            episode_info,
            'is_playable':
            True,
            'info_type':
            'video',
            'stream_info': {
                'video': {}
            },
            'thumbnail':
            episode_info['poster'],
            'poster':
            season_info['poster'],
            'icon':
            "DefaultVideo.png",
            'properties': {
                'fanart_image': episode_info['fanart']
            },
        })

    return items
コード例 #6
0
def build_tvshow_info(tvdb_show, tmdb_show=None):
    tvdb_info = get_tvshow_metadata_tvdb(tvdb_show)
    tmdb_info = get_tvshow_metadata_tmdb(tmdb_show)
    info = {}
    info.update(tvdb_info)
    info.update(dict((k,v) for k,v in tmdb_info.iteritems() if v))
    # Prefer translated info
    if LANG != "en":
        for key in ('name', 'title', 'plot'):
            if is_ascii(info.get(key,'')) and not is_ascii(tvdb_info.get(key,'')):
                info[key] = tvdb_info[key]
    return info
コード例 #7
0
ファイル: tvshows.py プロジェクト: podgod/podgod
def build_tvshow_info(tvdb_show, tmdb_show=None):
    tvdb_info = get_tvshow_metadata_tvdb(tvdb_show)
    tmdb_info = get_tvshow_metadata_tmdb(tmdb_show)
    
    info = {}
    info.update(tvdb_info)
    info.update(dict((k,v) for k,v in tmdb_info.iteritems() if v))
    
    # Prefer translated info
    if LANG != "en":
        for key in ('name', 'title', 'plot'):
            if is_ascii(info.get(key,'')) and not is_ascii(tvdb_info.get(key,'')):
                info[key] = tvdb_info[key]
    return info
コード例 #8
0
ファイル: tvshows.py プロジェクト: OpenELEQ/meta4kodi
def list_episodes_tvdb(id, season_num):
    import_tvdb()
    id = int(id)
    season_num = int(season_num)

    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)

    season = show[season_num]
    season_info = get_season_metadata_tvdb(show_info, season, banners=True)
    
    items = []
    for (episode_num, episode) in season.items():
        if episode_num == 0 or not episode.has_aired(flexible=True):
            break
        
        episode_info = get_episode_metadata_tvdb(season_info, episode)
                        
        context_menu = [
         (
          _("Select stream..."),
          "PlayMedia({0})".format(plugin.url_for("tv_play", id=id, season=season_num, episode=episode_num, mode='select'))
         ),
         (
          _("Show info"),
          'Action(Info)'
         ),
         (
          _("Add to list"),
          "RunPlugin({0})".format(plugin.url_for("lists_add_episode_to_list", src='tvdb', id=id,
                                                 season=season_num, episode = episode_num))
         ),
        ]
        
        items.append({'label': episode_info.get('title'),
                      'path': plugin.url_for("tv_play", id=id, season=season_num, episode=episode_num, mode='default'),
                      'context_menu': context_menu,
                      'info': episode_info,
                      'is_playable': True,
                      'info_type': 'video',
                      'stream_info': {'video': {}},
                      'thumbnail': episode_info['poster'],
                      'poster': season_info['poster'],
                      'icon': "DefaultVideo.png",
                      'properties' : {'fanart_image' : episode_info['fanart']},
                      })

    return items
コード例 #9
0
def list_seasons_tvdb(id):
    import_tvdb()
    id = int(id)

    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)

    items = []
    for (season_num, season) in show.items():
        if season_num == 0 or not season.has_aired(flexible=True):
            continue

        season_info = get_season_metadata_tvdb(show_info, season)

        context_menu = [(_("Show info"), 'Action(Info)'),
                        (_("Add to list"), "RunPlugin({0})".format(
                            plugin.url_for("lists_add_season_to_list",
                                           src='tvdb',
                                           id=id,
                                           season=season_num)))]

        items.append({
            'label':
            u"%s %d" % (_("Season"), season_num),
            'path':
            plugin.url_for(tv_season, id=id, season_num=season_num),
            'context_menu':
            context_menu,
            'info':
            season_info,
            'thumbnail':
            season_info['poster'],
            'icon':
            "DefaultVideo.png",
            'poster':
            season_info['poster'],
            'properties': {
                'fanart_image': season_info['fanart']
            },
        })
    return items
コード例 #10
0
def list_seasons_tvdb(id):
    import_tvdb()
    id = int(id)
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)
    title = show_info['name']
    items = []
    for (season_num, season) in show.items():
        if season_num == 0 or not season.has_aired(flexible=True):
            continue
        season_info = get_season_metadata_tvdb(show_info, season)
        if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): context_menu = [(_("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay"), "RunScript(script.qlickplay,info=seasoninfo,tvshow={0},season={1})".format(title, season_num)), (_("TV trailer"),"RunScript(script.qlickplay,info=playtvtrailer,tvdb_id={0})".format(id)), (_("Recommended tv shows (TMDb)"),"ActivateWindow(10025,plugin://script.qlickplay/?info=similartvshows&tvdb_id={0})".format(id))]
        elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): context_menu = [(_("Extended season info"), "RunScript(script.extendedinfo,info=seasoninfo,tvshow={0},season={1})".format(title, season_num)), (_("TV trailer"),"RunScript(script.extendedinfo,info=playtvtrailer,tvdb_id={0})".format(id)), (_("Recommended tv shows (TMDb)"),"ActivateWindow(10025,plugin://script.extendedinfo/?info=similartvshows&tvdb_id={0})".format(id))]
        else: context_menu = []
        items.append({'label': u"%s %d" % (_("Season"), season_num),
                      'path': plugin.url_for(tv_season, id=id, season_num=season_num),
                      'context_menu': context_menu,
                      'info': season_info,
                      'thumbnail': season_info['poster'],
                      'icon': "DefaultVideo.png",
                      'poster': season_info['poster'],
                      'properties' : {'fanart_image' : season_info['fanart']},
                      })
    return items
コード例 #11
0
ファイル: tvshows.py プロジェクト: krzysztofuu/Bonitillonew
def play_episode(id, season, episode, mode):
    import_tvdb()
    id = int(id)
    season = int(season)
    episode = int(episode)
    # Get database id
    dbid = xbmc.getInfoLabel("ListItem.DBID")
    try:
        dbid = int(dbid)
    except:
        dbid = None
    # Get show data from TVDB
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'context':
        play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_tv_player_plugin_from_library(id)
        if not play_plugin or play_plugin == "default":
            play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode)
    else:
        play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("tvshows", filters = {'network': show.get('network')})
    else: players = get_players("tvshows", filters = {'network': show.get('network')})
    players = [p for p in players if p.id == play_plugin] or players
    if not players: return xbmc.executebuiltin( "Action(Info)")
    # Get show ids from Trakt
    trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'], "show", show.get('year', 0))
    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        if lang == LANG:
            tvdb_data = show
        else:
            tvdb_data = create_tvdb(lang)[id]
        if tvdb_data['seriesname'] is None:
            continue
        episode_parameters = get_episode_parameters(tvdb_data, season, episode)
        if episode_parameters is not None:
            params[lang] = episode_parameters
        else:
            if trakt_ids["tmdb"] != None and trakt_ids["tmdb"] != "":
                return tmdb_play_episode(trakt_ids["tmdb"], season, episode, mode)
            elif trakt_ids["tvdb"] == None or trakt_ids["tvdb"] == "":
                msg = "{0} {1} - S{2}E{3}".format(_("No TVDb information found for"), show_info['name'], season, episode)
                return dialogs.ok(_("%s not found") % _("Episode information"), msg)
            else:
                msg = "{0} {1} - S{2}E{3}".format(_("No TVDb or TMDb information found for"), show_info['name'], season, episode)
                return dialogs.ok(_("%s not found") % _("Episode information"), msg)
        if trakt_ids != None: params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])
    # Go for it
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        # set properties
        set_property("data", json.dumps({'dbid': dbid, 'tvdb': id, 
            'season': season, 'episode': episode}))
        # Play
        season_info = get_season_metadata_tvdb(show_info, show[season], banners=False)
        episode_info = get_episode_metadata_tvdb(season_info, show[season][episode])
        action_play({
            'label': episode_info['title'],
            'path': link,
            'info': episode_info,
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': episode_info['poster'],
            'poster': episode_info['poster'],
            'properties' : {'fanart_image' : episode_info['fanart']},
        })
コード例 #12
0
ファイル: tvshows.py プロジェクト: vphuc81/MyRepository
def get_episode_parameters(show, season, episode):
    articles = ['a ', 'A ', 'An ', 'an ', 'The ', 'the ']
    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['sortname'] = to_utf8(parameters['clearname'])
    for article in articles:
        if to_utf8(parameters['clearname']).startswith(article): parameters['sortname'] = to_utf8(parameters['clearname']).replace(article,'')
    parameters['urlname'] = urllib.quote(to_utf8(parameters['clearname']))
    articles = ['a ', 'A ', 'An ', 'an ', 'The ', 'the ']
    parameters['sortname'] = to_utf8(parameters['clearname'])
    for article in articles:
        if to_utf8(parameters['clearname']).startswith(article): parameters['sortname'] = to_utf8(parameters['clearname']).replace(article,'')
    parameters['shortname'] = to_utf8(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['sorttitle'] = to_utf8(parameters['title'])
    for article in articles:
        if to_utf8(parameters['title']).startswith(article): parameters['sorttitle'] = to_utf8(parameters['title']).replace(article,'')
    parameters['shorttitle'] = to_utf8(parameters['title'][1:-1])
    parameters['firstaired'] = episode_obj.get('firstaired')
    parameters['year'] = show.get('year', 0)
    trakt_ids = get_trakt_ids("tvdb", show['id'], parameters['clearname'], "show", parameters['year'])
#    if trakt_ids["slug"]:
#        if trakt_ids["slug"] != None and trakt_ids["slug"] != "": parameters['slug'] = trakt_ids["slug"]
#        else: parameters['slug'] = parameters['clearname'].lower().replace(" ","-")
    if parameters['firstaired']:
        parameters['epyear'] = int(parameters['firstaired'].split("-")[0].strip())
        parameters['epmonth'] = int(parameters['firstaired'].split("-")[1].strip())
        parameters['epday'] = int(parameters['firstaired'].split("-")[2].strip())
    else:
        parameters["epyear"] = 1980
        parameters["epmonth"] = 0
        parameters["epday"] = 0
    parameters['imdb'] = show.get('imdb_id', '')
    parameters['epid'] = episode_obj.get('id')
    if episode_obj.get('id') != "": parameters['plot'] = episode_obj.get('overview')
    else: parameters['plot'] = show['overview']
    if episode_obj.get('Rating') != "": parameters['rating'] = episode_obj.get('Rating')
    else: parameters['rating'] = show['Rating']
    if episode_obj.get('RatingCount') != "": parameters['votes'] = episode_obj.get('RatingCount')
    else: parameters['votes'] = show['RatingCount']
    parameters['writer'] = episode_obj.get('Writer')
    parameters['director'] = episode_obj.get('Director')
    parameters['status'] = show.get('Status')
    parameters['mpaa'] = show.get('ContentRating')
    parameters['actors'] = show.get('Actors')
    if show.get('Genre') != None and '|' in show.get('Genre'): parameters['genres'] = show.get('Genre').replace('|',' / ')[3:-3]
    else: parameters['genres'] = show.get('Genre')
    parameters['runtime'] = show['runtime']
    parameters['duration'] = int(show['runtime']) * 60
    tvdb_base = "http://thetvdb.com/banners/"
    if episode_obj.get('filename') != "": parameters['thumbnail'] = tvdb_base + str(episode_obj.get('filename'))
    elif show.get('poster') != "": parameters['thumbnail'] = tvdb_base + show.get('poster')
    else: parameters['thumbnail'] = get_icon("metalliq")
    if show.get('poster') != "": parameters['poster'] = tvdb_base + show.get('poster')
    else: parameters['poster'] = get_icon("metalliq")
    parameters['thumbnail'] = "http://thetvdb.com/banners/episodes/" + str(show['id']) + "/" + str(parameters['epid']) + ".jpg"
    if show.get('banner') != "": parameters['banner'] = tvdb_base + show.get('banner')
    else: parameters['banner'] = get_banner_path()
    if show.get('fanart') != None and show.get('fanart') != "": parameters['fanart'] = tvdb_base + show.get('fanart')
    else: parameters['fanart'] = get_background_path()
    is_anime = False
    if parameters['genres'] != None and parameters['absolute_number'] and parameters['absolute_number'] != '0' and "animation" in parameters['genres'].lower():
        tmdb_results = tmdb.Find(show['id']).info(external_source="tvdb_id")
        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)
    parameters['now'] = datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')
    return parameters
コード例 #13
0
ファイル: tvshows.py プロジェクト: itzikg/meta4kodi
def play_episode(id, season, episode, mode):  
    import_tvdb()
    
    id = int(id)
    season = int(season)
    episode = int(episode)
    
    # Get database id
    dbid = xbmc.getInfoLabel("ListItem.DBID")
    try:
        dbid = int(dbid)
    except:
        dbid = None
        
    # Get show data from TVDB
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)

    # Get active players
    players = active_players("tvshows", filters = {'network': show.get('network')})
    if not players:
        xbmc.executebuiltin( "Action(Info)")
        action_cancel()
        return

    # Get player to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'library':
        play_plugin = get_player_plugin_from_library(id)
        if not play_plugin:
            play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY)
    else:
        play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER)
        
    # Use just selected player if exists (selectors excluded)
    players = [p for p in players if p.id == play_plugin] or players

    # Get show ids from Trakt
    trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'],
                    "show", show.get('year', 0))

    # Preload params
    params = {}
    for lang in get_needed_langs(players):
        if lang == LANG:
            tvdb_data = show
        else:
            tvdb_data = create_tvdb(lang)[id]
        if tvdb_data['seriesname'] is None:
            continue
        params[lang] = get_episode_parameters(tvdb_data, season, episode)
        params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])

    # BETA
    action_cancel()

    # Get single video selection
    use_simple_selector = plugin.get_setting(SETTING_USE_SIMPLE_SELECTOR, converter=bool)
    selection = get_video_link(players, params, mode, use_simple_selector)
    if not selection:
        #action_cancel()
        return
        
    # Get selection details
    link = selection['path']
    action = selection.get('action', '')
    
    plugin.log.info('Playing url: %s' % link.encode('utf-8'))

    # Activate link
    if action == "ACTIVATE":
        action_activate(link)
    else:
        # Build list item (needed just for playback from widgets)
        season_info = get_season_metadata_tvdb(show_info, show[season], banners=False)
        episode_info = get_episode_metadata_tvdb(season_info, show[season][episode])
        listitem = {
            'label': episode_info['title'],
            'path': link,
            'info': episode_info,
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': episode_info['poster'],
            'poster': episode_info['poster'],
            'properties' : {'fanart_image' : episode_info['fanart']},
        }
    
        # set properties
        if trakt_ids:
            set_property('script.trakt.ids', json.dumps(trakt_ids))
        set_property("data", json.dumps({'dbid': dbid, 'tvdb': id, 
            'season': season, 'episode': episode}))
        
        # Play
        if action == "PLAY":
            action_play(listitem)
        else:
            action_resolve(listitem)
コード例 #14
0
def play_episode_from_guide(id, season, episode, mode):  
    import_tvdb()
    id = int(id)
    season = int(season)
    episode = int(episode)
    dbid = xbmc.getInfoLabel("ListItem.DBID")
    try:
        dbid = int(dbid)
    except:
        dbid = None
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)
    if mode == 'select':
        play_plugin = ADDON_PICKER.id
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_CHANNELER)
    else:
        play_plugin = mode
    channelers = active_channelers("tvshows", filters = {'network': show.get('network')})
    channelers = [p for p in channelers if p.id == play_plugin] or channelers
    if not channelers:
        xbmc.executebuiltin( "Action(Info)")
        action_cancel()
        return
    trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'],
                    "show", show.get('year', 0))
    params = {}
    for lang in get_needed_langs(channelers):
        if lang == LANG:
            tvdb_data = show
        else:
            tvdb_data = create_tvdb(lang)[id]
        if tvdb_data['seriesname'] is None:
            continue
        episode_parameters = get_episode_parameters(tvdb_data, season, episode)
        if episode_parameters is not None:
            params[lang] = episode_parameters
        else:
            msg = "{0} {1} - S{1}E{2}".format(_("No tvdb information found for"), show['seriesname'], season, episode)
            dialogs.ok(_("Episode info not found"), msg)
            return
        if trakt_ids != None:
            params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])
    link = on_play_video(mode, channelers, params, trakt_ids)
    if link:
        set_property("data", json.dumps({'dbid': dbid, 'tvdb': id, 
            'season': season, 'episode': episode}))
        season_info = get_season_metadata_tvdb(show_info, show[season], banners=False)
        episode_info = get_episode_metadata_tvdb(season_info, show[season][episode])
        action_play({
            'label': episode_info['title'],
            'path': link,
            'info': episode_info,
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': episode_info['poster'],
            'poster': episode_info['poster'],
            'properties' : {'fanart_image' : episode_info['fanart']},
        })
コード例 #15
0
ファイル: tvshows.py プロジェクト: Quihico/meta4kodi
def play_episode(id, season, episode, mode):  
    import_tvdb()
    
    id = int(id)
    season = int(season)
    episode = int(episode)
    
    # Get database id
    dbid = xbmc.getInfoLabel("ListItem.DBID")
    try:
        dbid = int(dbid)
    except:
        dbid = None
        
    # Get show data from TVDB
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)

    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'library':
        play_plugin = get_player_plugin_from_library(id)
        if not play_plugin or play_plugin == "default":
            play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY)
    else:
        play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER)
    players = active_players("tvshows", filters = {'network': show.get('network')})
    players = [p for p in players if p.id == play_plugin] or players
    if not players:
        xbmc.executebuiltin( "Action(Info)")
        action_cancel()
        return
    
    # Get show ids from Trakt
    trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'],
                    "show", show.get('year', 0))

    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        if lang == LANG:
            tvdb_data = show
        else:
            tvdb_data = create_tvdb(lang)[id]
        if tvdb_data['seriesname'] is None:
            continue
        episode_parameters = get_episode_parameters(tvdb_data, season, episode)
        if episode_parameters is not None:
            params[lang] = episode_parameters
        else:
            msg = "{0} {1} - S{1}E{2}".format(_("No tvdb information found for"), show['seriesname'], season, episode)
            dialogs.ok(_("Episode info not found"), msg)
            return
        
        params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])

    # Go for it
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        # set properties
        set_property("data", json.dumps({'dbid': dbid, 'tvdb': id, 
            'season': season, 'episode': episode}))
    
        # Play
        season_info = get_season_metadata_tvdb(show_info, show[season], banners=False)
        episode_info = get_episode_metadata_tvdb(season_info, show[season][episode])
        action_play({
            'label': episode_info['title'],
            'path': link,
            'info': episode_info,
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': episode_info['poster'],
            'poster': episode_info['poster'],
            'properties' : {'fanart_image' : episode_info['fanart']},
        })
コード例 #16
0
def play_episode(id, season, episode, mode):
    import_tvdb()

    id = int(id)
    season = int(season)
    episode = int(episode)

    # Get database id
    dbid = xbmc.getInfoLabel("ListItem.DBID")
    try:
        dbid = int(dbid)
    except:
        dbid = None

    # Get show data from TVDB
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)

    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'library':
        play_plugin = get_player_plugin_from_library(id)
        if not play_plugin:
            play_plugin = plugin.get_setting(
                SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY)
    else:
        play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER)
    players = active_players("tvshows",
                             filters={'network': show.get('network')})
    players = [p for p in players if p.id == play_plugin] or players
    if not players:
        xbmc.executebuiltin("Action(Info)")
        action_cancel()
        return

    # Get show ids from Trakt
    trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'], "show",
                              show.get('year', 0))

    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        if lang == LANG:
            tvdb_data = show
        else:
            tvdb_data = create_tvdb(lang)[id]
        if tvdb_data['seriesname'] is None:
            continue
        params[lang] = get_episode_parameters(tvdb_data, season, episode)
        params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])

    # Go for it
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        # set properties
        set_property(
            "data",
            json.dumps({
                'dbid': dbid,
                'tvdb': id,
                'season': season,
                'episode': episode
            }))

        # Play
        season_info = get_season_metadata_tvdb(show_info,
                                               show[season],
                                               banners=False)
        episode_info = get_episode_metadata_tvdb(season_info,
                                                 show[season][episode])
        action_play({
            'label': episode_info['title'],
            'path': link,
            'info': episode_info,
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': episode_info['poster'],
            'poster': episode_info['poster'],
            'properties': {
                'fanart_image': episode_info['fanart']
            },
        })
コード例 #17
0
ファイル: tvshows.py プロジェクト: krzysztofuu/Bonitillonew
def get_episode_parameters(show, season, episode):
    articles = ['a ', 'A ', 'An ', 'an ', 'The ', 'the ']
    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['sortname'] = to_utf8(parameters['clearname'])
    for article in articles:
        if to_utf8(parameters['clearname']).startswith(article): parameters['sortname'] = to_utf8(parameters['clearname']).replace(article,'')
    parameters['urlname'] = urllib.quote(to_utf8(parameters['clearname']))
    articles = ['a ', 'A ', 'An ', 'an ', 'The ', 'the ']
    parameters['sortname'] = to_utf8(parameters['clearname'])
    for article in articles:
        if to_utf8(parameters['clearname']).startswith(article): parameters['sortname'] = to_utf8(parameters['clearname']).replace(article,'')
    parameters['shortname'] = to_utf8(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['sorttitle'] = to_utf8(parameters['title'])
    for article in articles:
        if to_utf8(parameters['title']).startswith(article): parameters['sorttitle'] = to_utf8(parameters['title']).replace(article,'')
    parameters['shorttitle'] = to_utf8(parameters['title'][1:-1])
    parameters['firstaired'] = episode_obj.get('firstaired')
    parameters['year'] = show.get('year', 0)
    trakt_ids = get_trakt_ids("tvdb", show['id'], parameters['clearname'], "show", parameters['year'])
#    if trakt_ids["slug"]:
#        if trakt_ids["slug"] != None and trakt_ids["slug"] != "": parameters['slug'] = trakt_ids["slug"]
#        else: parameters['slug'] = parameters['clearname'].lower().replace(" ","-")
    if parameters['firstaired']:
        parameters['epyear'] = int(parameters['firstaired'].split("-")[0].strip())
        parameters['epmonth'] = int(parameters['firstaired'].split("-")[1].strip())
        parameters['epday'] = int(parameters['firstaired'].split("-")[2].strip())
    else:
        parameters["epyear"] = 1980
        parameters["epmonth"] = 0
        parameters["epday"] = 0
    parameters['imdb'] = show.get('imdb_id', '')
    parameters['epid'] = episode_obj.get('id')
    if episode_obj.get('id') != "": parameters['plot'] = episode_obj.get('overview')
    else: parameters['plot'] = show['overview']
    if episode_obj.get('Rating') != "": parameters['rating'] = episode_obj.get('Rating')
    else: parameters['rating'] = show['Rating']
    if episode_obj.get('RatingCount') != "": parameters['votes'] = episode_obj.get('RatingCount')
    else: parameters['votes'] = show['RatingCount']
    parameters['writer'] = episode_obj.get('Writer')
    parameters['director'] = episode_obj.get('Director')
    parameters['status'] = show.get('Status')
    parameters['mpaa'] = show.get('ContentRating')
    parameters['actors'] = show.get('Actors')
    if show.get('Genre') != None and '|' in show.get('Genre'): parameters['genres'] = show.get('Genre').replace('|',' / ')[3:-3]
    else: parameters['genres'] = show.get('Genre')
    parameters['runtime'] = show['runtime']
    parameters['duration'] = int(show['runtime']) * 60
    tvdb_base = "http://thetvdb.com/banners/"
    if episode_obj.get('filename') != "": parameters['thumbnail'] = tvdb_base + str(episode_obj.get('filename'))
    elif show.get('poster') != "": parameters['thumbnail'] = tvdb_base + show.get('poster')
    else: parameters['thumbnail'] = get_icon("metalliq")
    if show.get('poster') != "": parameters['poster'] = tvdb_base + show.get('poster')
    else: parameters['poster'] = get_icon("metalliq")
    parameters['thumbnail'] = "http://thetvdb.com/banners/episodes/" + str(show['id']) + "/" + str(parameters['epid']) + ".jpg"
    if show.get('banner') != "": parameters['banner'] = tvdb_base + show.get('banner')
    else: parameters['banner'] = get_banner_path()
    if show.get('fanart') != None and show.get('fanart') != "": parameters['fanart'] = tvdb_base + show.get('fanart')
    else: parameters['fanart'] = get_background_path()
    is_anime = False
    if parameters['genres'] != None and parameters['absolute_number'] and parameters['absolute_number'] != '0' and "animation" in parameters['genres'].lower():
        tmdb_results = tmdb.Find(show['id']).info(external_source="tvdb_id")
        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)
    parameters['now'] = datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')
    return parameters
コード例 #18
0
ファイル: tvshows.py プロジェクト: krzysztofuu/Bonitillonew
def play_episode_from_guide(id, season, episode, mode):  
    import_tvdb()
    id = int(id)
    season = int(season)
    episode = int(episode)
    dbid = xbmc.getInfoLabel("ListItem.DBID")
    try:
        dbid = int(dbid)
    except:
        dbid = None
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)
    if mode == 'select':
        play_plugin = ADDON_PICKER.id
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_CHANNELER, unicode)
    else:
        play_plugin = mode
    channelers = active_channelers("tvshows", filters = {'network': show.get('network')})
    channelers = [p for p in channelers if p.id == play_plugin] or channelers
    if not channelers:
        xbmc.executebuiltin( "Action(Info)")
        action_cancel()
        return
    trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'],
                    "show", show.get('year', 0))
    params = {}
    for lang in get_needed_langs(channelers):
        if lang == LANG:
            tvdb_data = show
        else:
            tvdb_data = create_tvdb(lang)[id]
        if tvdb_data['seriesname'] is None:
            continue
        episode_parameters = get_episode_parameters(tvdb_data, season, episode)
        if episode_parameters is not None:
            params[lang] = episode_parameters
        else:
            msg = "{0} {1} - S{1}E{2}".format(_("No tvdb information found for"), show['seriesname'], season, episode)
            dialogs.ok(_("%s not found") % _("Episode information"), msg)
            return
        if trakt_ids != None:
            params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])
    link = on_play_video(mode, channelers, params, trakt_ids)
    if link:
        set_property("data", json.dumps({'dbid': dbid, 'tvdb': id, 
            'season': season, 'episode': episode}))
        season_info = get_season_metadata_tvdb(show_info, show[season], banners=False)
        episode_info = get_episode_metadata_tvdb(season_info, show[season][episode])
        action_play({
            'label': episode_info['title'],
            'path': link,
            'info': episode_info,
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': episode_info['poster'],
            'poster': episode_info['poster'],
            'properties' : {'fanart_image' : episode_info['fanart']},
        })
コード例 #19
0
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