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 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 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)
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)