本文整理汇总了Python中YDStreamExtractor.getVideoInfo方法的典型用法代码示例。如果您正苦于以下问题:Python YDStreamExtractor.getVideoInfo方法的具体用法?Python YDStreamExtractor.getVideoInfo怎么用?Python YDStreamExtractor.getVideoInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YDStreamExtractor
的用法示例。
在下文中一共展示了YDStreamExtractor.getVideoInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getExtURL
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def getExtURL(urlPage):
print 'YoutubeDL decoding ' + urlPage
vid = YDStreamExtractor.getVideoInfo(urlPage,quality=2) #quality is 0=SD, 1=720p, 2=1080p and is a maximum
stream_url = vid.streamURL() #This is what Kodi (XBMC) will play
return stream_url
示例2: download_video
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def download_video(self):
selection = xbmcgui.Dialog().select(heading=LANG(22080), list=[LANG(33003)])
if selection == 0:
import YDStreamExtractor
vid = YDStreamExtractor.getVideoInfo(self.listitem.getProperty("youtube_id"), quality=1)
YDStreamExtractor.handleDownload(vid)
示例3: playYoutubeVid
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def playYoutubeVid(id, meta=None, poster=None):
'''
from resources.lib import pafy
pafy.set_api_key(vars.API_KEY)
#Resolve the youtube video url for ourselves
v = pafy.new(id)
stream_url = v.getbest().url
'''
if meta is None:
#Create an empty meta, so we can fill it with the information grabbed from youtube
meta = {}
if 'title' not in meta:
meta['title'] = v.title #Store the youtube title in the meta
if poster is None:
poster = 'Default.png'
#YDStreamExtractor.disableDASHVideo(True) #Kodi (XBMC) only plays the video for DASH streams, so you don't want these normally. Of course these are the only 1080p streams on YouTube
try:
#url = id #a youtube ID will work as well and of course you could pass the url of another site
vid = YDStreamExtractor.getVideoInfo(id,quality=1) #quality is 0=SD, 1=720p, 2=1080p and is a maximum
stream_url = vid.streamURL() #This is what Kodi (XBMC) will play
except:
dev.log('Failed to get a valid stream_url!')
return False #Failed to grab a video title
#xbmc.Player().play(v.getbest().url) #Play this video
liz = xbmcgui.ListItem(meta['title'], iconImage=poster, thumbnailImage=poster)
liz.setInfo( type="Video", infoLabels=meta )
liz.setPath(stream_url)
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
示例4: playYoutubeVid
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def playYoutubeVid(id, meta=None, poster=None):
dev.log('poster: '+poster)
#Poster URL that hickups the addon: image://C%3a%5cKodi%5cportable_data%5cuserdata%5caddon_data%5cplugin.video.youtubelibrary%5cStreams%5cTV%5cSleuteltje%20-%20Bios%20Intros%5cfolder.jpg/
#poster = None
if meta is None:
#Create an empty meta, so we can fill it with the information grabbed from youtube
meta = {}
if poster is None:
poster = 'Default.png'
elif poster.startswith('image://'):
poster = poster[8:-1]
poster = urllib.unquote(urllib.unquote(poster))
dev.log('poster cleaned: '+poster)
#YDStreamExtractor.disableDASHVideo(True) #Kodi (XBMC) only plays the video for DASH streams, so you don't want these normally. Of course these are the only 1080p streams on YouTube
try:
#url = id #a youtube ID will work as well and of course you could pass the url of another site
vid = YDStreamExtractor.getVideoInfo(id,quality=1) #quality is 0=SD, 1=720p, 2=1080p and is a maximum
stream_url = vid.streamURL() #This is what Kodi (XBMC) will play
except:
dev.log('Failed to get a valid stream_url!')
return False #Failed to grab a video title
if 'title' not in meta:
meta['title'] = vid.title #Store the youtube title in the meta
#xbmc.Player().play(v.getbest().url) #Play this video
liz = xbmcgui.ListItem(meta['title'], iconImage=poster, thumbnailImage=poster)
liz.setInfo( type="Video", infoLabels=meta )
liz.setPath(stream_url)
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
示例5: fullInfo
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def fullInfo(videoId):
fullUrl = "https://www.youtube.com/watch?v=" + videoId
vid = YDStreamExtractor.getVideoInfo(fullUrl,quality=1)
streamurl = vid.streamURL()
title = vid.title
description = vid.description
thumb = vid.thumbnail
return streamurl, title, description, thumb
# def batchResolve(collection):
# for video in collection.videoList:
# thread = ResolveThread(video)
# thread.start()
#
#
# import threading
# class ResolveThread(threading.Thread):
# def __init__(self, video):
# threading.Thread.__init__(self)
# self.video = video
#
# def run(self):
# print 'starting thread'
# vid = YDStreamExtractor.getVideoInfo(self.video.fullUrl(),quality=1)
# print vid.streamURL()
示例6: handlePush
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def handlePush(data, from_gui=False):
if not from_gui and checkForWindow(): # Do nothing if the window is open
return False
if data.get("type") == "link":
url = data.get("url", "")
if StreamExtractor.mightHaveVideo(url):
vid = StreamExtractor.getVideoInfo(url)
if vid:
if vid.hasMultipleStreams():
vlist = []
for info in vid.streams():
vlist.append(info["title"] or "?")
idx = xbmcgui.Dialog().select(util.T(32091), vlist)
if idx < 0:
return
vid.selectStream(idx)
util.LOG(vid.streamURL()) # TODO: REMOVE
StreamUtils.play(vid.streamURL())
return True
if canPlayURL(url):
handleURL(url)
return True
media = getURLMediaType(url)
if media == "video" or media == "music":
StreamUtils.play(url)
return True
elif media == "image":
import gui
gui.showImage(url)
return True
elif data.get("type") == "file":
if data.get("file_type", "").startswith("image/"):
import gui
gui.showImage(data.get("file_url", ""))
return True
elif data.get("file_type", "").startswith("video/") or data.get("file_type", "").startswith("audio/"):
StreamUtils.play(data.get("file_url", ""))
return True
elif data.get("type") == "note":
import gui
gui.showNote(data.get("body", ""))
return True
elif data.get("type") == "list":
import gui
gui.showList(data)
return True
elif data.get("type") == "address":
import urllib
xbmc.executebuiltin(
"XBMC.RunScript(special://home/addons/service.pushbullet.com/lib/maps.py,service.pushbullet.com,%s,None,)"
% urllib.quote(data.get("address", ""))
)
return True
return False
示例7: showVideo
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def showVideo(url):
if url:
import YDStreamExtractor
YDStreamExtractor.disableDASHVideo(True)
vid = YDStreamExtractor.getVideoInfo(url, quality=1)
url = vid.streamURL()
plugin.set_resolved_url({'path':url, 'info': {'type': 'Video'}})
示例8: PlayTrailer
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def PlayTrailer(youtube_id):
import YDStreamExtractor
YDStreamExtractor.disableDASHVideo(True)
vid = YDStreamExtractor.getVideoInfo(youtube_id, quality=1)
if vid:
stream_url = vid.streamURL()
log("Youtube Trailer:" + stream_url)
xbmc.executebuiltin("PlayMedia(%s)" % stream_url)
示例9: get_video_info
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def get_video_info(url):
info = YDStreamExtractor.getVideoInfo(url)
if hasattr(info, '_streams'):
return info
else:
log_utils.log('Stream not available: |%s|' % url, log_utils.LOGERROR)
kodi.notify(msg=kodi.i18n('stream_not_available'), sound=False)
return None
示例10: downloadYoutubeVid
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def downloadYoutubeVid(name, fold, videoid, settings, type='', season=None):
#youtube-dl command to download best quality: -f bestvideo[ext!=webm]+bestaudio[ext!=webm]/best[ext!=webm]
#YDStreamExtractor.disableDASHVideo(True)
movieLibrary = vars.tv_folder #The path we should save in is the vars.tv_folder setting from the addon settings
if type=='musicvideo':
movieLibrary = vars.musicvideo_folder
if type=='movies':
movieLibrary = vars.movies_folder
folder = os.path.join(movieLibrary, fold) #Set the folder to the maindir/dir
enc_name = dev.legal_filename(name) #Encode the filename to a legal filename
xbmcvfs.mkdir(movieLibrary) #Create the maindirectory if it does not exist yet
xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet
xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet
if type == '' or type == 'tv':
folder = os.path.join(folder, 'Season '+season) #Set the folder to the maindir/dir
xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet
full_file_path = os.path.join(folder, enc_name) #Set the file to maindir/name/name
dev.log('Downloading '+videoid, 1)
#vid = YDStreamExtractor.getVideoInfo(videoid,quality=1)
path = os.path.join(movieLibrary, fold) #Set the folder to the maindir/dir
#url = "https://www.youtube.com/watch?v=YKSU82afy1w" #ducktales intro to test
url = "https://www.youtube.com/watch?v="+videoid
vid = YDStreamExtractor.getVideoInfo(url,quality=1)
if vid == None:
dev.log('Failed to retrieve video from url: '+url)
return False
if settings.find('download_videos').text == '720p':
dev.log('%%%%%%% QUALITY: 720p quality selected')
format = 'bestvideo[height<=?720]+bestaudio/best[height<=?720]'
elif settings.find('download_videos').text == '1080p':
dev.log('%%%%%%% QUALITY: 1080p quality selected')
format = 'bestvideo[height<=?1080]+bestaudio/best[height<=?1080]'
else:
dev.log('%%%%%%% QUALITY: best quality selected')
format = 'bestvideo+bestaudio/best'
ydl_opts = {
'format': format,
'logger': MyLogger(),
'progress_hooks': [my_hook],
'outtmpl' : full_file_path+'.%(ext)s',
#'-o' : enc_name+'.%(ext)s',
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
return ydl.download(['https://www.youtube.com/watch?v='+videoid])
"""
示例11: play
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def play(url):
if url.find('linkOut') != -1:
urlout = url.split('?id=')[-1]
url = base64.b64decode(urlout)
plugin.notify(msg=urlout, title=url)
resolved = ''
stream_url = ''
item = None
try:
import urlresolver
resolved = urlresolver.HostedMediaFile(url).resolve()
if not resolved or resolved == False or len(resolved) < 1:
resolved = urlresolver.resolve(url)
if resolved is None or len(resolved) < 1:
resolved = urlresolver.resolve(urllib.unquote(url))
if len(resolved) > 1:
plugin.notify(msg="PLAY {0}".format(resolved.partition('.')[-1]), title="URLRESOLVER", delay=1000)
plugin.set_resolved_url(resolved)
item = ListItem.from_dict(path=resolved)
item.add_stream_info('video', stream_values={})
item.set_is_playable(True)
plugin.play_video(item)
return None
except:
resolved = ''
plugin.notify(msg="FAILED {0}".format(url.partition('.')[-1]), title="URLRESOLVER", delay=1000)
try:
import YDStreamExtractor
info = YDStreamExtractor.getVideoInfo(url, resolve_redirects=True)
resolved = info.streamURL()
for s in info.streams():
try:
stream_url = s['xbmc_url'].encode('utf-8', 'ignore')
xbmc.log(msg="**YOUTUBE-DL Stream found: {0}".format(stream_url))
except:
pass
if len(stream_url) > 1:
resolved = stream_url
if len(resolved) > 1:
plugin.notify(msg="Playing: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)
plugin.set_resolved_url(resolved)
item = ListItem.from_dict(path=resolved)
item.add_stream_info('video', stream_values={})
item.set_is_playable(True)
plugin.play_video(item)
return None
except:
plugin.notify(msg="Failed: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)
if len(resolved) > 1:
plugin.set_resolved_url(resolved)
item = ListItem.from_dict(path=resolved)
plugin.play_video(item)
return None
else:
plugin.set_resolved_url(url)
plugin.play_video(url)
return None
示例12: handlePush
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def handlePush(data, from_gui=False):
if not from_gui and checkForWindow(): # Do nothing if the window is open
return False
if data.get("type") == "link":
url = data.get("url", "")
if StreamExtractor.mightHaveVideo(url):
vid = StreamExtractor.getVideoInfo(url)
if vid:
if vid.hasMultipleStreams():
vlist = []
for info in vid.streams():
vlist.append(info["title"] or "?")
idx = xbmcgui.Dialog().select(common.localise(32091), vlist)
if idx < 0:
return
vid.selectStream(idx)
playMedia(vid.streamURL(), vid.title, vid.thumbnail, vid.description)
return True
if canPlayURL(url):
handleURL(url)
return True
media = getURLMediaType(url)
if media == "video" or media == "audio":
url += "|" + urllib.urlencode({"User-Agent": getURLUserAgent(url)})
playMedia(url, playlist_type="video" and xbmc.PLAYLIST_VIDEO or xbmc.PLAYLIST_MUSIC)
return True
elif media == "image":
import gui
gui.showImage(url)
return True
elif data.get("type") == "file":
if data.get("file_type", "").startswith("image/"):
import gui
gui.showImage(data.get("file_url", ""))
return True
elif data.get("file_type", "").startswith("video/") or data.get("file_type", "").startswith("audio/"):
playMedia(data.get("file_url", ""))
return True
elif data.get("type") == "note":
import gui
gui.showNote(data.get("body", ""))
return True
elif data.get("type") == "list":
import gui
gui.showList(data)
return True
elif data.get("type") == "address":
cmd = "XBMC.RunScript({0},MAP,{1},None,)".format(common.__addonid__, urllib.quote(data.get("address", "")))
xbmc.executebuiltin(cmd)
return True
return False
示例13: play_trailer
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def play_trailer(youtube_id="", listitem=None, popstack=False):
if not listitem:
listitem = xbmcgui.ListItem(xbmc.getLocalizedString(20410))
listitem.setInfo('video', {'Title': xbmc.getLocalizedString(20410), 'Genre': 'Youtube Video'})
import YDStreamExtractor
YDStreamExtractor.disableDASHVideo(True)
vid = YDStreamExtractor.getVideoInfo(youtube_id, quality=1)
if vid:
stream_url = vid.streamURL()
PlayMedia(stream_url, listitem, popstack)
示例14: play
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def play(url):
resolved = ''
stream_url = ''
item = None
try:
import urlresolver
resolved = urlresolver.HostedMediaFile(url).resolve()
if not resolved or resolved == False or len(resolved) < 1:
resolved = urlresolver.resolve(url)
if resolved is None or len(resolved) < 1:
resolved = urlresolver.resolve(urllib.unquote(url))
if len(resolved) > 1:
plugin.notify(msg="PLAY {0}".format(resolved.partition('.')[-1]), title="URLRESOLVER", delay=1000)
plugin.set_resolved_url(resolved)
item = ListItem.from_dict(path=resolved)
item.add_stream_info('video', stream_values={})
item.set_is_playable(True)
return item
except:
resolved = ''
plugin.notify(msg="FAILED {0}".format(url.partition('.')[-1]), title="URLRESOLVER", delay=1000)
try:
import YDStreamExtractor
info = YDStreamExtractor.getVideoInfo(url, resolve_redirects=True)
resolved = info.streamURL()
for s in info.streams():
try:
stream_url = s['xbmc_url'].encode('utf-8', 'ignore')
xbmc.log(msg="**YOUTUBE-DL Stream found: {0}".format(stream_url))
except:
pass
if len(stream_url) > 1:
resolved = stream_url
if len(resolved) > 1:
plugin.notify(msg="Playing: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)
plugin.set_resolved_url(resolved)
item = ListItem.from_dict(path=resolved)
item.add_stream_info('video', stream_values={})
item.set_is_playable(True)
return item
except:
plugin.notify(msg="Failed: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)
if len(resolved) > 1:
plugin.set_resolved_url(resolved)
item = ListItem.from_dict(path=resolved)
return item
else:
plugin.set_resolved_url(url) #url)
#plugurl = 'plugin://plugin.video.live.streamspro/?url={0}'.format(urllib.quote_plus(url))
#item = ListItem.from_dict(path=plugurl)
#item.add_stream_info('video', stream_values={})
#item.set_is_playable(True)
#plugin.notify(msg="RESOLVE FAIL: {0}".format(url.split('.', 1)[-1]),title="Trying {0}".format(item.path.split('.', 1)[-1]), delay=2000)
return None
示例15: PlayTrailer
# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import getVideoInfo [as 别名]
def PlayTrailer(youtube_id="", listitem=None, popstack=False):
if not listitem:
listitem =xbmcgui.ListItem ('Trailer')
listitem.setInfo('video', {'Title': 'Trailer', 'Genre': 'Youtube Video'})
import YDStreamExtractor
YDStreamExtractor.disableDASHVideo(True)
vid = YDStreamExtractor.getVideoInfo(youtube_id, quality=1)
if vid:
stream_url = vid.streamURL()
log("Youtube Trailer:" + stream_url)
PlayMedia(stream_url, listitem, popstack)