Python xbmcplugin.setResolvedUrl() Examples

The following are 30 code examples of xbmcplugin.setResolvedUrl(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module xbmcplugin , or try the search function .
Example #1
Source File: addon.py    From filmkodi with Apache License 2.0 7 votes vote down vote up
def resolve_url(self, stream_url):
        '''
        Tell XBMC that you have resolved a URL (or not!).
        
        This method should be called as follows:
        
        #. The user selects a list item that has previously had ``isPlayable``
           set (this is true for items added with :meth:`add_item`, 
           :meth:`add_music_item` or :meth:`add_music_item`)
        #. Your code resolves the item requested by the user to a media URL
        #. Your addon calls this method with the resolved URL
        
        Args:
            stream_url (str or ``False``): If a string, tell XBMC that the 
            media URL ha been successfully resolved to stream_url. If ``False`` 
            or an empty string tell XBMC the resolving failed and pop up an 
            error messsage.
        '''
        if stream_url:
            self.log_debug('resolved to: %s' % stream_url)
            xbmcplugin.setResolvedUrl(self.handle, True, 
                                      xbmcgui.ListItem(path=stream_url))
        else:
            self.show_error_dialog(['sorry, failed to resolve URL :('])
            xbmcplugin.setResolvedUrl(self.handle, False, xbmcgui.ListItem()) 
Example #2
Source File: default.py    From ru with GNU General Public License v2.0 6 votes vote down vote up
def tvcsam(params):
    #http://www.tvc.ru/video/iframe/id/101797/isPlay/true/id_stat/channel/?acc_video_id=/channel/brand/id/2723/show/episodes/episode_id/47027
    #print "%s: url=%s"%(params['title'],params['flink'])
    #print "http://www.tvc.ru/"+params['flink']
    http=GET("http://www.tvc.ru/"+params['flink'])
    ll=re.compile('video/iframe/id/([0-9]+)/').findall(http)
    #print ll[0]
    #print http
    #window.pl.data.dataUrl = 'http://www.tvc.ru/video/json/id/102174';
    #lnk=re.compile('//www.tvc.ru/video/json/id/([0-9]+)').findall(http)
    #print lnk
    #print lnk[0]
    jso=json.loads(GET('http://www.tvc.ru/video/json/id/'+ll[0]))
    url=jso['path']['quality'][0]['url']
    item = xbmcgui.ListItem(path=url)
    xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item) 
Example #3
Source File: spike.py    From plugin.video.ustvvod with GNU General Public License v2.0 6 votes vote down vote up
def play_video(video_uri = common.args.url):
	# Handle the poewrnation specific video loading
	if 'powernation' in video_uri:
		video_data = connection.getURL(video_uri)
		video_json = json.loads(video_data)
		video_url = video_json['HLSURL']
		
		item = xbmcgui.ListItem(path = video_url)
		try:
			item.setThumbnailImage(common.args.thumb)
		except:
			pass
		try:
			item.setInfo('Video', {	'title' : common.args.name,
									'season' : common.args.season_number,
									'episode' : common.args.episode_number,
									'TVShowTitle' : common.args.show_title})
		except:
			pass
		xbmcplugin.setResolvedUrl(pluginHandle, True, item)
	else:
		video_data = connection.getURL(video_uri)
		video_url = BeautifulSoup(video_data, 'html5lib').find('div', class_ = 'video_player')['data-mgid']
		main_viacom.play_video(BASE, video_url) 
Example #4
Source File: addon.py    From xbmc-addons-chinese with GNU General Public License v2.0 6 votes vote down vote up
def play_video(room_id):
    """
    Play a video by the provided path.
    :param path: str
    :return: None
    """
    f = urllib2.urlopen('http://www.zhanqi.tv/api/static/live.roomid/{room_id}.json?sid='.format(room_id=room_id))
    obj = json.loads(f.read())
    #path = 'http://dlhls.cdn.zhanqi.tv/zqlive/{video}.m3u8'.format(video=obj['data']['videoIdKey']);
    #path = 'http://ebithdl.cdn.zhanqi.tv/zqlive/{video}.flv'.format(video=obj['data']['videoIdKey'])
    path = 'rtmp://wsrtmp.load.cdn.zhanqi.tv/zqlive/{video}'.format(video=obj['data']['videoId'])
    play_item = xbmcgui.ListItem(path=path, thumbnailImage=obj['data']['bpic'])
    play_item.setInfo(type="Video", infoLabels={"Title":obj['data']['title']})
    # Pass the item to the Kodi player.
    xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
    # directly play the item.
    xbmc.Player().play(path, play_item) 
Example #5
Source File: amc.py    From plugin.video.ustvvod with GNU General Public License v2.0 6 votes vote down vote up
def play_video(episode_url = common.args.url):
	episode_data = connection.getURL(APIBASE + 'episode-details?episode_id=' + episode_url)
	episode_json = json.loads(episode_data)
	video_url = VIDEOURL % episode_json['data']['Episode']['FullEpisode']['PID']
	print video_url
	video_data = connection.getURL(video_url)
	video_tree = BeautifulSoup(video_data)
	finalurl = video_tree.video['src']
	item = xbmcgui.ListItem(path = finalurl)
	try:
		item.setThumbnailImage(common.args.thumb)
	except:
		pass
	try:
		item.setInfo('Video', {	'title' : common.args.name,
								'season' : common.args.season_number,
								'episode' : common.args.episode_number,
								'TVShowTitle' : common.args.show_title})
	except:
		pass
	xbmcplugin.setResolvedUrl(pluginHandle, True, item) 
Example #6
Source File: msnbc.py    From plugin.video.ustvvod with GNU General Public License v2.0 6 votes vote down vote up
def play_video(video_url = common.args.url):
	hbitrate = -1
	sbitrate = int(addon.getSetting('quality')) * 1024
	closedcaption = None
	video_data = connection.getURL(video_url)
	video_tree = BeautifulSoup(video_data, 'html.parser')
	finalurl = video_tree.video['src']
	try:
		closedcaption = video_tree.find('textstream', type = 'text/vtt')['src']
	except:
		pass
	if (addon.getSetting('enablesubtitles') == 'true') and (closedcaption is not None):
			convert_subtitles(closedcaption)
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
	if (addon.getSetting('enablesubtitles') == 'true') and (closedcaption is not None):
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
		xbmc.Player().setSubtitles(ustvpaths.SUBTITLE) 
Example #7
Source File: marvelkids.py    From plugin.video.ustvvod with GNU General Public License v2.0 6 votes vote down vote up
def play_video(video_url = common.args.url):
	stored_size = 0
	video_data = connection.getURL(video_url)
	video_model = re.compile('model: *(\[.*\]),\s*videoPlayer: _player,', re.DOTALL).findall(video_data)[0]
	video_model = simplejson.loads(video_model)
	try:
		sbitrate = long(addon.getSetting('quality')) * 1000
	except Exception as e:
		print "Exception: ", e
	hbitrate = -1
	print sbitrate
	for item in video_model[0]['flavors']:
		if item['format'] == 'mp4' and item['security_profile'][0] == 'progressive':
			bitrate = item['bitrate']
			if bitrate > hbitrate and bitrate <= sbitrate:
				hbitrate = bitrate
				url = item['url']
	finalurl = url
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl)) 
Example #8
Source File: default.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
def resolve(name, url, iconimage, description):
    host = url
    if host.split('|')[0].endswith('.mp4') and 'clou' in host:
        stream_url = host + '|User-Agent=%s&Referer=%s' % (urllib.quote_plus(client.agent(), ':/'), GAMATO)
        name = name
    elif 'tenies-online' in host:
        stream_url = client.request(host)
        stream_url = client.parseDOM(stream_url, 'a', {'id': 'link'}, ret='href')[0]
        stream_url = evaluate(stream_url)
    else:
        stream_url = evaluate(host)
        name = name.split(' [B]|')[0]
    try:
        liz = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
        liz.setInfo(type="Video", infoLabels={"Title": name, "Plot": description})
        liz.setProperty("IsPlayable", "true")
        liz.setPath(str(stream_url))
        xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
    except BaseException:
        control.infoDialog(Lang(32012), NAME) 
Example #9
Source File: tvnplayer.py    From filmkodi with Apache License 2.0 6 votes vote down vote up
def __LOAD_AND_PLAY_WATCHED(self, url,
                                pType='video'):  # NOWE wersja używa xbmcplugin.setResolvedUrl wspiera status "watched"
        if url == '':
            d = xbmcgui.Dialog()
            d.ok('Nie znaleziono streamingu', 'Może to chwilowa awaria.', 'Spróbuj ponownie za jakiś czas')
            return False
        liz = xbmcgui.ListItem(path=url)
        try:
            return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
        except:
            d = self.dialog()
            if pType == "video":
                d.ok('Wystąpił błąd!', 'Błąd przy przetwarzaniu, lub wyczerpany limit czasowy oglądania.',
                     'Zarejestruj się i opłać abonament.', 'Aby oglądać za darmo spróbuj ponownie za jakiś czas.')
            elif pType == "music":
                d.ok('Wystąpił błąd!', 'Błąd przy przetwarzaniu.', 'Aby wysłuchać spróbuj ponownie za jakiś czas.')
            return False 
Example #10
Source File: default.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
def resolve(name, url, iconimage, description):
    stream_url = evaluate(url)
    name = name.split(' [B]|')[0]
    if stream_url is None:
        control.infoDialog('Prueba otro enlace', NAME, ICON, 4000)
    elif '.mpd|' in stream_url:
        stream_url, headers = stream_url.split('|')
        listitem = xbmcgui.ListItem(path=stream_url)
        listitem.setProperty('inputstreamaddon', 'inputstream.adaptive')
        listitem.setProperty('inputstream.adaptive.manifest_type', 'mpd')
        listitem.setMimeType('application/dash+xml')
        listitem.setProperty('inputstream.adaptive.stream_headers', headers)
        listitem.setContentLookup(False)
        xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
    else:
        try:
            liz = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
            liz.setInfo(type="Video", infoLabels={ "Title": name, "Plot": description })
            liz.setProperty("IsPlayable", "true")
            liz.setPath(str(stream_url))
            xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
        except:
            control.infoDialog('Prueba otro enlace', NAME, ICON, 4000) 
Example #11
Source File: xswift2.py    From plugin.video.openmeta with GNU General Public License v3.0 6 votes vote down vote up
def set_resolved_url(self, item=None, subtitles=None):
		if self._end_of_directory:
			raise Exception('Current Kodi handle has been removed. Either set_resolved_url(), end_of_directory(), or finish() has already been called.')
		self._end_of_directory = True
		succeeded = True
		if item is None:
			item = {}
			succeeded = False
		if isinstance(item, basestring):
			item = {'path': item}
		item = self._listitemify(item)
		item.set_played(True)
		xbmcplugin.setResolvedUrl(self.handle, succeeded, item.as_xbmc_listitem())
		if subtitles:
			self._add_subtitles(subtitles)
		return [item] 
Example #12
Source File: xbmc_runner.py    From plugin.video.youtube with GNU General Public License v2.0 6 votes vote down vote up
def _set_resolved_url(self, context, base_item, succeeded=True):
        item = xbmc_items.to_item(context, base_item)
        item.setPath(base_item.get_uri())
        xbmcplugin.setResolvedUrl(context.get_handle(), succeeded=succeeded, listitem=item)

        """
        # just to be sure :)
        if not isLiveStream:
            tries = 100
            while tries>0:
                xbmc.sleep(50)
                if xbmc.Player().isPlaying() and xbmc.getCondVisibility("Player.Paused"):
                    xbmc.Player().pause()
                    break
                tries-=1
        """ 
Example #13
Source File: addon.py    From plugin.audio.tidal2 with GNU General Public License v3.0 6 votes vote down vote up
def play_track(track_id, album_id):
    media_url = session.get_media_url(track_id, album_id=album_id)
    log("Playing: %s" % media_url)
    disableInputstreamAddon = False
    if not media_url.startswith('http://') and not media_url.startswith('https://') and \
        not 'app=' in media_url.lower() and not 'playpath=' in media_url.lower():
        # Rebuild RTMP URL
        if KODI_VERSION >= (17, 0):
            media_url = 'rtmp://%s' % media_url
            disableInputstreamAddon = True
        else:
            host, tail = media_url.split('/', 1)
            app, playpath = tail.split('/mp4:', 1)
            media_url = 'rtmp://%s app=%s playpath=mp4:%s' % (host, app, playpath)
    li = ListItem(path=media_url)
    if disableInputstreamAddon:
        # Krypton can play RTMP Audio Streams without inputstream.rtmp Addon
        li.setProperty('inputstreamaddon', '')
    mimetype = 'audio/flac' if session._config.quality == Quality.lossless and session.is_logged_in else 'audio/mpeg'
    li.setProperty('mimetype', mimetype)
    xbmcplugin.setResolvedUrl(plugin.handle, True, li) 
Example #14
Source File: main.py    From plugin.video.auvio with GNU General Public License v3.0 6 votes vote down vote up
def play_radio(params):
    
    cid = int(params.get('channel_id',None))
    media_url = None
    
    common.plugin.log("play_radio #{0}".format(cid))

    channel = api.get_single_channel(cid)
    
    if channel:
        common.plugin.log(json.dumps(channel))
        stream_node = channel.get('streamurl',None)

        if stream_node:
            media_url = stream_node.get('mp3','').encode('utf-8').strip()
        
    if not media_url:
        common.plugin.log_error("unable to get the radio stream URL.")
        common.popup("Impossible de trouver le flux radio")
        
    #play
    liz = xbmcgui.ListItem(path=media_url)
    return xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=liz) 
Example #15
Source File: default.py    From tdw with GNU General Public License v3.0 6 votes vote down vote up
def play(url, id=0):
	print url
	engine=__settings__.getSetting("Engine")
	if engine=="0":
		play_ace(url, id)
		
	if engine=="1":
		item = xbmcgui.ListItem()#path=url
		xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
		tthp.play(url, handle, id, __settings__.getSetting("DownloadDirectory"))
		
	if engine=="2":
		purl ="plugin://plugin.video.yatp/?action=play&torrent="+ urllib.quote_plus(url)+"&file_index="+str(id)
		item = xbmcgui.ListItem()#path=purl
		xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
		xbmc.Player().play(purl) 
Example #16
Source File: plugin_content.py    From plugin.audio.spotify with GNU General Public License v3.0 6 votes vote down vote up
def next_track(self):
        '''special entry which tells the remote connect player to move to the next track'''
        
        cur_playlist_position = xbmc.PlayList(xbmc.PLAYLIST_MUSIC).getposition()
        # prevent unintentional skipping when Kodi track ends before connect player
        # playlist position will increse only when play next button is pressed
        if cur_playlist_position > self.last_playlist_position:
            # move to next track
            self.sp.next_track()
            # give time for connect player to update info
            xbmc.sleep(100)
            
        self.last_playlist_position = cur_playlist_position
        cur_playback = self.sp.current_playback()
        trackdetails = cur_playback["item"]
        url, li = parse_spotify_track(trackdetails, silenced=True)
        xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li) 
Example #17
Source File: default.py    From kodi with GNU General Public License v3.0 6 votes vote down vote up
def play_item(self, url, pid = None):
        print "*** play url %s" % url

        if (pid == None) and ("m3u8" in url):
            url = ("http:" if (not ("http://" in url)) else "") + url
            response = common.fetchPage({"link": url})
            if (not (("http://" in response["content"]) or ("https://" in response["content"]))):
                content = response["content"].split("\n")
                name = os.path.join(self.path.decode("utf-8"), 'resources/playlists/') + "temp.m3u8"
                block = url.split("mp4")[0]
                f = open(name, "w+")
                for line in content:
                   if "mp4" in line:
                       line = block + "mp4" + line.split("mp4")[-1]
                   f.write(line + "\n")
                f.close()
                item = xbmcgui.ListItem(path=name)
            else:
                item = xbmcgui.ListItem(path=url) 
        else:
            item = xbmcgui.ListItem(path=url) 
        xbmcplugin.setResolvedUrl(self.handle, True, item) 
Example #18
Source File: default.py    From kodi with GNU General Public License v3.0 6 votes vote down vote up
def play(self, stream, url_main):
        if 'm3u8' in stream:
            print "M3U8"
            url = stream
        else:
            print "RTMP"
            url = stream
            url += " swfUrl=http://tivix.co/templates/Default/style/uppod.swf"
            url += " pageURL=http://tivix.co"
            url += " swfVfy=true live=true"

        try:         
            item = xbmcgui.ListItem(path = url + "|Referer="+url_main)
            xbmcplugin.setResolvedUrl(self.handle, True, item)
        except:
            self.showErrorMessage("The channel is not available") 
Example #19
Source File: addon.py    From plugin.audio.tidal2 with GNU General Public License v3.0 6 votes vote down vote up
def play_track_cut(track_id, cut_id, album_id):
    media_url = session.get_media_url(track_id, cut_id=cut_id, album_id=album_id)
    log("Playing Cut %s: %s" % (cut_id, media_url))
    disableInputstreamAddon = False
    if not media_url.startswith('http://') and not media_url.startswith('https://') and \
        not 'app=' in media_url.lower() and not 'playpath=' in media_url.lower():
        # Rebuild RTMP URL
        if KODI_VERSION >= (17, 0):
            media_url = 'rtmp://%s' % media_url
            disableInputstreamAddon = True
        else:
            host, tail = media_url.split('/', 1)
            app, playpath = tail.split('/mp4:', 1)
            media_url = 'rtmp://%s app=%s playpath=mp4:%s' % (host, app, playpath)
    li = ListItem(path=media_url)
    if disableInputstreamAddon:
        # Krypton can play RTMP Audio Streams without inputstream.rtmp Addon
        li.setProperty('inputstreamaddon', '')
    mimetype = 'audio/flac' if session._config.quality == Quality.lossless and session.is_logged_in else 'audio/mpeg'
    li.setProperty('mimetype', mimetype)
    xbmcplugin.setResolvedUrl(plugin.handle, True, li) 
Example #20
Source File: plugin.py    From kodi with GNU General Public License v3.0 6 votes vote down vote up
def play(url, direct):
    if (direct != 1) and ("m3u8" in url):
        url = ("http:" if (not (("http://" in url) or ("https://" in url))) else "") + url
        response = common.fetchPage({"link": url})
        if (not (("http://" in response["content"]) or ("https://" in response["content"]))):
            content = response["content"].split("\n")
            name = os.path.join(PATH.decode("utf-8"), 'resources/playlists/') + "temp.m3u8"
            block = url.split("mp4")[0]
            f = open(name, "w+")
            for line in content:
               if "mp4" in line:
                   line = block + "mp4" + line.split("mp4")[-1]
               f.write(line + "\n")
            f.close()
            item = xbmcgui.ListItem(path=name)
        else:
            item = xbmcgui.ListItem(path=url) 
    else:
        item = xbmcgui.ListItem(path=url) 
    xbmcplugin.setResolvedUrl(HANDLE, True, item) 
Example #21
Source File: default.py    From kodi with GNU General Public License v3.0 6 votes vote down vote up
def play(self, url):
        print "Play media URL: %s" % url

        hd = True if  self.addon.getSetting('hd_youtube_videos') == 'true' else False
        supported_resolutions = ['720p', '1080p'] if hd else ['360p', '480p']
        video_url = ''

        try:
            if 'youtube' in url:
                yt.url = url
                video_url = yt.videos[-1].url
            else:
                video_url = url

            print urllib.unquote(video_url)
            item = xbmcgui.ListItem(path=video_url)
            xbmcplugin.setResolvedUrl(self.handle, True, item)
        except Exception, e:
            self.showErrorMessage(e) 
Example #22
Source File: addon.py    From plugin.video.sparkle with GNU General Public License v3.0 6 votes vote down vote up
def resolve_url(self, stream_url):
        '''
        Tell XBMC that you have resolved a URL (or not!).
        
        This method should be called as follows:
        
        #. The user selects a list item that has previously had ``isPlayable``
           set (this is true for items added with :meth:`add_item`, 
           :meth:`add_music_item` or :meth:`add_music_item`)
        #. Your code resolves the item requested by the user to a media URL
        #. Your addon calls this method with the resolved URL
        
        Args:
            stream_url (str or ``False``): If a string, tell XBMC that the 
            media URL ha been successfully resolved to stream_url. If ``False`` 
            or an empty string tell XBMC the resolving failed and pop up an 
            error messsage.
        '''
        if stream_url:
            self.log_debug('resolved to: %s' % stream_url)
            xbmcplugin.setResolvedUrl(self.handle, True, 
                                      xbmcgui.ListItem(path=stream_url))
        else:
            self.show_error_dialog(['sorry, failed to resolve URL :('])
            xbmcplugin.setResolvedUrl(self.handle, False, xbmcgui.ListItem()) 
Example #23
Source File: default.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def play(params):
	login = __settings__.getSetting("Login")
	password = __settings__.getSetting("Password")
	if len(login) == 0 or len(password) == 0:
		showMessage('Error', 'Проверьте логин и пароль', 3000)
		return False

	href = urllib.unquote_plus(params['href'])
	video = json.loads(urllib.unquote_plus(params['video']))
	files = {}
	for videoData in video:
		try:
			files[videoData[0]]
		except:
			files[videoData[0]] = {}
		files[videoData[0]][videoData[1]] = "%s/%s.%s" % (videoData[0], videoData[1], videoData[2])

	for filesData in getFilesByLang(files):
		for file in getFiles(filesData):
			target = href + file
			fileUrl = GET(
				target, apiUrl, {
					"username": login,
					"password": password
				}, True, True)
			if fileUrl and isRemoteFile(fileUrl):
				i = xbmcgui.ListItem(path = fileUrl)
				i.setProperty('mimetype', 'video/x-msvideo')
				xbmcplugin.setResolvedUrl(h, True, i)
				return True

	return False 
Example #24
Source File: ivi2xbmc.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def playid(params, play=False):


	try:
		f = open(adv_file, 'r')
		last_ad=f.readline()

	except:
		f = open(adv_file, 'w')
		last_ad=str(int(time.time()))
		f.write(last_ad)
		f.close()
	aplay=dig_player()
	aplay.init()
	aplay.lastad=last_ad
	aplay.pre_end=time.time()
	aplay.getData(params['id'])
	if aplay.strt_file!=None:
		item = xbmcgui.ListItem(path=aplay.strt_file)
		xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
		aplay.play_loop()
		aplay.stop
		aplay.active=False
	else:
		ShowMessage('music.ivi.ru', language(30010), 2000)
		#track_page_view(str(params['id']),'event','5(Video*VideoForbidden)',UATRACK=GATrack)
		aplay.stop 
Example #25
Source File: torr2xbmc.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def play_url2(params):
    torr_link=urllib.unquote(params["torr_url"])
    img=urllib.unquote_plus(params["img"])
    title=urllib.unquote_plus(params["title"])
    TSplayer=TSengine()
    out=TSplayer.load_torrent(torr_link,'TORRENT')
    if out=='Ok':
        lnk=TSplayer.get_link(int(params['ind']),title, img, img)
        if lnk:
            item = xbmcgui.ListItem(path=lnk)
            item.setInfo(type="Video",infoLabels={"Title": params['title1']})
            xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
            while not xbmc.Player().isPlaying:
                xbmc.sleep(300)
            while TSplayer.player.active and not TSplayer.local: 
                TSplayer.loop()
                xbmc.sleep(300)
                if xbmc.abortRequested:
                    TSplayer.log.out("XBMC is shutting down")
                    break
            if TSplayer.local and xbmc.Player().isPlaying: 
                try: time1=TSplayer.player.getTime()
                except: time1=0
                i = xbmcgui.ListItem("***%s"%title)
                i.setProperty('StartOffset', str(time1))
                xbmc.Player().play(TSplayer.filename.decode('utf-8'),i)

        else:
            item = xbmcgui.ListItem(path='')
            xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, item) 
    TSplayer.end()
    xbmc.Player().stop
    xbmc.executebuiltin('Container.Refresh') 
Example #26
Source File: addon.py    From xbmc-addons-chinese with GNU General Public License v2.0 5 votes vote down vote up
def play_video(episode,name):
    """
    Play a video by the provided path.
    :param path: str
    :return: None
    """
    episode = episode.replace("show_episode?","play_episode?")
    html = get(_meijumao+episode)
    if not html:
        dialog.ok(__addonname__, '没有找到视频源,播放出错')
        return
    soup_js = BeautifulSoup(html,"html5lib")
    title = ""
    if soup_js.find_all("h1"):
        title = soup_js.find_all("h1")[0].get_text()
    if soup_js.find_all("li",attrs={"class":"active"}):
        title += " - "+soup_js.find_all("li",attrs={"class":"active"})[0].get_text()
    play_url = ""
    for script in soup_js.find_all('script'):
        matched = re.search('http.*m3u8.*\"', script.get_text())
        if matched:
            play_url =  matched.group().replace("\"","").replace("&amp;","&").replace("->application/x-mpegURL","")
    if len(play_url) == 0:
        dialog.ok(__addonname__, '没有找到视频源,播放出错')
        return
    play_item = xbmcgui.ListItem(name)
    play_item.setInfo(type="Video",infoLabels={"Title":name})
    # Pass the item to the Kodi player.
    xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
    # directly play the item.
    xbmc.Player().play(play_url, play_item) 
Example #27
Source File: default.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def play(fle, ind):	
	fle = os.path.join(__addon__.getAddonInfo('path'),'torrents',fle + '.torrent')
	purl = "plugin://plugin.video.tam/?mode=play&url=" + urllib.quote_plus(fle) + "&ind=" + str(ind)
	item = xbmcgui.ListItem(path=purl)
	xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
	#xbmc.executebuiltin("Container.Refresh") 
Example #28
Source File: ivi2fstep.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def play(params):

	i = xbmcgui.ListItem(path = params['file'])
	xbmcplugin.setResolvedUrl(hos, True, i) 
Example #29
Source File: default.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def play(params):
    fileUrl = urllib.unquote_plus(params['href'])

    i = xbmcgui.ListItem(path=get_full_url(fileUrl))
    xbmcplugin.setResolvedUrl(h, True, i) 
Example #30
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def play_episode_(self, url, referer, post_id, season_id, episode_id, title, image):
        log("*** play_episode")
        try:
            url = self.get_seasons_link(referer, post_id, season_id, episode_id)

            item = xbmcgui.ListItem(path=url)
            xbmcplugin.setResolvedUrl(self.handle, True, item)

        except Exception as ex:
            url_episode = url + "?nocontrols=1&season=%s&episode=%s" % (season_id, episode_id)
            links, subtitles = self.get_video_link_from_iframe(url_episode)
            self.selectQuality(links, title, image, subtitles)
            xbmcplugin.setContent(self.handle, 'episodes')
            xbmcplugin.endOfDirectory(self.handle, True)