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 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 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()
# -*- coding: utf-8 -*- import xbmc, xbmcgui import urllib import YDStreamExtractor as StreamExtractor import YDStreamUtils as StreamUtils import common StreamExtractor.overrideParam('noplaylist',True) StreamExtractor.generateBlacklist(('.*:(?:user|channel|search)$','(?i)generic.*')) def getURLMediaType(url): if url.startswith('http'): videoTypes = xbmc.getSupportedMedia('video') musicTypes = xbmc.getSupportedMedia('music') imageTypes = xbmc.getSupportedMedia('picture') ext = url.rsplit('.',1)[-1] if ext in videoTypes: return 'video' elif ext in musicTypes: return 'audio' elif ext in imageTypes: return 'image' return protocolMediaType(url) def canHandle(data): if data.get('type') == 'link': url = data.get('url','') if StreamExtractor.mightHaveVideo(url): return 'video' mediaType = getURLMediaType(url) if mediaType: return mediaType return canPlayURL(url) and 'video' or None
# -*- coding: utf-8 -*- import xbmc, xbmcgui import urllib import YDStreamExtractor as StreamExtractor import YDStreamUtils as StreamUtils import common StreamExtractor.overrideParam("noplaylist", True) StreamExtractor.generateBlacklist((".*:(?:user|channel|search)$", "(?i)generic.*")) def getURLMediaType(url): if url.startswith("http"): videoTypes = xbmc.getSupportedMedia("video") musicTypes = xbmc.getSupportedMedia("music") imageTypes = xbmc.getSupportedMedia("picture") ext = url.rsplit(".", 1)[-1] if ext in videoTypes: return "video" elif ext in musicTypes: return "audio" elif ext in imageTypes: return "image" return protocolMediaType(url) def canHandle(data): if data.get("type") == "link": url = data.get("url", "") if StreamExtractor.mightHaveVideo(url): return "video"
listitem = xbmcgui.ListItem(path=path) listitem.setInfo(type="Video", infoLabels={"Title": title}) 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:
# -*- coding: utf-8 -*- import xbmc, xbmcgui import urllib import YDStreamExtractor as StreamExtractor import YDStreamUtils as StreamUtils import common StreamExtractor.overrideParam('noplaylist',True) StreamExtractor.generateBlacklist(('.*:(?:user|channel|search)$','(?i)generic.*')) def getURLMediaType(url): if url.startswith('http'): videoTypes = xbmc.getSupportedMedia('video') musicTypes = xbmc.getSupportedMedia('music') imageTypes = xbmc.getSupportedMedia('picture') ext = url.rsplit('.',1)[-1] if ext in videoTypes: return 'video' elif ext in musicTypes: return 'audio' elif ext in imageTypes: return 'image' return protocolMediaType(url) def canHandle(data): if data.get('type') == 'link': url = data.get('url','') if StreamExtractor.mightHaveVideo(url): return 'video' mediaType = getURLMediaType(url) if mediaType: return mediaType return canPlayURL(url) and 'video' or None