def _handleDownload(info,path=None,duration=None,bg=False): path = path or StreamUtils.getDownloadPath(use_default=True) if bg: downloader = StreamUtils.DownloadProgressBG else: downloader = StreamUtils.DownloadProgress with downloader(line1='Starting download...') as prog: try: setOutputCallback(prog.updateCallback) _setDownloadDuration(duration) result = download(info,util.TMP_PATH) finally: setOutputCallback(None) _setDownloadDuration(duration) if not result and result.status != 'canceled': StreamUtils.showMessage(StreamUtils.T(32013),result.message,bg=bg) elif result: StreamUtils.showMessage(StreamUtils.T(32011),StreamUtils.T(32012),'',result.filepath,bg=bg) filePath = result.filepath if os.path.exists(result.filepath + '.part'): os.rename(result.filepath + '.part',result.filepath) StreamUtils.moveFile(filePath,path,filename=info.get('filename')) return result
def progressCallback(self,info): if xbmc.abortRequested: raise DownloadCanceledException('abortRequested') if not _CALLBACK: return #'downloaded_bytes': byte_counter, #'total_bytes': data_len, #'tmpfilename': tmpfilename, #'filename': filename, #'status': 'downloading', #'eta': eta, #'speed': speed sofar = info.get('downloaded_bytes') total = info.get('total_bytes') if info.get('filename'): self._lastDownloadedFilePath = info.get('filename') pct = '' pct_val = 0 if sofar != None and total: pct_val = int((float(sofar)/total) * 100) pct = ' (%s%%)' % pct_val eta = info.get('eta') or '' eta_str = '' if eta: eta_str = StreamUtils.durationToShortText(eta) eta = ' ETA: ' + eta_str speed = info.get('speed') or '' speed_str = '' if speed: speed_str = StreamUtils.simpleSize(speed) + 's' speed = ' ' + speed_str status = '%s%s:' % (info.get('status','?').title(),pct) text = CallbackMessage(status + eta + speed, pct_val, eta_str, speed_str, info) ok = self.showMessage(text) if not ok: LOG('Download canceled') raise DownloadCanceledException()
def handleURL(url): protocol = url.split("://", 1)[0] if protocol in protocolURLs: pluginURL = protocolURLs[protocol].format(url=url) StreamUtils.play(pluginURL) """{u'iden': u'ujxCHwc6fiSsjAl11HK7y0',
def progressCallback(self, info): global _DOWNLOAD_CANCEL if self._monitor.abortRequested() or _DOWNLOAD_CANCEL: _DOWNLOAD_CANCEL = False raise DownloadCanceledException('abortRequested') if _DOWNLOAD_DURATION: if time.time() - _DOWNLOAD_START > _DOWNLOAD_DURATION: raise DownloadCanceledException('duration_reached') if not _CALLBACK: return # 'downloaded_bytes': byte_counter, # 'total_bytes': data_len, # 'tmpfilename': tmpfilename, # 'filename': filename, # 'status': 'downloading', # 'eta': eta, # 'speed': speed sofar = info.get('downloaded_bytes') total = info.get('total_bytes') or info.get('total_bytes_estimate') if info.get('filename'): self._lastDownloadedFilePath = info.get('filename') pct = '' pct_val = 0 eta = None if sofar is not None and total: pct_val = int((float(sofar) / total) * 100) pct = ' (%s%%)' % pct_val elif _DOWNLOAD_DURATION: sofar = time.time() - _DOWNLOAD_START eta = _DOWNLOAD_DURATION - sofar pct_val = int((float(sofar) / _DOWNLOAD_DURATION) * 100) eta = eta or info.get('eta') or '' eta_str = '' if eta: eta_str = StreamUtils.durationToShortText(eta) eta = ' ETA: ' + eta_str speed = info.get('speed') or '' speed_str = '' if speed: speed_str = StreamUtils.simpleSize(speed) + 's' speed = ' ' + speed_str status = '%s%s:' % (info.get('status', '?').title(), pct) text = CallbackMessage(status + eta + speed, pct_val, eta_str, speed_str, info) ok = self.showMessage(text) if not ok: util.LOG('Download canceled') raise DownloadCanceledException()
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 mediaPlaying(): #TODO: make sure we're checking for all media return StreamUtils.isPlaying() # xbmc.executeJSONRPC('{"jsonrpc":"2.0","id":1,"method":"Playlist.Clear","params":{"playlistid":1}}') # xbmc.executeJSONRPC('{"jsonrpc":"2.0","id":1,"method":"Playlist.Add","params":{"playlistid":1,"item":{"file":"' + str(url) + '"}}}') # return xbmc.executeJSONRPC('{"jsonrpc":"2.0","id":1,"method":"Player.Open","params":{"item":{"playlistid":1,"position":0}}}') '''{u'iden': u'ujxCHwc6fiSsjAl11HK7y0',
def start(self,path): interrupted = None if getSetting('video_return_interrupt',True): interrupted = StreamUtils.current() self.getCurrentTime() self.interrupted = interrupted self.doPlay(path)
def progressCallback(self, info): global _DOWNLOAD_CANCEL if xbmc.abortRequested or _DOWNLOAD_CANCEL: _DOWNLOAD_CANCEL = False raise DownloadCanceledException("abortRequested") if _DOWNLOAD_DURATION: if time.time() - _DOWNLOAD_START > _DOWNLOAD_DURATION: raise DownloadCanceledException("duration_reached") if not _CALLBACK: return # 'downloaded_bytes': byte_counter, # 'total_bytes': data_len, # 'tmpfilename': tmpfilename, # 'filename': filename, # 'status': 'downloading', # 'eta': eta, # 'speed': speed sofar = info.get("downloaded_bytes") total = info.get("total_bytes") if info.get("filename"): self._lastDownloadedFilePath = info.get("filename") pct = "" pct_val = 0 eta = None if sofar is not None and total: pct_val = int((float(sofar) / total) * 100) pct = " (%s%%)" % pct_val elif _DOWNLOAD_DURATION: sofar = time.time() - _DOWNLOAD_START eta = _DOWNLOAD_DURATION - sofar pct_val = int((float(sofar) / _DOWNLOAD_DURATION) * 100) eta = eta or info.get("eta") or "" eta_str = "" if eta: eta_str = StreamUtils.durationToShortText(eta) eta = " ETA: " + eta_str speed = info.get("speed") or "" speed_str = "" if speed: speed_str = StreamUtils.simpleSize(speed) + "s" speed = " " + speed_str status = "%s%s:" % (info.get("status", "?").title(), pct) text = CallbackMessage(status + eta + speed, pct_val, eta_str, speed_str, info) ok = self.showMessage(text) if not ok: util.LOG("Download canceled") raise DownloadCanceledException()
def progressCallback(self, info): global _DOWNLOAD_CANCEL if xbmc.abortRequested or _DOWNLOAD_CANCEL: _DOWNLOAD_CANCEL = False raise DownloadCanceledException('abortRequested') if _DOWNLOAD_DURATION: if time.time() - _DOWNLOAD_START > _DOWNLOAD_DURATION: raise DownloadCanceledException('duration_reached') if not _CALLBACK: return # 'downloaded_bytes': byte_counter, # 'total_bytes': data_len, # 'tmpfilename': tmpfilename, # 'filename': filename, # 'status': 'downloading', # 'eta': eta, # 'speed': speed sofar = info.get('downloaded_bytes') total = info.get('total_bytes') or info.get('total_bytes_estimate') if info.get('filename'): self._lastDownloadedFilePath = info.get('filename') pct = '' pct_val = 0 eta = None if sofar is not None and total: pct_val = int((float(sofar) / total) * 100) pct = ' (%s%%)' % pct_val elif _DOWNLOAD_DURATION: sofar = time.time() - _DOWNLOAD_START eta = _DOWNLOAD_DURATION - sofar pct_val = int((float(sofar) / _DOWNLOAD_DURATION) * 100) eta = eta or info.get('eta') or '' eta_str = '' if eta: eta_str = StreamUtils.durationToShortText(eta) eta = ' ETA: ' + eta_str speed = info.get('speed') or '' speed_str = '' if speed: speed_str = StreamUtils.simpleSize(speed) + 's' speed = ' ' + speed_str status = '%s%s:' % (info.get('status', '?').title(), pct) text = CallbackMessage(status + eta + speed, pct_val, eta_str, speed_str, info) ok = self.showMessage(text) if not ok: util.LOG('Download canceled') raise DownloadCanceledException()
def mediaPlaying(): # TODO: make sure we're checking for all media return StreamUtils.isPlaying() # xbmc.executeJSONRPC('{"jsonrpc":"2.0","id":1,"method":"Playlist.Clear","params":{"playlistid":1}}') # xbmc.executeJSONRPC('{"jsonrpc":"2.0","id":1,"method":"Playlist.Add","params":{"playlistid":1,"item":{"file":"' + str(url) + '"}}}') # return xbmc.executeJSONRPC('{"jsonrpc":"2.0","id":1,"method":"Player.Open","params":{"item":{"playlistid":1,"position":0}}}') """{u'iden': u'ujxCHwc6fiSsjAl11HK7y0',
def _handleDownload(info, path=None, duration=None, bg=False): path = path or StreamUtils.getDownloadPath(use_default=True) if bg: downloader = StreamUtils.DownloadProgressBG else: downloader = StreamUtils.DownloadProgress with downloader(line1='Starting download...') as prog: try: setOutputCallback(prog.updateCallback) _setDownloadDuration(duration) result = download(info, util.TMP_PATH) finally: setOutputCallback(None) _setDownloadDuration(duration) if not result and result.status != 'canceled': StreamUtils.showMessage(StreamUtils.T(32013), result.message, bg=bg) elif result: StreamUtils.showMessage(StreamUtils.T(32011), StreamUtils.T(32012), '', result.filepath, bg=bg) filePath = result.filepath part = result.filepath + u'.part' try: if os.path.exists(part): os.rename(part, result.filepath) except UnicodeDecodeError: part = part.encode('utf-8') if os.path.exists(part): os.rename(part, result.filepath) StreamUtils.moveFile(filePath, path, filename=info.get('filename')) return result
def getCurrentTime(self): if not StreamUtils.isPlaying(): return None offset = getSetting('video_resume_offset',0) val = self.getTime() - offset if val < 0: val = 0 (ms,tsec) = math.modf(val) m, s = divmod(int(tsec), 60) h, m = divmod(m, 60) self.currentTime = (h,m,s,int(ms*1000))
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 handleDownload(info, duration=None, bg=False, path=None): """ Download the selected video in vidinfo to a path the user chooses. Displays a progress dialog and ok/error message when finished. Set bg=True to download in the background. Returns a DownloadResult object for foreground transfers. """ info = _convertInfo(info) path = StreamUtils.getDownloadPath() if bg: servicecontrol.ServiceControl().download(info, path, duration) else: return _handleDownload(info, path, duration=duration, bg=False)
def notify(self,message='',header='Forum Browser',ntype='all'): if StreamUtils.isPlaying(): method = self.notifyMethodVideo else: method = self.notifyMethod if method == 'normal' and ntype == 'single': mtime=self.notifyXbmcDuration image=util.__addon__.getAddonInfo('icon') util.showNotice(header,message,mtime,image) elif method != 'normal' and ntype == 'all': if getSetting('FBIsRunning',False): signals.sendSignal('NEW_POSTS') return forumsManager(size=method)
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 youtubeDLDownload(self,vid,path,target=None): import YDStreamExtractor as StreamExtractor import YDStreamUtils as StreamUtils if not target: target = self.chooseDirectory() if not target: return with StreamUtils.DownloadProgress() as prog: try: StreamExtractor.disableDASHVideo(True) StreamExtractor.setOutputCallback(prog) result = StreamExtractor.downloadVideo(vid,path) finally: StreamExtractor.setOutputCallback(None) if not result and result.status != 'canceled': xbmcgui.Dialog().ok(T(32103),'[CR]',result.message) elif result: xbmcgui.Dialog().ok(T(32062),T(32104),'[CR]',result.filepath) if target: xbmcvfs.copy(result.filepath,os.path.join(target,os.path.basename(result.filepath))) xbmcvfs.delete(result.filepath)
def downloadyoutube(file, ffdir=""): debug("Start downloadyoutube") # if FFmpeg is defined use it also at youtube-dl if not ffdir == "": YDStreamExtractor.overrideParam('ffmpeg_location', ffdir) # download video YDStreamExtractor.overrideParam('preferedformat', "avi") vid = YDStreamExtractor.getVideoInfo(file, quality=2) with YDStreamUtils.DownloadProgress( ) as prog: # this creates a progress dialog interface ready to use try: YDStreamExtractor.setOutputCallback(prog) result = YDStreamExtractor.downloadVideo(vid, folder) if result: full_path_to_file = result.filepath elif result.status != 'canceled': error_message = result.message finally: YDStreamExtractor.setOutputCallback(None)
def handleDownload(vidinfo): """ Download the selected video in vidinfo to a path the user chooses. Displays a progress dialog and ok/error message when finished. Returns a DownloadResult object. """ path = StreamUtils.getDownloadPath() with StreamUtils.DownloadProgress() as prog: try: setOutputCallback(prog.updateCallback) result = downloadVideo(vidinfo,StreamUtils.TMP_PATH) finally: setOutputCallback(None) if not result and result.status != 'canceled': StreamUtils.showMessage(StreamUtils.T(32013),result.message) elif result: StreamUtils.showMessage(StreamUtils.T(32011),StreamUtils.T(32012),'',result.filepath) StreamUtils.moveFile(result.filepath,path) return result
def runServer(self): while self.targetsBox.ready() and not xbmc.abortRequested: self.targetsBox.join() if self.targetsBox.device.hasPush(): if self.instantPlay: if not StreamUtils.isPlaying() or self.interruptMedia: data = self.targetsBox.device.getNext() if data: pushhandler.handlePush(data) else: if self.showNotification: data = self.targetsBox.device.getNext() if data: util.notify( '{0}: {1}'.format(util.T(32090), data.get('type', '?')), data.get('title', '')) self.targetsBox.device.clear() xbmc.sleep(200) self.targetsBox.close() self.targetsBox = None
def runServer(self): while self.targetsBox.ready() and not xbmc.abortRequested: self.targetsBox.join() if self.targetsBox.device.hasPush(): if self.instantPlay: if not StreamUtils.isPlaying() or self.interruptMedia: data = self.targetsBox.device.getNext() if data: pushhandler.handlePush(data) else: if self.showNotification: data = self.targetsBox.device.getNext() if data: util.notify( '{0}: {1}'.format(util.T(32090),data.get('type','?')), data.get('title','') ) self.targetsBox.device.clear() xbmc.sleep(200) self.targetsBox.close() self.targetsBox = None
def playInterrupted(self): if not self.isSelfPlaying: return self.isSelfPlaying = False if self.interrupted: LOG('PLAYER: Playing interrupted video') if getSetting('video_bypass_resume_dialog',True) and self.currentTime: try: xbmc.sleep(1000) StreamUtils.playAt(self.interrupted, *self.currentTime) except: ERROR('PLAYER: Failed manually resume video - sending to XBMC') xbmc.sleep(1000) StreamUtils.play(self.interrupted) else: xbmc.sleep(1000) StreamUtils.play(self.interrupted,getSetting('video_resume_as_preview',False)) self.interrupted = None self.currentTime = None
kodi_player.play(path,listitem) time.sleep(10) videoda=0 while videoda==0 : try: file=kodi_player.getPlayingFile() debug("-----> "+file) if not file=="": videoda=1 except: pass debug("Start Download") debug("FILE :"+file) YDStreamExtractor.overrideParam('ffmpeg_location',ffmpg) YDStreamExtractor.overrideParam('preferedformat',"avi") #YDStreamExtractor.overrideParam('title',title) vid = YDStreamExtractor.getVideoInfo(file,quality=int(quality)) #kodi_player.stop() with YDStreamUtils.DownloadProgress() as prog: #This gives a progress dialog interface ready to use try: YDStreamExtractor.setOutputCallback(prog) result = YDStreamExtractor.downloadVideo(vid,folder) if result: #success full_path_to_file = result.filepath elif result.status != 'canceled': #download failed error_message = result.message finally: YDStreamExtractor.setOutputCallback(None)
def play_video(iurl, dl=False): """ Play a video by the provided path. :param path: str """ streamer_list = [ 'tamilgun', 'mersalaayitten', 'mhdtvlive.', '/hls/', 'poovee.', 'watchtamiltv.', 'cloudspro.', 'abroadindia.', 'nextvnow.', 'akamaihd.', 'hindigeetmala.', '.mp4', 'googlevideo.', 'tmvplay.', 'playembed.', 'tamilhdtv.', 'andhrawatch.', 'tamiltv.', 'thoptv.', 'athavantv', 'justmoviesonline.', '.mp3', 'googleapis.', '.m3u8', 'telugunxt.', 'ozee.', 'bharat-movies.', 'googleusercontent.', 'hyfytv.' ] # Create a playable item with a path to play. title = 'unknown' if 'ZZZZ' in iurl: iurl, title = iurl.split('ZZZZ') play_item = xbmcgui.ListItem(path=iurl) vid_url = play_item.getfilename() #xbmc.log("DeccanDelight vid_url = %s" %vid_url,xbmc.LOGNOTICE) if any([x in vid_url for x in streamer_list]): if 'mersalaayitten' in vid_url: scraper = mersal.mersal() stream_url, srtfile = scraper.get_video(vid_url) play_item.setPath(stream_url) if srtfile: play_item.setSubtitles(['special://temp/mersal.srt', srtfile]) elif 'athavantv.' in vid_url: scraper = lyca.lyca() stream_url = scraper.get_video(vid_url) play_item.setPath(stream_url) elif 'hindigeetmala.' in vid_url: scraper = gmala.gmala() stream_url = scraper.get_video(vid_url) if stream_url: if 'youtube.' in stream_url: stream_url = resolve_url(stream_url) play_item.setPath(stream_url) elif 'telugunxt.' in vid_url: scraper = tflame.tflame() stream_url = scraper.get_video(vid_url) if stream_url: stream_url = resolve_url(stream_url) if stream_url: play_item.setPath(stream_url) else: play_item.setPath(None) elif 'bharat-movies.' in vid_url: scraper = bmov.bmov() stream_url = scraper.get_video(vid_url) if stream_url: stream_url = resolve_url(stream_url) if stream_url: play_item.setPath(stream_url) else: play_item.setPath(None) elif 'tamilgun.' in vid_url: scraper = tgun.tgun() stream_url = scraper.get_video(vid_url) if stream_url: play_item.setPath(stream_url) elif ('tmvplay.' in vid_url) and ('data=' not in vid_url): scraper = tmvp.tmvp() stream_url = scraper.get_video(vid_url) if stream_url: play_item.setPath(stream_url) elif 'ozee.' in vid_url: scraper = ozee.ozee() stream_url = scraper.get_video(vid_url) if stream_url: play_item.setPath(stream_url) elif 'andhrawatch.' in vid_url: scraper = awatch.awatch() stream_url = scraper.get_video(vid_url) if stream_url: if 'youtube.' in stream_url: stream_url = resolve_url(stream_url) play_item.setPath(stream_url) elif 'tamiltv.site' in vid_url: scraper = tamiltv.tamiltv() stream_url = scraper.get_video(vid_url) if stream_url: if 'youtube.' in stream_url: stream_url = resolve_url(stream_url) play_item.setPath(stream_url) elif 'thoptv.' in vid_url: scraper = thop.thop() stream_url = scraper.get_video(vid_url) play_item.setPath(stream_url) elif 'hyfytv.' in vid_url: scraper = hyfy.hyfy() stream_url = scraper.get_video(vid_url) play_item.setPath(stream_url) elif 'nextvnow.' in vid_url: scraper = nextv.nextv() stream_url = scraper.get_video(vid_url) play_item.setPath(stream_url) elif 'mhdtvlive.' in vid_url: scraper = mhdtv.mhdtv() stream_url = scraper.get_video(vid_url) if 'youtube.' in stream_url: stream_url = resolve_url(stream_url) if stream_url: play_item.setPath(stream_url) else: play_item.setPath(None) elif 'playembed.' in vid_url or '.m3u8' in vid_url: stream_url = vid_url play_item.setPath(stream_url) elif 'abroadindia.' in vid_url: scraper = aindia.aindia() stream_url = scraper.get_video(vid_url) if stream_url: if 'youtube.' in stream_url: stream_url = resolve_url(stream_url) elif '.f4m' in stream_url: qurl = urllib.quote_plus(stream_url) stream_url = 'plugin://plugin.video.f4mTester/?streamtype=HDS&url=%s' % qurl elif '.ts' in stream_url: qurl = urllib.quote_plus(stream_url) stream_url = 'plugin://plugin.video.f4mTester/?streamtype=TSDOWNLOADER&url=%s' % qurl if stream_url: play_item.setPath(stream_url) else: play_item.setPath(None) elif 'load.' in vid_url: stream_url = resolve_url(vid_url) if stream_url: play_item.setPath(stream_url) else: play_item.setPath(None) else: stream_url = vid_url play_item.setPath(stream_url) else: stream_url = resolve_url(vid_url) if stream_url: play_item.setPath(stream_url) else: play_item.setPath(None) if dl: downloadDir = _settings('dlfolder') if not downloadDir: xbmc.executebuiltin( 'XBMC.Notification(Download:,Choose download directory in Settings!,5000)' ) return if '|' in stream_url: headers = stream_url.split('|')[1] stream_url = stream_url.split('|')[0] vid = {} vid['title'] = title vid['url'] = stream_url vid['ext'] = 'mp4' with YDStreamUtils.DownloadProgress( ) as prog: #This gives a progress dialog interface ready to use try: YDStreamExtractor.setOutputCallback(prog) result = YDStreamExtractor.downloadVideo(vid, downloadDir) if result: #success full_path_to_file = result.filepath elif result.status != 'canceled': #download failed error_message = result.message finally: YDStreamExtractor.setOutputCallback(None) else: kodistr = xbmc.getInfoLabel('System.BuildVersion') kodiver = float(kodistr[0:3]) if kodiver >= 17.0 and stream_url and ('yupp' not in stream_url) and ( 'SUNNXT' not in stream_url): if '.m3u8' in stream_url: if 'master' in stream_url or 'adaptive' in stream_url: play_item.setProperty('inputstreamaddon', 'inputstream.adaptive') play_item.setProperty('inputstream.adaptive.manifest_type', 'hls') play_item.setMimeType( 'application/vnd.apple.mpegstream_url') play_item.setContentLookup(False) if '|' in stream_url: stream_url, strhdr = stream_url.split('|') play_item.setProperty( 'inputstream.adaptive.stream_headers', strhdr) play_item.setPath(stream_url) elif '.mpd' in stream_url: play_item.setProperty('inputstreamaddon', 'inputstream.adaptive') play_item.setProperty('inputstream.adaptive.manifest_type', 'mpd') play_item.setMimeType('application/dash+xml') play_item.setContentLookup(False) elif '.ism' in stream_url: play_item.setProperty('inputstreamaddon', 'inputstream.adaptive') play_item.setProperty('inputstream.adaptive.manifest_type', 'ism') play_item.setMimeType('application/vnd.ms-sstr+xml') play_item.setContentLookup(False) xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
def pauseStack(self): if not self.stack: StreamUtils.pause() self.stack += 1
def resumeStack(self): self.stack -= 1 if self.stack < 1: self.stack = 0 StreamUtils.resume()
def handleURL(url): protocol = url.split('://', 1)[0] if protocol in protocolURLs: pluginURL = protocolURLs[protocol].format(url=url) StreamUtils.play(pluginURL) '''{u'iden': u'ujxCHwc6fiSsjAl11HK7y0',