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()
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)
def playVideo(url): vid = YDStreamExtractor.getVideoInfo( url, 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 stream_url = stream_url.split('|')[0] xbmcplugin.setResolvedUrl(pluginhandle, True, xbmcgui.ListItem(path=stream_url))
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
def start_play(): kb = xbmc.Keyboard('default', 'heading', False) kb.setDefault('') kb.setHeading(enter0) kb.setHiddenInput(False) kb.doModal() if (kb.isConfirmed()): try: url = kb.getText(kb) vid = YDStreamExtractor.getVideoInfo(url, quality=1) stream_url = vid.streamURL() title = vid.selectedStream()['title'] thumbnail = vid.selectedStream()['thumbnail'] listitem = xbmcgui.ListItem(title) listitem.setInfo('video', {'Title': title}) listitem.setArt({'thumb': thumbnail, 'icon': thumbnail}) xbmc.Player().play(stream_url, listitem) except: xbmc.executebuiltin('Notification(%s, %s, %d, %s)' % (addonname, errorline2, time, infoicon)) start_menu() else: xbmc.executebuiltin('Notification(%s, %s, %d, %s)' % (addonname, errorline1, time, infoicon)) start_menu()
def application(environ, start_response): d = parse_qs(environ['QUERY_STRING']) url = d.get('url', [''])[0] usevfs = d.get('vfs', ['0'])[0] qual = d.get('qual', [0])[0] if not url: start_response('400 Bad Request') return [""] #url = "http://www.youtube.com/watch?v=DBvv2_0EV54" #a youtube ID will work as well and of course you could pass the url of another site vid = YDStreamExtractor.getVideoInfo( url, quality=qual) #quality is 0=SD, 1=720p, 2=1080p and is a maximum stream_url = vid.streamURL() #This is what Kodi (XBMC) will play if not stream_url: start_response('500 Internal server error') return [""] prot_options = stream_url.find('|') if prot_options != -1: stream_url = stream_url[:prot_options] if usevfs == '1': vfs_stream_url = "http://" + environ['SERVER_NAME'] + ":" + environ[ 'SERVER_PORT'] + "/vfs/" + urllib.quote_plus(stream_url) start_response('302 Temporary Redirect', [('Location', vfs_stream_url)]) else: start_response('302 Temporary Redirect', [('Location', stream_url)]) return [""]
def resolve(self, 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(urlquick.unquote(url)) if len(resolved) > 1: return resolved except: resolved = '' 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') except: pass if len(stream_url) > 1: resolved = stream_url if len(resolved) > 1: return resolved except: resolved = None return resolved
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]) """
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)
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
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): # vid = YDStreamExtractor.getVideoInfo(self.video.fullUrl(),quality=1)
def download_video(params): # Ici on a seulement le lien de la page web où se trouve la video # Il faut appeller la fonction get_video_url de la chaine concernée # pour avoir l'URL finale de la vidéo channel = get_channel_module(params) params.next = 'download_video' url_video = channel.get_video_url(params) # Maintenant on peut télécharger la vidéo print 'URL_VIDEO to download ' + url_video vid = YDStreamExtractor.getVideoInfo(url_video, quality=3) path = common.PLUGIN.get_setting('dlFolder') path = path.decode("utf-8").encode(common.FILESYSTEM_CODING) with YDStreamUtils.DownloadProgress() as prog: try: YDStreamExtractor.setOutputCallback(prog) result = YDStreamExtractor.downloadVideo(vid, path) if result: # success full_path_to_file = result.filepath elif result.status != 'canceled': # download failed error_message = result.message finally: YDStreamExtractor.setOutputCallback(None) return None
def get_video(self, productID): if 'yt_' in productID: yt_url = 'http://www.youtube.com/watch?v=' + productID.split( 'yt_', 1)[1] yt_video = YDStreamExtractor.getVideoInfo(yt_url, quality=3) return Item(yt_video.title, yt_video.streamURL(), yt_video.thumbnail) else: content = self.ua.get(self.get_player_init_url(productID)) link_re = re.compile("'?src'?\s*:\s+'(https?://[^']+\\.m3u8.*)'") title_re = re.compile("programName: '(.*?)',") thumb_re = re.compile("thumbnails: {[\s\n]*url: '(.*?)\$") sd_link = link_re.search(content) if sd_link is None: return None hd_link = None if self.hd_enabled: hd_link = self.try_get_hd_link(sd_link.group(1)) if hd_link: return hd_link title = title_re.search(content).group(1) thumb = None thumb_result = thumb_re.search(content) if thumb_result: thumb = thumb_result.group(1) + '010.jpg' return Item(title, sd_link.group(1), thumb)
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)
def playYoutubeVid(id, meta=None, poster=None): 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)
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)
def download_video(self): selection = xbmcgui.Dialog().select(heading=LANG(22080), list=[LANG(33003)]) if selection == 0: youtube_id = self.listitem.getProperty("youtube_id") import YDStreamExtractor vid = YDStreamExtractor.getVideoInfo(youtube_id, quality=1) YDStreamExtractor.handleDownload(vid)
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'}})
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)
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
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
def play_video(path): url = final_link vid = YDStreamExtractor.getVideoInfo(url, quality=1) play_item = xbmcgui.ListItem(path=path) stream_url = vid.streamURL() if stream_url: play_item.setPath(stream_url) xbmcplugin.setResolvedUrl(addon_handle, True, listitem=play_item)
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
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]) """
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
def playvideo(url): debug(url) vid = YDStreamExtractor.getVideoInfo(url,quality=2) #quality is 0=SD, 1=720p, 2=1080p and is a maximum debug(vid) stream_url = vid.streamURL() stream_url=stream_url.split("|")[0] listitem = xbmcgui.ListItem(path=stream_url) addon_handle = int(sys.argv[1]) xbmcplugin.setResolvedUrl(addon_handle, True, listitem)
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
def getVideo(self, episodePagePath): videoUrlRegex = re.compile( r"<iframe (?:.+?)\s+src=\"(?P<video_page>https*://www.youtube.com[-_a-zA-Z0-9\/]+)?") videoPageSource = super(Swarnavahini, self).getSource(episodePagePath) # print "video page source="+videoPageSource YDStreamExtractor.disableDASHVideo(True) video_urls = videoUrlRegex.findall(videoPageSource) url = video_urls[0] vid = YDStreamExtractor.getVideoInfo(url, quality=1) return vid.streamURL()
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)
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
def youtube_info_by_id(self, youtube_id): vid = YDStreamExtractor.getVideoInfo(youtube_id, quality=1) if not vid: return None, None listitem = xbmcgui.ListItem(label=vid.title, thumbnailImage=vid.thumbnail) listitem.setInfo(type='video', infoLabels={"genre": vid.sourceName, "plot": vid.description}) return vid.streamURL(), listitem
def playVideo(url): debug( "(playVideo) ------------------------------------------------ START = playVideo -----------------------------------------------" ) vid = YDStreamExtractor.getVideoInfo( url, quality=prefQUALITY) # quality is 0=SD, 1=720p, 2=1080p and is max stream_url = vid.streamURL() # This is what Kodi will play stream_url = stream_url.split('|')[0] xbmcplugin.setResolvedUrl(pluginhandle, True, xbmcgui.ListItem(path=stream_url))
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)
def PlayTrailer(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() log("Youtube Trailer:" + stream_url) PlayMedia(stream_url, listitem, popstack)
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
def youtube_info_by_id(self, youtube_id): vid = YDStreamExtractor.getVideoInfo(youtube_id, quality=1) if not vid: return None, None listitem = xbmcgui.ListItem(label=vid.title, thumbnailImage=vid.thumbnail) listitem.setInfo(type='video', infoLabels={ "genre": vid.sourceName, "plot": vid.description }) return vid.streamURL(), listitem
def playVideo(name, url): import YDStreamExtractor 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 # url = "https://www.youtube.com/watch?v=" + url #a youtube ID will work as well and of course you could pass the url of another site vid = YDStreamExtractor.getVideoInfo(url,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 print "stream_url =", stream_url img = " " listitem = xbmcgui.ListItem(name, iconImage=img, thumbnailImage=img) playfile = xbmc.Player() playfile.play(stream_url, listitem)
def play(url): if plugin.get_setting('debugon', converter=bool): web_pdb.set_trace() 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(WebUtils.unescape(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) return None
def play(url): if url.find('linkOut') != -1: urlout = url.split('?id=')[-1] url = base64.b64decode(urlout) resolved = '' stream_url = '' item = None try: if urlresolver is not None: stream_url = urlresolver.resolve(url) if len(stream_url) > 1: resolved = stream_url except: plugin.notify(msg="{0}".format(url), title="URLResolver FAILED", delay=1000) if len(resolved) < 1: plugin.notify(msg="{0}".format(url), title="Trying YouTube-DL", delay=1000) try: import YDStreamExtractor info = YDStreamExtractor.getVideoInfo(url, resolve_redirects=True) stream_url = info.streamURL() if len(stream_url) < 1 or stream_url.find('http') == -1: 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 else: resolved = stream_url except: plugin.notify(msg="{0}".format(url), title="YOUTUBE-DL Failed", delay=1000) if len(resolved) < 1: plugin.notify(msg="{0}".format(url), title="FAILED TO RESOLVE", delay=1000) return None else: vidurl = resolved.encode('utf-8', 'ignore') item = ListItem.from_dict(path=vidurl) item.add_stream_info('video', stream_values={}) item.set_is_playable(True) plugin.set_resolved_url(item) return plugin.play_video(item)
def play_video(path, isyoutube, isplayable): """ Play a video by the provided path. :param path: Fully-qualified video URL :type path: str :type isyoutube: bool :type isplayable: Number 0-4 """ if isplayable in ('0', '2', '3'): # unplayable item (unknown, coming soon, outdated) if isplayable == '2': if not dialogYesNo(LS(30000), LS(30067)): return elif isplayable == '3': if not dialogYesNo(LS(30000), LS(30066)): return else: return if strToBool(isyoutube): writeLog('Youtube video, invoke plugin.youtube.dl', xbmc.LOGINFO) writeLog('try to use quality factor {}'.format(yt_quality)) if YDStreamExtractor.mightHaveVideo(path, resolve_redirects=True): try: vid = YDStreamExtractor.getVideoInfo(path, quality=yt_quality, resolve_redirects=True) if vid is not None: if vid.hasMultipleStreams(): s_list = list() for stream in vid.streams(): s_list.append(stream['title']) writeLog( 'multiple streams detected: {}'.format( ', '.join(s_list)), xbmc.LOGINFO) path = vid.streamURL() else: notify(LS(30000), LS(30047), xbmcgui.NOTIFICATION_WARNING) writeLog('Could not extract video stream', xbmc.LOGERROR) except Exception as e: notify(LS(30000), LS(30047), xbmcgui.NOTIFICATION_WARNING) writeLog('youtube_dl has thrown an exception', xbmc.LOGERROR) writeLog(str(e), xbmc.LOGERROR) else: writeLog('Could not extract video stream', xbmc.LOGERROR) notify(LS(30000), LS(), xbmcgui.NOTIFICATION_WARNING) play_item = xbmcgui.ListItem(path=path) xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
def resolve(self, url): html = client.request(url) soup = webutils.bs(html) video = soup.find('iframe')['src'] if 'youtube' in video: yt_id = self.yt_video_id(video) l = 'http://www.youtube.com/watch?v=' + yt_id import YDStreamExtractor YDStreamExtractor.disableDASHVideo(True) vid = YDStreamExtractor.getVideoInfo(l, quality=1) resolved = vid.streamURL() return resolved
def playYoutubeVideo(self, youtube_id="", listitem=None, popstack=True): if not listitem: listitem = xbmcgui.ListItem(xbmc.getLocalizedString(20410)) listitem.setInfo('video', {'Title': xbmc.getLocalizedString(20410), 'Genre': 'Youtube Video'}) import YDStreamExtractor YDStreamExtractor.disableDASHVideo(True) if youtube_id: vid = YDStreamExtractor.getVideoInfo(youtube_id, quality=1) if vid: stream_url = vid.streamURL() self.play(stream_url, listitem) else: Notify("no youtube id found")
def resolve(self,url): html = client.request(url) soup = webutils.bs(html) video=soup.find('iframe')['src'] if 'youtube' in video: yt_id = self.yt_video_id(video) l = 'http://www.youtube.com/watch?v=' + yt_id import YDStreamExtractor YDStreamExtractor.disableDASHVideo(True) vid = YDStreamExtractor.getVideoInfo(l,quality=1) resolved = vid.streamURL() return resolved
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
def playYoutubeVideo(self, youtube_id="", listitem=None, popstack=True): if not listitem: listitem = xbmcgui.ListItem(xbmc.getLocalizedString(20410)) listitem.setInfo('video', {'Title': xbmc.getLocalizedString(20410), 'Genre': 'Youtube Video'}) import YDStreamExtractor YDStreamExtractor.disableDASHVideo(True) if youtube_id: vid = YDStreamExtractor.getVideoInfo(youtube_id, quality=1) if vid: stream_url = vid.streamURL() log("Youtube Trailer:" + stream_url) self.play(stream_url, listitem) else: Notify("no youtube id found")
def get_YTD(url): import YDStreamExtractor vid = YDStreamExtractor.getVideoInfo(url,resolve_redirects=True) dbg_log('- YTD: \n') if vid: dbg_log('- YTD: Try\n') stream_url = vid.streamURL() # stream_url = vid.streamURL().split('|')[0] dbg_log('- surl:'+ stream_url + '\n') else: dbg_log('- YTD: None\n') return None
def playVideo(name, url): pass#print"In playVideo url =", url import YDStreamExtractor 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 # url = "https://www.youtube.com/watch?v=" + url #a youtube ID will work as well and of course you could pass the url of another site vid = YDStreamExtractor.getVideoInfo(url,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 pass#print"stream_url =", stream_url n1 = stream_url.find("|", 0) stream_url = stream_url[:n1] pass#print"stream_url 2=", stream_url img = " " playfile = xbmc.Player() playfile.play(stream_url)
def playYoutubeVideo(self, youtube_id="", listitem=None, popstack=True): if not listitem: listitem = xbmcgui.ListItem ('Trailer') listitem.setInfo('video', {'Title': listitem.getProperty('Label'), 'Plot': listitem.getProperty('Description'), 'Genre': 'Youtube Video'}) import YDStreamExtractor YDStreamExtractor.disableDASHVideo(True) if youtube_id: vid = YDStreamExtractor.getVideoInfo(youtube_id, quality=1) if vid: stream_url = vid.streamURL() log("Youtube Trailer:" + stream_url) self.play(stream_url, listitem) else: Notify("no youtube id found")
def playVideo(name, url): import YDStreamExtractor 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 # url = "https://www.youtube.com/watch?v=" + url #a youtube ID will work as well and of course you could pass the url of another site vid = YDStreamExtractor.getVideoInfo( url, 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 print "stream_url =", stream_url img = " " listitem = xbmcgui.ListItem(name, iconImage=img, thumbnailImage=img) playfile = xbmc.Player() playfile.play(stream_url, listitem)
def play_video(self, name, kaltura_id): """ Plays a video. Keyword arguments: kaltura_id -- the Kaltura id of the video """ log('play_video, kaltura_id=%s' % kaltura_id, debug=self.debug()) self.ydl.add_default_info_extractors() ytdl_url = 'kaltura:%s:%s' % (self.partner_id, kaltura_id) log('play_video, ytdl_url=%s' % ytdl_url, debug=self.debug()) vid = YDStreamExtractor.getVideoInfo(ytdl_url, quality=2) stream_url = vid.streamURL() liz = xbmcgui.ListItem(name, path=stream_url) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
def Playvid(url, name): import YDStreamExtractor vid = YDStreamExtractor.getVideoInfo(url,quality=1) stream_url = vid.streamURL() if stream_url: iconimage = xbmc.getInfoImage("ListItem.Thumb") listitem = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage) listitem.setInfo('video', {'Title': name, 'Genre': 'Sport'}) listitem.setProperty("IsPlayable","true") if int(sys.argv[1]) == -1: pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) pl.clear() pl.add(stream_url, listitem) xbmc.Player().play(pl) else: listitem.setPath(str(stream_url)) xbmcplugin.setResolvedUrl(utils.addon_handle, True, listitem)
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_url = 'https://www.youtube.com/watch?v=' + video_id yd_video_info = YDStreamExtractor.getVideoInfo(video_url, quality=1) if yd_video_info is not None: video_info.set_video_name(yd_video_info.title) video_info.set_video_image(yd_video_info.thumbnail) video_info.add_video_link(VIDEO_QUAL_HD_720, yd_video_info.streamURL()) video_info.set_video_stopped(False) else: video_info.set_video_stopped(True) except Exception, e: Logger.logError(e) video_info.set_video_stopped(True)
def resolveURLFile(path): import YDStreamExtractor as StreamExtractor StreamExtractor.overrideParam('noplaylist', True) StreamExtractor.generateBlacklist(('.*:(?:user|channel|search)$', '(?i)generic.*')) import xbmcvfs f = xbmcvfs.File(path, 'r') try: url = f.read().strip() except: kodiutil.ERROR() return finally: f.close() vid = StreamExtractor.getVideoInfo(url) if not vid: return None return vid.streamURL()
def _StartInfoActions(self): for info in self.infos: ########### Images ##################### if info == 'xkcd': passDataToSkin('XKCD', GetXKCDInfo(), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'flickr': passDataToSkin('Flickr', GetFlickrImages(), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'cyanide': passDataToSkin('CyanideHappiness', GetCandHInfo(), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'dailybabes': passDataToSkin('DailyBabes', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) passDataToSkin('DailyBabes', GetDailyBabes(), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'dailybabe': passDataToSkin('DailyBabe', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) passDataToSkin('DailyBabe', GetDailyBabes(single=True), self.prop_prefix, self.window, self.control, self.handle, self.limit) ########### Audio ##################### elif info == 'discography': passDataToSkin('Discography', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) Discography = GetDiscography(self.ArtistName) if len(Discography) == 0: Discography = GetArtistTopAlbums(self.Artist_mbid) passDataToSkin('Discography', Discography, self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'mostlovedtracks': passDataToSkin('MostLovedTracks', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) passDataToSkin('MostLovedTracks', GetMostLovedTracks(self.ArtistName), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'artistdetails': passDataToSkin('Discography', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) passDataToSkin('MusicVideos', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) ArtistDetails = GetArtistDetails(self.ArtistName) if "audiodbid" in ArtistDetails: MusicVideos = GetMusicVideos(ArtistDetails["audiodbid"]) passDataToSkin('MusicVideos', MusicVideos, self.prop_prefix, self.window, self.control, self.handle, self.limit) passDataToSkin('Discography', GetDiscography(self.ArtistName), self.prop_prefix, self.window, self.control, self.handle, self.limit) passHomeDataToSkin(ArtistDetails, self.prop_prefix) elif info == 'albuminfo': if self.id: AlbumDetails = GetAlbumDetails(self.id) Trackinfo = GetTrackDetails(self.id) passHomeDataToSkin(AlbumDetails, self.prop_prefix) passDataToSkin('Trackinfo', Trackinfo, self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'albumshouts': passDataToSkin('Shout', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.ArtistName and self.AlbumName: passDataToSkin('Shout', GetAlbumShouts(self.ArtistName, self.AlbumName), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'artistshouts': passDataToSkin('Shout', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.ArtistName: passDataToSkin('Shout', GetArtistShouts(self.ArtistName), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'topartists': passDataToSkin('TopArtists', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) passDataToSkin('TopArtists', GetTopArtists(), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'hypedartists': passDataToSkin('HypedArtists', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) passDataToSkin('HypedArtists', GetHypedArtists(), self.prop_prefix, self.window, self.control, self.handle, self.limit) ### RottenTomatoesMovies ################################################################################# elif info == 'intheaters': passDataToSkin('InTheatersMovies', GetRottenTomatoesMovies("movies/in_theaters"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'boxoffice': passDataToSkin('BoxOffice', GetRottenTomatoesMovies("movies/box_office"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'opening': passDataToSkin('Opening', GetRottenTomatoesMovies("movies/opening"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'comingsoon': passDataToSkin('ComingSoonMovies', GetRottenTomatoesMovies("movies/upcoming"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'toprentals': passDataToSkin('TopRentals', GetRottenTomatoesMovies("dvds/top_rentals"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'currentdvdreleases': passDataToSkin('CurrentDVDs', GetRottenTomatoesMovies("dvds/current_releases"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'newdvdreleases': passDataToSkin('NewDVDs', GetRottenTomatoesMovies("dvds/new_releases"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'upcomingdvds': passDataToSkin('UpcomingDVDs', GetRottenTomatoesMovies("dvds/upcoming"), self.prop_prefix, self.window, self.control, self.handle, self.limit) ### The MovieDB ########################################################################################## elif info == 'incinemas': passDataToSkin('InCinemasMovies', GetMovieDBMovies("now_playing"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'upcoming': passDataToSkin('UpcomingMovies', GetMovieDBMovies("upcoming"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'topratedmovies': passDataToSkin('TopRatedMovies', GetMovieDBMovies("top_rated"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'popularmovies': passDataToSkin('PopularMovies', GetMovieDBMovies("popular"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'airingtodaytvshows': passDataToSkin('AiringTodayTVShows', GetMovieDBTVShows("airing_today"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'onairtvshows': passDataToSkin('OnAirTVShows', GetMovieDBTVShows("on_the_air"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'topratedtvshows': passDataToSkin('TopRatedTVShows', GetMovieDBTVShows("top_rated"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'populartvshows': passDataToSkin('PopularTVShows', GetMovieDBTVShows("popular"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'similarmovies': passDataToSkin('SimilarMovies', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.id: MovieId = self.id elif self.dbid and (int(self.dbid) > -1): MovieId = GetImdbID("movie", self.dbid) log("IMDBId from local DB:" + str(MovieId)) else: MovieId = "" if MovieId: passDataToSkin('SimilarMovies', GetSimilarMovies(MovieId), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'studio': passDataToSkin('StudioInfo', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.studio: CompanyId = SearchforCompany(self.studio) passDataToSkin('StudioInfo', GetCompanyInfo(CompanyId), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'set': passDataToSkin('MovieSetItems', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.dbid and not "show" in str(self.type): name = GetMovieSetName(self.dbid) if name: self.setid = SearchForSet(name) if self.setid: SetData = GetSetMovies(self.setid) if SetData: passDataToSkin('MovieSetItems', SetData, self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'movielists': passDataToSkin('MovieLists', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.dbid: movieid = GetImdbID("movie", self.dbid) log("MovieDB Id:" + str(movieid)) if movieid: passDataToSkin('MovieLists', GetMovieLists(movieid), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'keywords': passDataToSkin('Keywords', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.dbid: movieid = GetImdbID("movie", self.dbid) log("MovieDB Id:" + str(movieid)) if movieid: passDataToSkin('Keywords', GetMovieKeywords(movieid), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'popularpeople': passDataToSkin('PopularPeople', GetPopularActorList(), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'extendedinfo': from DialogVideoInfo import DialogVideoInfo if self.handle: xbmcplugin.endOfDirectory(self.handle) dialog = DialogVideoInfo(u'script-%s-DialogVideoInfo.xml' % __addonname__, __cwd__, id=self.id, dbid=self.dbid, imdbid=self.imdbid, name=self.name) dialog.doModal() elif info == 'extendedactorinfo': from DialogActorInfo import DialogActorInfo dialog = DialogActorInfo(u'script-%s-DialogInfo.xml' % __addonname__, __cwd__, id=self.id, name=self.name) dialog.doModal() elif info == 'extendedtvinfo': if self.id: tvshowinfo = GetTVShowInfo(self.id) if tvshowinfo: # prettyprint(tvshowinfo) passHomeDataToSkin(tvshowinfo[0], self.prop_prefix) elif info == 'seasoninfo': passDataToSkin("SeasonVideos", None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.tvshow and self.season: seasoninfo, videos = GetSeasonInfo(self.tvshow, self.season) passHomeDataToSkin(seasoninfo, self.prop_prefix) passDataToSkin("SeasonVideos", videos, self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'directormovies': passDataToSkin('DirectorMovies', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.director: directorid = GetPersonID(self.director) if directorid: passDataToSkin('DirectorMovies', GetDirectorMovies(directorid), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'writermovies': passDataToSkin('WriterMovies', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.writer and not self.writer.split(" / ")[0] == self.director.split(" / ")[0]: writerid = GetPersonID(self.writer) if writerid: passDataToSkin('WriterMovies', GetDirectorMovies(writerid), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'similarmoviestrakt': passDataToSkin('SimilarTrakt', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if (self.id or self.dbid): if self.dbid: movieid = GetImdbID("movie", self.dbid) else: movieid = self.id passDataToSkin('SimilarMovies', GetSimilarTrakt("movie", movieid), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'similartvshowstrakt': passDataToSkin('SimilarTrakt', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if (self.id or self.dbid): if self.dbid: if self.type == "episode": tvshowid = GetImdbIDfromEpisode(self.dbid) else: tvshowid = GetImdbID("tvshow", self.dbid) else: tvshowid = self.id passDataToSkin('SimilarTVShows', GetSimilarTrakt("show", tvshowid), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'airingshows': passDataToSkin('AiringShows', GetTraktCalendarShows("shows"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'premiereshows': passDataToSkin('PremiereShows', GetTraktCalendarShows("premieres"), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'trendingshows': passDataToSkin('TrendingShows', GetTrendingShows(), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'trendingmovies': passDataToSkin('TrendingMovies', GetTrendingMovies(), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'similarartistsinlibrary': passDataToSkin('SimilarArtists', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.Artist_mbid: passDataToSkin('SimilarArtists', GetSimilarArtistsInLibrary(self.Artist_mbid), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'artistevents': passDataToSkin('ArtistEvents', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.Artist_mbid: passDataToSkin('ArtistEvents', GetEvents(self.Artist_mbid), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'youtubesearch': homewindow.setProperty('%sSearchValue' % self.prop_prefix, self.id) # set properties passDataToSkin('YoutubeSearch', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.id: passDataToSkin('YoutubeSearch', GetYoutubeSearchVideosV3(self.id, self.hd, self.orderby), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'youtubeplaylist': passDataToSkin('YoutubePlaylist', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.id: passDataToSkin('YoutubePlaylist', GetYoutubePlaylistVideos(self.id), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'youtubeusersearch': passDataToSkin('YoutubeUserSearch', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.id: passDataToSkin('YoutubeUserSearch', GetYoutubeUserVideos(self.id), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'nearevents': passDataToSkin('NearEvents', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) passDataToSkin('NearEvents', GetNearEvents(self.tag, self.festivalsonly, self.lat, self.lon, self.location, self.distance), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'trackinfo': homewindow.setProperty('%sSummary' % self.prop_prefix, "") # set properties if self.ArtistName and self.TrackName: TrackInfo = GetTrackInfo(self.ArtistName, self.TrackName) homewindow.setProperty('%sSummary' % self.prop_prefix, TrackInfo["summary"]) # set properties elif info == 'venueevents': passDataToSkin('VenueEvents', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) if self.location: self.id = GetVenueID(self.location) if self.id: passDataToSkin('VenueEvents', GetVenueEvents(self.id), self.prop_prefix, self.window, self.control, self.handle, self.limit) else: Notify("Error", "Could not find venue") elif info == 'topartistsnearevents': passDataToSkin('TopArtistsNearEvents', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) artists = GetXBMCArtists() events = GetArtistNearEvents(artists["result"]["artists"][0:49]) passDataToSkin('TopArtistsNearEvents', events, self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'channels': channels = create_channel_list() # prettyprint(channels) elif info == 'favourites': if self.id: favourites = GetFavouriteswithType(self.id) else: favourites = GetFavourites() homewindow.setProperty('favourite.count', str(len(favourites))) if len(favourites) > 0: homewindow.setProperty('favourite.1.name', favourites[-1]["Label"]) passDataToSkin('Favourites', favourites, self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'json': passDataToSkin('RSS', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) videos = GetYoutubeVideos(self.feed, self.prop_prefix) passDataToSkin('RSS', videos, self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'similarlocal' and self.dbid: passDataToSkin('SimilarLocalMovies', None, self.prop_prefix, self.window, self.control, self.handle, self.limit) passDataToSkin('SimilarLocalMovies', GetSimilarFromOwnLibrary(self.dbid), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'iconpanel': passDataToSkin('IconPanel', GetIconPanel(1), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'weather': passDataToSkin('WeatherImages', GetWeatherImages(), self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'updatexbmcdatabasewithartistmbidbg': SetMusicBrainzIDsForAllArtists(False, False) elif info == 'setfocus': self.control = "" # workaround to avoid breaking PlayMedia xbmc.executebuiltin("SetFocus(22222)") elif info == 'playliststats': GetPlaylistStats(self.id) elif info == "sortletters": listitems = GetSortLetters(self.path, self.id) passDataToSkin('SortLetters', listitems, self.prop_prefix, self.window, self.control, self.handle, self.limit) elif info == 'slideshow': windowid = xbmcgui.getCurrentWindowId() Window = xbmcgui.Window(windowid) focusid = Window.getFocusId() itemlist = Window.getFocus() numitems = itemlist.getSelectedPosition() log("items:" + str(numitems)) for i in range(0, numitems): Notify(item.getProperty("Image")) elif info == 'action': xbmc.executebuiltin(self.id) elif info == "youtubevideo": if self.id: self.control = "" # workaround to avoid breaking PlayMedia import YDStreamExtractor YDStreamExtractor.disableDASHVideo(True) vid = YDStreamExtractor.getVideoInfo(self.id, quality=1) stream_url = vid.streamURL() log("Youtube Trailer:" + stream_url) xbmc.executebuiltin("PlayMedia(%s)" % stream_url) elif info == 'playtrailer': xbmc.executebuiltin("ActivateWindow(busydialog)") xbmc.sleep(500) if self.id: MovieId = self.id elif self.dbid and (int(self.dbid) > -1): MovieId = GetImdbID("movie", self.dbid) log("MovieDBID from local DB:" + str(MovieId)) elif self.imdbid: MovieId = GetMovieDBID(self.imdbid) else: MovieId = "" if MovieId: trailer = GetTrailer(MovieId) xbmc.executebuiltin("Dialog.Close(busydialog)") if trailer: xbmc.executebuiltin("PlayMedia(%s)" % trailer) self.control = "" # workaround to avoid breaking PlayMedia else: Notify("Error", "No Trailer available") elif info == 'updatexbmcdatabasewithartistmbid': SetMusicBrainzIDsForAllArtists(True, False)
def onClick(self, controlID): homewindow.setProperty("WindowColor", xbmc.getInfoLabel("Window(home).Property(movie.ImageColor)")) if controlID in [50, 750]: actorid = self.getControl(controlID).getSelectedItem().getProperty("id") AddToWindowStack("video", self.MovieId) dialog = DialogActorInfo.DialogActorInfo(u'script-%s-DialogInfo.xml' % __addonname__, __cwd__, id=actorid) self.close() dialog.doModal() elif controlID in [150, 250]: movieid = self.getControl(controlID).getSelectedItem().getProperty("id") self.close() AddToWindowStack("video", self.MovieId) dialog = DialogVideoInfo(u'script-%s-DialogVideoInfo.xml' % __addonname__, __cwd__, id=movieid) dialog.doModal() elif controlID == 350: listitem = self.getControl(350).getSelectedItem() import YDStreamExtractor YDStreamExtractor.disableDASHVideo(True) vid = YDStreamExtractor.getVideoInfo(listitem.getProperty("youtube_id"), quality=1) stream_url = vid.streamURL() self.close() log("Youtube Trailer:" + stream_url) xbmc.executebuiltin("PlayMedia(%s)" % stream_url) elif controlID == 550: xbmc.executebuiltin("ActivateWindow(busydialog)") studioitems = GetCompanyInfo(self.getControl(controlID).getSelectedItem().getProperty("id")) AddToWindowStack("video", self.MovieId) self.close() dialog = DialogVideoList.DialogVideoList(u'script-%s-VideoList.xml' % __addonname__, __cwd__, listitems=studioitems) xbmc.executebuiltin("Dialog.Close(busydialog)") dialog.doModal() elif controlID == 950: xbmc.executebuiltin("ActivateWindow(busydialog)") keywordid = self.getControl(controlID).getSelectedItem().getProperty("id") keyworditems = GetMoviesWithKeyword(keywordid) AddToWindowStack("video", self.MovieId) self.close() xbmc.executebuiltin("Dialog.Close(busydialog)") dialog = DialogVideoList.DialogVideoList(u'script-%s-VideoList.xml' % __addonname__, __cwd__, listitems=keyworditems) dialog.doModal() elif controlID == 850: xbmc.executebuiltin("ActivateWindow(busydialog)") genreid = self.getControl(controlID).getSelectedItem().getProperty("id") genreitems = GetMoviesWithGenre(genreid) AddToWindowStack("video", self.MovieId) self.close() dialog = DialogVideoList.DialogVideoList(u'script-%s-VideoList.xml' % __addonname__, __cwd__, listitems=genreitems) xbmc.executebuiltin("Dialog.Close(busydialog)") dialog.doModal() elif controlID == 650: xbmc.executebuiltin("ActivateWindow(busydialog)") country = self.getControl(controlID).getSelectedItem().getProperty("iso_3166_1") certification = self.getControl(controlID).getSelectedItem().getProperty("certification") cert_items = GetMoviesWithCertification(country, certification) AddToWindowStack("video", self.MovieId) self.close() dialog = DialogVideoList.DialogVideoList(u'script-%s-VideoList.xml' % __addonname__, __cwd__, listitems=cert_items) xbmc.executebuiltin("Dialog.Close(busydialog)") dialog.doModal() elif controlID == 450: xbmc.executebuiltin("ActivateWindow(busydialog)") list_items = GetMoviesFromList(self.getControl(controlID).getSelectedItem().getProperty("id")) self.close() AddToWindowStack("video", self.MovieId) dialog = DialogVideoList.DialogVideoList(u'script-%s-VideoList.xml' % __addonname__, __cwd__, listitems=list_items) xbmc.executebuiltin("Dialog.Close(busydialog)") dialog.doModal()
def download_video(youtube_id): vid = YDStreamExtractor.getVideoInfo(youtube_id, quality=1) YDStreamExtractor.handleDownload(vid)
def get_youtube_info(youtube_id): return YDStreamExtractor.getVideoInfo(youtube_id, quality=1)