def PLAY_RTE(name,url,iconimage):
name=htmlcleaner.cleanUnicode(name)
if 'feeds' in url:
link=OPEN_URL(url)
URL=re.compile('media:content url="(.+?)"').findall(link)[0]
import F4MProxy
player=F4MProxy.f4mProxyHelper()
player.playF4mLink(URL, name,iconimage)
else:
if 'f4m' in url:
import F4MProxy
player=F4MProxy.f4mProxyHelper()
player.playF4mLink(url, name,iconimage)
else:
select=[]
returned=[]
r='http://www.rte.ie/manifests/%s.f4m'%url
html=OPEN_URL(r)
match=re.compile('href=".+?-(.+?)\.f4m"').findall(html)
for i in match:
select.append(i+'P')
returned.append(i)
link=(returned[xbmcgui.Dialog().select('Please Select', select)])
stream='http://cdn.rasset.ie/hls-live/_definst_/%s/%s-%s.m3u8' %(url,url,link)
liz = xbmcgui.ListItem(name, iconImage='DefaultVideo.png', thumbnailImage=iconimage)
liz.setInfo(type='Video', infoLabels={'Title':name})
liz.setProperty("IsPlayable","true")
liz.setPath(stream)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
python类setResolvedUrl()的实例源码
def TG4_PLAY_LINK(name,url,iconimage):
vid=url
pubid=iconimage.split('pubId=')[1]
stream_url='http://c.brightcove.com/services/mobile/streaming/index/master.m3u8?videoId=%s&pubId=%s'% (vid,pubid)
liz = xbmcgui.ListItem(name, iconImage='DefaultVideo.png', thumbnailImage=iconimage)
liz.setInfo(type='Video', infoLabels={'Title':name})
liz.setProperty("IsPlayable","true")
liz.setPath(stream_url)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
def threeE(name,url,iconimage):
import time
TIME=str(time.time())
TIME=TIME.split('.')[0]
stream_url='http://csm-e.cds1.yospace.com/csm/extlive/tv3ie01,tv3-prd.m3u8?yo.ac=true&yo.sl=3&yo.po=5&yo.ls=1,2,3&unique='+ TIME
liz = xbmcgui.ListItem(name, iconImage='DefaultVideo.png', thumbnailImage=iconimage)
liz.setInfo(type='Video', infoLabels={'Title':name})
liz.setProperty("IsPlayable","true")
liz.setPath(stream_url)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
def PLAY_STREAM(name,url,iconimage):
url='http://c.brightcove.com/services/mobile/streaming/index/master.m3u8?videoId='+url
liz = xbmcgui.ListItem(name, iconImage='DefaultVideo.png', thumbnailImage=iconimage)
liz.setInfo(type='Video', infoLabels={'Title':name})
liz.setProperty("IsPlayable","true")
liz.setPath(url)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
def GetLivePlayable(name,url,iconimage):
STREAM = url
liz = xbmcgui.ListItem(name, iconImage='DefaultVideo.png', thumbnailImage=iconimage)
liz.setInfo(type='Video', infoLabels={'Title':name})
liz.setProperty("IsPlayable","true")
liz.setPath(STREAM)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
#self.AddLiveLink( list, id.replace('_',' ').upper(), url, language = language.title(),host= 'BBC iPLAYER '+supplier,quality=quality_dict.get(res, 'NA'))
def PLAY_STREAM(name,url,iconimage):
name = name.split(' : ', 1)[-1]
liz = xbmcgui.ListItem(name, iconImage='DefaultVideo.png', thumbnailImage=iconimage)
liz.setInfo(type='Video', infoLabels={'Title':name})
liz.setProperty("IsPlayable","true")
liz.setPath(url)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
def play_video(self, stream):
if stream is not None:
play_item = xbmcgui.ListItem(path=stream.stream_url)
if stream.subtitle_url is not None:
play_item.setSubtitles([stream.subtitle_url])
xbmcplugin.setResolvedUrl(self._handle, True, listitem=play_item)
def play_livestream(self, path):
play_item = xbmcgui.ListItem(path=path)
xbmcplugin.setResolvedUrl(self._handle, True, listitem=play_item)
def router(paramstring):
params = dict(parse_qsl(paramstring[1:]))
if params:
if params['mode'] == 'play':
play_item = xbmcgui.ListItem(path=params['link'])
xbmcplugin.setResolvedUrl(__handle__, True, listitem=play_item)
else:
for stream in streams():
list_item = xbmcgui.ListItem(label=stream['name'], thumbnailImage=stream['thumb'])
list_item.setProperty('fanart_image', stream['thumb'])
list_item.setProperty('IsPlayable', 'true')
url = '{0}?mode=play&link={1}'.format(__url__, stream['link'])
xbmcplugin.addDirectoryItem(__handle__, url, list_item, isFolder=False)
xbmcplugin.endOfDirectory(__handle__)
def play_video(video_id):
media = session.get_video_url(video_id)
if media:
log("Playing: %s" % media.url)
li = ListItem(path=media.url)
li.setProperty('mimetype', 'video/mp4')
xbmcplugin.setResolvedUrl(plugin.handle, True, li)
def _set_resolved_url(self, context):
"""
Resolve a playable URL
:param context: context object
:type context: PlayContext
"""
self.log_debug('Resolving URL from {0}'.format(str(context)))
if context.play_item is None:
list_item = xbmcgui.ListItem(path=context.path)
else:
list_item = self.create_list_item(context.play_item)
xbmcplugin.setResolvedUrl(self._handle, context.succeeded, list_item)
def play_resolved_url(url):
_log("play_resolved_url ["+url+"]")
listitem = xbmcgui.ListItem(path=url)
listitem.setProperty('IsPlayable', 'true')
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
def play_channel(channel):
"""Make kodi play a TV channel"""
url = get_channel_url(channel)
play_item = xbmcgui.ListItem("Channel")
play_item.setPath(url)
play_item.setInfo(type='Video', infoLabels={'Title': 'Channel'})
play_item.setProperty("IsPlayable", "true")
xbmcplugin.setResolvedUrl(plugin_handle, True, listitem=play_item)
plugintools.py 文件源码
项目:plugin.video.streamondemand-pureita
作者: orione7
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def play_resolved_url(url):
_log("play_resolved_url ["+url+"]")
listitem = xbmcgui.ListItem(path=url)
listitem.setProperty('IsPlayable', 'true')
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
def playMP3Track(songId):
content = trackPostUnicodeGetRestrictedPage('https://music.amazon.de/dmls/', songId)
url_list_match = re.compile('urlList":\["(.+?)"',re.DOTALL).findall(content)
if url_list_match:
mp3_file_string = url_list_match[0]
play_item = xbmcgui.ListItem(path=mp3_file_string)
play_item = setPlayItemInfo(play_item)
xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=play_item)
def playUrl(url):
xbmc.log('Play url:' + url,xbmc.LOGDEBUG)
if not in_xbmc:
return True
liz = xbmcgui.ListItem(path=url)
return xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=liz)
def play(channel_id, airing_id=None):
stream_url = fsgo.get_stream_url(channel_id, airing_id)
if stream_url:
bitrate = select_bitrate(stream_url['bitrates'].keys())
if bitrate:
play_url = stream_url['bitrates'][bitrate]
playitem = xbmcgui.ListItem(path=play_url)
playitem.setProperty('IsPlayable', 'true')
xbmcplugin.setResolvedUrl(_handle, True, listitem=playitem)
else:
dialog('ok', language(30020), message=language(30021))
def play_video(path):
"""
Play a video by the provided path.
:param path: str
"""
# Get the list of videos in the category.
url = get_video(path)
print("play_video:url={0}".format(url))
# Create a playable item with a path to play.
play_item = xbmcgui.ListItem(path=url)
# Pass the item to the Kodi player.
xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
def IStreamPlayback(url, asin, trailer):
values = getFlashVars(url)
if not values:
return
vMT = 'Trailer' if trailer == '1' else 'Feature'
data = getUrldata(mode='catalog/GetPlaybackResources',
values=values,
extra=True,
vMT=vMT,
opt='&titleDecorationScheme=primary-content')
title, plot, mpd, subs = getStreams(*data, retmpd=True)
licURL = getUrldata(mode='catalog/GetPlaybackResources',
values=values,
extra=True,
vMT=vMT,
dRes='Widevine2License',
retURL=True)
common.Log(mpd)
listitem = xbmcgui.ListItem(path=mpd)
if trailer == '1':
if title:
listitem.setInfo('video', {'Title': title + ' (Trailer)'})
if plot:
listitem.setInfo('video', {'Plot': plot})
listitem.setSubtitles(subs)
listitem.setProperty('inputstreamaddon', 'inputstream.mpd')
listitem.setProperty('inputstream.mpd.license_type', 'com.widevine.alpha')
listitem.setProperty('inputstream.mpd.license_key', licURL)
xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=listitem)
def _sendMessage(self, level, caption, message, action=Action()):
dialog = xbmcgui.Dialog()
dialog.notification(caption, message, level)
url = self.encodeUrl(action)
self.context.log.info("[Response] - send{} '{}', redirecting to '{}'", caption, message, url)
listItem = xbmcgui.ListItem()
xbmcplugin.setResolvedUrl(self.handle, False, listItem)