コード例 #1
0
def play(params):
    name = params.name
    youtube_id = params.get('youtube_id')

    if youtube_id and requests.head(
            "http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v={0}&format=json"
            .format(youtube_id)).status_code == 200:
        video_url = "plugin://plugin.video.youtube/play/?video_id={0}".format(
            youtube_id)
    else:
        results = []
        for media in youtube_search(urllib.quote_plus(name)):
            label = media["label"]
            label2 = media["plot"]
            image = ""
            if media.get('art'):
                if media['art'].get('thumb'):
                    image = (media['art']['thumb'])
            listitem = xbmcgui.ListItem(label=label,
                                        label2=label2,
                                        iconImage=image)
            listitem.setProperty("path", media["file"])
            results.append(listitem)
        xbmc.executebuiltin("dialog.Close(busydialog)")
        title = "{0} \"{1}\"".format(_("Select mirror for"), name)
        dialog = DialogSelect("DialogSelect.xml",
                              "",
                              listing=results,
                              title=title)
        dialog.doModal()
        result = dialog.result
        if not result:
            return
        video_url = result.getProperty("path")
    return Plugin.resolve_url(play_item={'path': video_url})
コード例 #2
0
def play(params):
    play_item = {'path': params.url}
    if SUBTITLE:
        subtitle_file = os.path.join(addon.config_dir, "subtitle.srt")
        subtitle_downloaded = download_subtitle(params.subtitle, subtitle_file)
        if subtitle_downloaded:
            play_item['subtitles'] = [subtitle_file]
    return Plugin.resolve_url(params.url, play_item=play_item)