Esempio n. 1
0
def play_video(eid, server):
    html = fetch_html('/vids/play/%s/%s' % (eid, server))
    urls = joonmedia.extract_video_link(html)
    if len(urls) > 0:
        # select first video
        plugin.log.debug(urls[0])
        quality = plugin.get_setting('qualityPref', int)
        info = getVideoInfo(urls[0], quality=quality, resolve_redirects=True)
        if info is None:
            plugin.log.warning('Fail to extract')
            return None
        streams = info.streams()
        plugin.log.debug("num of streams: %d" % len(streams))

        from xbmcswift2 import xbmc, xbmcgui
        pl = xbmc.PlayList( xbmc.PLAYLIST_VIDEO )
        pl.clear()
        for stream in streams:
            li = xbmcgui.ListItem(stream['title'], iconImage="DefaultVideo.png")
            li.setInfo( 'video', { "Title": stream['title'] } )
            pl.add(stream['xbmc_url'], li)
        xbmc.Player().play(pl)
    else:
        plugin.log.warning('Unsupported')
    return plugin.finish(None, succeeded=False) # immediate return
Esempio n. 2
0
    def _inside(self, num):
        if num == -1:
            self._inside_root(select=self.insideIndex)
            return

        with self.lock:
            source, links = self.items[num]

            if len(links) == 1:
                self.selection = links[0]
                self.close()
                return
            self.list.reset()
            for item in links:
                listitem = xbmcgui.ListItem(item['label'])
                listitem.setProperty("Path", item['path'])
                try:
                    if "plugin://" in links[0]['path']:
                        icon = xbmcaddon.Addon(id=links[0]['path'].split("/")
                                               [2]).getAddonInfo('icon')
                    else:
                        icon = xbmc.translatePath("{0}/folder.jpg".format(
                            links[0]['path'].rsplit("/", 2)[0]))
                    listitem.setIconImage(icon)
                    listitem.setThumbnailImage(icon)
                except:
                    pass
                self.list.addItem(listitem)
            self.insideIndex = num
Esempio n. 3
0
    def __init__(self,
                 label=None,
                 label2=None,
                 icon=None,
                 thumbnail=None,
                 path=None,
                 fanart=None,
                 offscreen=False):
        '''Defaults are an emtpy string since xbmcgui.ListItem will not
        accept None.
        '''
        kwargs = {
            'label': label,
            'label2': label2,
            'path': path,
            'offscreen': offscreen
        }
        #kwargs = dict((key, val) for key, val in locals().items() if val is
        #not None and key != 'self')
        kwargs = dict(
            (key, val) for key, val in kwargs.items() if val is not None)
        self._listitem = xbmcgui.ListItem(**kwargs)

        # kodi doesn't make getters available for these properties so we'll
        # keep track on our own
        self._path = path
        self._context_menu_items = []
        self.is_folder = True
        self._played = False
        self._art = {'icon': icon, 'thumb': thumbnail, 'fanart': fanart}

        # set listitem art
        self._listitem.setArt(self._art)
Esempio n. 4
0
def playmovie(url, label=''):
    """
    play movie
    """
    result = _http(baseurl + url)

    mp4str = re.search(r'<video id="player".*?<source src="(.*?)"', result,
                       re.S)
    if mp4str:
        playurl = mp4str.group(1)

        plugin.play_video({
            'label': label,
            'is_playable': True,
            'path': playurl
        })

    flashvar = re.search(r'var flashvars = \{(.*?)\};', result, re.S)
    if flashvar:
        rtmpstr = re.search(r'src : "(rtmp.*?)"', flashvar.group(1))
        title = re.search(r'label : "(.*?)"', flashvar.group(1))
        swfurl = re.search(r'var cmp_url = "(.*?)"', result)
        rtmpurl = re.search(r'(rtmp://.*?/.*?)/(.*)', rtmpstr.group(1))
        pageurl = baseurl + url
        playurl = rtmpurl.group(1) + ' playpath=mp4:' + rtmpurl.group(
            2) + ' pageUrl=' + pageurl + ' swfUrl=' + swfurl.group(1)

        listitem = xbmcgui.ListItem()
        listitem.setInfo(type="Video", infoLabels={'Title': title.group(1)})
        xbmc.Player().play(playurl, listitem)
Esempio n. 5
0
    def __init__(self,
                 label=None,
                 label2=None,
                 icon=None,
                 thumbnail=None,
                 path=None):
        """Defaults are an emtpy string since xbmcgui.ListItem will not
        accept None.
        """
        kwargs = {
            'label': label,
            'label2': label2,
            'iconImage': icon,
            'thumbnailImage': thumbnail,
            'path': path,
        }
        # kwargs = dict((key, val) for key, val in locals().items() if val is
        # not None and key != 'self')
        kwargs = dict(
            (key, val) for key, val in kwargs.items() if val is not None)
        self._listitem = xbmcgui.ListItem(**kwargs)

        # xbmc doesn't make getters available for these properties so we'll
        # keep track on our own
        self._icon = icon
        self._path = path
        self._thumbnail = thumbnail
        self._context_menu_items = []
        self.is_folder = True
        self._played = False
Esempio n. 6
0
    def _inside(self, num):
        if num == -1:
            self._inside_root(select=self.insideIndex)
            return

        with self.lock:
            source, links = self.items[num]

            if len(links) == 1:
                self.selection = links[0]
                self.close()
                return

            self.list.reset()
            for item in links:
                listitem = xbmcgui.ListItem(item['label'])
                listitem.setProperty("Path", item['path'])

                try:
                    pluginid = item['path'].split("/")[2]
                    icon = xbmcaddon.Addon(id=pluginid).getAddonInfo('icon')
                    listitem.setIconImage(icon)
                except:
                    pass

                self.list.addItem(listitem)

            self.insideIndex = num
Esempio n. 7
0
def play_transcode_video(userid, path, name, md5, select_type=False):
    player = myplayer.Player()
    listitem = xbmcgui.ListItem(name)
    listitem.setInfo(type="Video", infoLabels={'Title': name})

    api = get_api(userid)
    if select_type:
        choice = xbmcutils.select('请选转码格式', TRANSCODE_TYPES)
        if choice < 0:
            return
        transcode_type = TRANSCODE_TYPES[choice]
    else:
        transcode_type = plugin.get_setting('transcode_type', str)

    params = dict((k, v[0]) for k, v in plugin.request.args.items())
    subtitle = params.get('subtitle')
    if subtitle:
        subtitle = [subtitle]
    else:
        subtitle = []

    api_res = api.get_subtitle(md5, name or '', path)
    if api_res['total_num'] > 0:
        for sub_record in api_res['records']:
            subtitle.append(sub_record['file_path'])

    player.play(api.get_transcode_url(path, transcode_type),
                listitem,
                sublist=subtitle)
Esempio n. 8
0
def playvideo(vid, name, image):
    quality = int(plugin.addon.getSetting('movie_quality'))

    urls = video_from_vid(vid, level=quality)
    stackurl = 'stack://' + ' , '.join(urls)
    list_item = xbmcgui.ListItem(name, thumbnailImage=image)
    list_item.setInfo('video', {'title': name})
    xbmc.Player().play(stackurl, list_item)
Esempio n. 9
0
def jrplay_url(url):
    result = jrnaverm.parseVideoPage( url )
    nurl = result['path']+"|User-Agent="+jrnaverm.BrowserAgent
    from xbmcswift2 import xbmc, xbmcgui
    li = xbmcgui.ListItem(result['title'], iconImage="defaultVideo.png")
    li.setInfo('video', {"Title": result['title']})
    xbmc.Player().play(nurl, li)
    return plugin.finish(None, succeeded=False)
Esempio n. 10
0
def playvideo(url, name, image):
    level = int(plugin.addon.getSetting('resolution'))

    urls = video_from_url(url, level=level)
    stackurl = 'stack://' + ' , '.join(urls)
    list_item = xbmcgui.ListItem(name, thumbnailImage=image)
    list_item.setInfo('video', {'title': name})
    xbmc.Player().play(stackurl, list_item)
Esempio n. 11
0
def play_video(url):
    info = resolve_video_url(url)
    vid_url = "{0:s}|User-Agent={1:s}&Cookie={2:s}".format(
        info['url'], info['useragent'], info['cookie'])
    #return plugin.play_video({'label':info['title'], 'path':vid_url, 'is_playable':True})
    from xbmcswift2 import xbmcgui
    li = xbmcgui.ListItem(info['title'], iconImage="DefaultVideo.png")
    li.setInfo('video', {"Title": info['title']})
    xbmc.Player().play(vid_url, li)
    return plugin.finish(None, succeeded=False)
Esempio n. 12
0
def play(docu_link):
    media = api.get_docu(docu_link)
    plugin.log.info(repr(media))
    source, media_type = media.get('source'), media.get('type')
    playback_url = None
    if source == 'youtube.com':
        if requests.head("http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v={0}&format=json".format(
                media.get('id'))).status_code == 200:
            if media_type == 'video':
                playback_url = (
                    'plugin://plugin.video.youtube/'
                    '?action=play_video&videoid=%s' % media.get('id')
                )
            elif media_type == 'playlist':
                playback_url = (
                    'plugin://plugin.video.youtube/'
                    '?action=play_all&playlist=%s' % media.get('id')
                )
        else:
            results = []
            title = media.get('title')
            for media in _youtube_search(urllib.quote_plus(title.encode(encoding='utf-8'))):
                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)
            title = "{0} \"{1}\"".format(_("Select mirror for"), title.encode(encoding='utf-8'))
            dialog = DialogSelect("DialogSelect.xml", "", listing=results, title=title)
            time.sleep(0.1)
            xbmc.executebuiltin("dialog.Close(busydialog)")
            dialog.doModal()
            result = dialog.result
            if not result:
                return
            playback_url = result.getProperty("path")
    elif source == 'vimeo.com':
        if media_type == 'video':
            playback_url = (
                'plugin://plugin.video.vimeo/'
                '?action=play_video&videoid=%s' % media.get('id')
            )
    if playback_url:
        plugin.log.info('Using playback url: %s' % playback_url)
        return plugin.set_resolved_url(playback_url)
    else:
        plugin.log.error(repr(media))
        plugin.notify(msg=_('Not Implemented yet'))
Esempio n. 13
0
def _play_video_by_list(urls_info, show_comments='0'):
    _print_info('Play without subtitle')
    playlist = xbmc.PlayList(1)
    playlist.clear()
    i = 1
    _print_info(str(len(urls_info[0])) + ' parts found!')
    player = BiliPlayer()
    for url in urls_info[0]:
        list_item = xbmcgui.ListItem(u'播放')
        list_item.setInfo(type='video', infoLabels={"Title": "第"+str(i)+"/"+str(len(urls_info[0]))+" 节"})
        i += 1
        playlist.add(url, listitem=list_item)
    player.showSubtitles(False)
    player.show_subtitle = False
    player.play(playlist)
Esempio n. 14
0
def video_url(url):
    proxy = None
    if plugin.get_setting('useProxy', bool):
        proxy = plugin.get_setting('proxyServer', unicode)
        print "Proxy=" + proxy
    data = gomm.parseProg(url, proxy=proxy)
    if data is None:
        if not gomtv_login():
            return
        data = gomm.parseProg(url, proxy=proxy)
    if data is None:
        xbmcgui.Dialog().ok(_L(30010), _L(30013))
        return
    if len(data) == 1:
        video = data[0]
        url = video['url'] + "|Referer=" + url
        li = xbmcgui.ListItem(video['title'], iconImage="DefaultVideo.png")
        li.setInfo('video', {"Title": video['title']})
        xbmc.Player().play(url, li)
    elif plugin.get_setting('plistDir', bool):
        items = [{
            'label': item['title'],
            'path': item['url'] + "|Referer=" + url,
            'thumbnail': "DefaultVideo.png",
            'is_playable': True
        } for item in data]
        return plugin.finish(items)
    else:
        pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
        pl.clear()
        for item in data:
            li = xbmcgui.ListItem(item['title'], iconImage="DefaultVideo.png")
            li.setInfo('video', {"Title": item['title']})
            pl.add(item['url'] + "|Referer=" + url, li)
        xbmc.Player().play(pl)
    return plugin.finish(None, succeeded=False)
Esempio n. 15
0
def playvideo(tvId, vid, title, pic):
    sel = int(plugin.addon.getSetting('resolution'))
    m3u8set = plugin.addon.getSetting('m3u8')
    playmode = True if m3u8set == 'true' else None
    urls = video_from_vid(tvId, vid, level=sel, m3u8=playmode)
    if urls is None:
        xbmcgui.Dialog().ok(plugin.addon.getAddonInfo('name'), '无法播放此视频')
        return

    if len(urls) > 1:
        stackurl = 'stack://' + ' , '.join(urls)
        list_item = xbmcgui.ListItem(title, thumbnailImage=pic)
        list_item.setInfo('video', {'title': title})
        xbmc.Player().play(stackurl, list_item)
    else:
        plugin.set_resolved_url(urls[0])
Esempio n. 16
0
def play_stream(url, name=None):
    params = dict((k, v[0]) for k, v in plugin.request.args.items())
    subtitle = params.get('subtitle')
    if subtitle:
        subtitle += '|User-Agent=Mozilla/5.0%20%28Windows%20NT%206.1%3B%20rv%3A25.0%29%20Gecko/20100101%20Firefox/25.0&Referer=http%3A//pan.baidu.com/disk/home'  # noqa

    url += '|User-Agent=Mozilla/5.0%20%28Windows%20NT%206.1%3B%20rv%3A25.0%29%20Gecko/20100101%20Firefox/25.0&Referer=http%3A//pan.baidu.com/disk/home'  # noqa

    if name is None:
        plugin.set_resolved_url(url, subtitle)
    elif is_torrent(name):
        plugin.redirect(plugin.url_for('play_torrent', url=url))
    else:
        listitem = xbmcgui.ListItem(name)
        player = myplayer.Player()
        player.play(url, listitem, sublist=subtitle)
Esempio n. 17
0
def play_path(userid, path, md5, name=None):
    params = dict((k, v[0]) for k, v in plugin.request.args.items())
    subtitle = params.get('subtitle')
    if subtitle:
        subtitle = [
            get_dlink(userid, subtitle) +
            '|User-Agent=AppleCoreMedia/1.0.0.9B206 (iPad; U; CPU OS 5_1_1 like Mac OS X; zh_cn)'
        ]  # noqa
    else:
        subtitle = []

    # api = get_api(userid)
    # item = api.get_filemetas(path)['info'][0]
    # url = item['dlink'] + '|User-Agent=AppleCoreMedia/1.0.0.9B206 (iPad; U; CPU OS 5_1_1 like Mac OS X; zh_cn)'  # noqa
    url = get_dlink(
        userid, path
    ) + '|User-Agent=AppleCoreMedia/1.0.0.9B206 (iPad; U; CPU OS 5_1_1 like Mac OS X; zh_cn)'  # noqa

    api = get_api(userid)
    api_res = api.get_subtitle(md5, name or '', path)
    if api_res['total_num'] > 0:
        for sub_record in api_res['records']:
            subtitle.insert(0, sub_record['file_path'])

    params = dict((k, v[0]) for k, v in plugin.request.args.items())
    if 'resolved' in params:
        plugin.set_resolved_url(url)

        if subtitle:
            player = xbmc.Player()
            for _ in xrange(30):
                if player.isPlaying():
                    break
                time.sleep(1)
            else:
                raise Exception('No video playing. Aborted after 30 seconds.')

            for surl in subtitle:
                # print '$'*50, surl
                player.setSubtitles(surl)

            # player.setSubtitleStream(0)

    else:
        listitem = xbmcgui.ListItem(name)
        player = myplayer.Player()
        player.play(url, listitem, sublist=subtitle)
Esempio n. 18
0
def playmovie(url, source='youku'):
    """
    play movie
    """
    playutil = PlayUtil(url, source)
    movurl = getattr(playutil, source, playutil.notsup)()
    if not movurl:
        xbmcgui.Dialog().ok('提示框', '解析地址异常,无法播放')
        return
    if 'not support' in movurl:
        xbmcgui.Dialog().ok('提示框',
                            '不支持的播放源,目前支持youku/sohu/qq/iqiyi/pps/letv/tudou')
        return
    if 'cancel' in movurl: return
    listitem = xbmcgui.ListItem()
    listitem.setInfo(type="Video", infoLabels={'Title': 'c'})
    xbmc.Player().play(movurl, listitem)
Esempio n. 19
0
def _play_video(urls_info, show_comments='1'):
    playlist = xbmc.PlayList(1)
    playlist.clear()
    list_item = xbmcgui.ListItem(u'播放')
    list_item.setInfo(type='video', infoLabels={"Title": u"播放"})
    _print_info(str(len(urls_info[0])) + ' parts found')
    stack_url = 'stack://' + ' , '.join(urls_info[0])
    playlist.add(stack_url, list_item)
    player = BiliPlayer()
    if show_comments == '1':
        _print_info('Play with subtitle')
        player.setSubtitle(get_tmp_dir() + '/' + urls_info[1])
    else:
        _print_info('Play without subtitle')
        player.showSubtitles(False)
        player.show_subtitle = False
    player.play(playlist)
    #while(not xbmc.abortRequested):
    xbmc.sleep(100)
Esempio n. 20
0
    def _inside_root(self, select=-1):
        with self.lock:
            self.list.reset()

            for source, links in self.items:
                if len(links) > 1:
                    source += " >>"
                listitem = xbmcgui.ListItem(source)
                try:
                    icon = xbmcaddon.Addon(
                        id=links[0]['path'].split("/")[2]).getAddonInfo('icon')
                    listitem.setIconImage(icon)
                except:
                    pass
                self.list.addItem(listitem)

            if select >= 0:
                self.list.selectItem(select)
            self.insideIndex = -1
Esempio n. 21
0
def play_video(url):
    plugin.log.debug(url)
    quality = plugin.get_setting('qualityPref', int)
    info = getVideoInfo(url, quality=quality, resolve_redirects=True)
    if info:
        streams = info.streams()
        plugin.log.debug("num of streams: %d" % len(streams))
        from xbmcswift2 import xbmc, xbmcgui
        pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
        pl.clear()
        for stream in streams:
            li = xbmcgui.ListItem(stream['title'],
                                  iconImage="DefaultVideo.png")
            li.setInfo('video', {"Title": stream['title']})
            pl.add(stream['xbmc_url'], li)
        xbmc.Player().play(pl)
    else:
        plugin.log.warning('Fail to extract')
        plugin.play_video({'path': url, 'is_playable': True})
    return plugin.finish(None, succeeded=False)
Esempio n. 22
0
def player(url, gcid, cid, title, finalurl=False):
    '''
    play video, add subtitle
    '''
    if not finalurl:
        url = xl.urlopen(url, redirect=False)
    # cks = dict((ck.name, ck.value) for ck in xl.cookiejar)
    cks = ['%s=%s' % (ck.name, ck.value) for ck in xl.cookiejar]
    movurl = '%s|%s&Cookie=%s' % (url, urllib.urlencode(
        xl.headers), urllib2.quote('; '.join(cks)))

    # for ck in xl.cookiejar:
    #    print ck.name, ck.value
    listitem = xbmcgui.ListItem(label=title)
    listitem.setInfo(type="Video", infoLabels={'Title': title})
    player = xbmc.Player()
    player.play(movurl, listitem)

    surl = ''
    subtinfo = '{0}/subtitle/list?gcid={1}&cid={2}&userid={3}&t={4}'.format(
        cloudurlpre, gcid, cid, xl.userid, cachetime)
    subtinfo = '%s|%s&Cookie=%s' % (subtinfo, urllib.urlencode(
        xl.headers), urllib2.quote('; '.join(cks)))
    subtitle = xl.urlopen(subtinfo)
    sinfos = json.loads(subtitle)
    # print sinfos
    surls = ''
    if 'sublist' in sinfos and len(sinfos['sublist']):
        surls = [sinfo['surl'] for sinfo in sinfos['sublist']]
    if surls:
        for _ in xrange(30):
            if player.isPlaying():
                break
            time.sleep(1)
        else:
            raise Exception('No video playing. Aborted after 30 seconds.')
        xl.headers.pop('Accept-encoding')
        for surl in surls:
            player.setSubtitles(
                '%s|%s&Cookie=%s' % (surl, urllib.urlencode(
                    xl.headers), urllib2.quote('; '.join(cks))))
Esempio n. 23
0
def playmovie(cid, vid, name):
    if vid != '0':
        urls = video_from_vid(vid)
    else:
        urls = bilivideo_from_vid(cid)

    stack_url = 'stack://' + ' , '.join(urls)
    danmu = plugin.addon.getSetting('danmu')

    playlist = xbmc.PlayList(1)
    playlist.clear()
    list_item = xbmcgui.ListItem(name)
    if danmu == 'true':
        bilibili.parse_subtitle(cid)
        player.setSubtitle(bilibili._get_tmp_dir() + '/tmp.ass')
        playlist.add(stack_url, list_item)
        player.play(playlist)
        #while(not xbmc.abortRequested):
        xbmc.sleep(500)
    else:
        plugin.set_resolved_url(stack_url)
Esempio n. 24
0
    def _inside_root(self, select=-1):
        with self.lock:
            self.list.reset()

            for source, links in self.items:
                if len(links) > 1:
                    source += " > {0}".format(_("Found %i items") % len(links))
                listitem = xbmcgui.ListItem(source)
                try:
                    if "plugin://" in links[0]['path']:
                        icon = xbmcaddon.Addon(id=links[0]['path'].split("/")
                                               [2]).getAddonInfo('icon')
                    else:
                        icon = xbmc.translatePath("{0}/folder.jpg".format(
                            links[0]['path'].rsplit("/", 2)[0]))
                    listitem.setIconImage(icon)
                    listitem.setThumbnailImage(icon)
                except:
                    pass
                self.list.addItem(listitem)

            if select >= 0:
                self.list.selectItem(select)
            self.insideIndex = -1
Esempio n. 25
0
    def onInit(self):
        self.list = self.getControl( STATION_LIST_ID )

        #items = []
        station_list = []
        Streams = stations.getStations(_sort_stations)
        idx = 0
 
	print (xbmc.PLAYLIST_VIDEO)
	print (xbmc.PLAYLIST_MUSIC)
        audio_playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
        video_playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
        audio_playlist.clear()
        video_playlist.clear()
        for Station in Streams:
            Address = Station['Address']
            Country = Station['Country']
            Director= Station['Director']
            Email   = Station['Email']
            Icon    = Station['Icon']
            Name    = Station['Name']
            Phone   = Station['Phone']
            Schedule= Station['Schedule']
            Url     = Station['Url']
            Verified= Station['Verified']
            WebPage = Station['WebPage']
            Video   = Station['Video']

            if 'false' == Verified:
                continue

            order = str(idx).zfill(2)

            li = xbmcgui.ListItem(order + ") " + Name, Name)
            li.setInfo('music', {'Title': Name})

            li.setProperty('Address',   Address)
            li.setProperty('Country',   Country)
            li.setProperty('Director',  Director)
            li.setProperty('Email',     Email)
            li.setProperty('Icon',      Icon)
            li.setProperty('Name',      Name)
            li.setProperty('Phone',     Phone)
            li.setProperty('Url',       Url)
            li.setProperty('WebPage',   WebPage)
            li.setProperty('Schedule',  Schedule)
            li.setProperty('Id',        str(idx))
            li.setProperty('Video',     Video)

            xlistitem = xbmcgui.ListItem(Name, iconImage=Icon, path=Url)
            if ("true" == Video):
                xlistitem.setInfo( "video", { "Title": Name } )
                video_playlist.add(Url, xlistitem)
            else:
                xlistitem.setInfo( "audio", { "Title": Name } )
                audio_playlist.add(Url, xlistitem)

            station_list.append(li)
            idx = idx + 1;

        
        self.list.addItems( station_list )
        self.focusedID = _last_station_id
        self.stationsCount = len(Streams)
        self.list.selectItem(self.focusedID)
        #self.player = xbmc.Player(xbmc.PLAYER_CORE_AUTO)
        self.player = xbmc.Player()
        if (_auto_start):
            self.runPlayer(_last_station_id)
        else:
            self.list.selectItem(_last_focused_station_id)