www.programcreek.com/python/example/98358/youtube_dl.YoutubeDL

 

 

Python youtube_dl.YoutubeDL() Examples

The following are 30 code examples for showing how to use youtube_dl.YoutubeDL(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module youtube_dl , or try the search function 

 .

Example 1

Project: JJMumbleBot   Author: DuckBoss   File: sound_board_utility.py    License: GNU General Public License v3.0 9 votes  

def download_clip(url, name): ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': dir_utils.get_perm_med_dir() + f'/sound_board/{name}.wav', 'noplaylist': True, 'continue_dl': True, 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': 'wav', 'preferredquality': '192', }] } try: with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.cache.remove() info_dict = ydl.extract_info(url, download=False) ydl.prepare_filename(info_dict) ydl.download([url]) return True except Exception: return False

 

Example 2

Project: facebook-scraper   Author: kevinzg   File: extractors.py    License: MIT License 7 votes  

def extract_video_highres(self): if not YoutubeDL: raise ModuleNotFoundError( "youtube-dl must be installed to download videos in high resolution." ) ydl_opts = { 'format': 'best', 'quiet': True, } try: post_id = self.post.get('post_id') video_page = 'https://www.facebook.com/' + post_id with YoutubeDL(ydl_opts) as ydl: url = ydl.extract_info(video_page, download=False)['url'] return {'video': url} except ExtractorError as ex: logger.error("Error extracting video with youtube-dl: %r", ex) return None

 

Example 3

Project: JJMumbleBot   Author: DuckBoss   File: youtube_helper.py    License: GNU General Public License v3.0 6 votes  

def download_song_name(url): try: with youtube_dl.YoutubeDL(YoutubeHelper.ydl_opts) as ydl: ydl.cache.remove() info_dict = ydl.extract_info(url, download=True) if info_dict['duration'] >= YoutubeHelper.max_track_duration: return None if info_dict['duration'] <= 0.1: return None prep_struct = { 'std_url': url, 'main_url': info_dict['url'], 'main_title': info_dict['title'], 'img_id': info_dict['id'], 'duration': info_dict['duration'] } return prep_struct except youtube_dl.utils.DownloadError: return None

 

Example 4

Project: JJMumbleBot   Author: DuckBoss   File: youtube_helper.py    License: GNU General Public License v3.0 6 votes  

def download_next(): queue_list = list(YoutubeHelper.queue_instance.queue_storage) if len(queue_list) > 0: youtube_url = queue_list[-1]['std_url'] else: return if os.path.exists(f"{dir_utils.get_temp_med_dir()}/youtube/{queue_list[-1]['img_id']}.jpg"): dprint(f"Thumbnail exists for {queue_list[-1]['img_id']}.jpg...skipping") return try: with youtube_dl.YoutubeDL(YoutubeHelper.ydl_opts) as ydl: ydl.cache.remove() ydl.extract_info(youtube_url, download=True) except youtube_dl.utils.DownloadError as e: dprint(e) return return

Example 5

Project: raveberry   Author: raveberry   File: test_youtube.py    License: GNU Lesser General Public License v3.0 6 votes  

def setUp(self): super().setUp() try: # try to find out whether youtube is happy with us this time # send a request and skip the test if there is an error ydl_opts = Youtube.get_ydl_opts() ydl_opts["logger"] = YoutubeDLLogger(self) with youtube_dl.YoutubeDL(ydl_opts) as ydl: self.info_dict = ydl.download( ["https://www.youtube.com/watch?v=wobbf3lb2nk"] ) except (youtube_dl.utils.ExtractorError, youtube_dl.utils.DownloadError) as e: self.skipTest(f"Error when interacting with youtube, skipping test: {e}") # reduce the number for youtube playlists self.client.post(reverse("set_max_playlist_items"), {"value": "3"}) # clear test cache; ensure that it's the test directory if os.path.split(os.path.dirname(settings.SONGS_CACHE_DIR))[1] == "test_cache": for member in os.listdir(settings.SONGS_CACHE_DIR): member_path = os.path.join(settings.SONGS_CACHE_DIR, member) if os.path.isfile(member_path): os.remove(member_path)

Example 6

Project: raveberry   Author: raveberry   File: youtube.py    License: GNU Lesser General Public License v3.0 6 votes  

def check_available(self) -> bool: try: with youtube_dl.YoutubeDL(self.ydl_opts) as ydl: self.info_dict = ydl.extract_info(self.query, download=False) except (youtube_dl.utils.ExtractorError, youtube_dl.utils.DownloadError) as e: self.error = e return False # this value is not an exact match, but it's a good approximation if "entries" in self.info_dict: self.info_dict = self.info_dict["entries"][0] self.id = self.info_dict["id"] size = self.info_dict["filesize"] max_size = self.musiq.base.settings.basic.max_download_size * 1024 * 1024 if ( max_size != 0 and self.check_cached() is None and (size is not None and size > max_size) ): self.error = "Song too long" return False return True

 

Example 7

Project: vidgear   Author: abhiTronix   File: test_camgear.py    License: Apache License 2.0 6 votes  

def return_youtubevideo_params(url): """ returns Youtube Video parameters(FPS, dimensions) directly using Youtube-dl """ ydl = youtube_dl.YoutubeDL( { "outtmpl": "%(id)s%(ext)s", "noplaylist": True, "quiet": True, "format": "bestvideo", } ) with ydl: result = ydl.extract_info( url, download=False ) # We just want to extract the info return (int(result["width"]), int(result["height"]), float(result["fps"]))

Example 8

Project: MusicTools   Author: kalbhor   File: musictools.py    License: MIT License 6 votes  

def download_song(song_url, song_title): """ Download a song using youtube url and song title """ outtmpl = song_title + '.%(ext)s' ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': outtmpl, 'postprocessors': [ {'key': 'FFmpegExtractAudio','preferredcodec': 'mp3', 'preferredquality': '192', }, {'key': 'FFmpegMetadata'}, ], } with youtube_dl.YoutubeDL(ydl_opts) as ydl: info_dict = ydl.extract_info(song_url, download=True)

 

Example 9

Project: youtube-dl-GUI   Author: yasoob   File: Download.py    License: MIT License 6 votes  

def download(self): ydl_options = self._prepare_ytd_options() with youtube_dl.YoutubeDL(ydl_options) as ydl: ydl.add_default_info_extractors() ydl.add_progress_hook(self.hook) try: ydl.download([self.url]) except ( youtube_dl.utils.DownloadError, youtube_dl.utils.ContentTooShortError, youtube_dl.utils.ExtractorError, youtube_dl.utils.UnavailableVideoError ) as e: self.error_occurred = True self.remove_row_signal.emit() self.remove_url_signal.emit(self.url) self.status_bar_signal.emit(str(e))

Example 10

Project: MusicNow   Author: kalbhor   File: command_line.py    License: MIT License 6 votes  

def download_song(song_url, song_title): ''' Downloads song from youtube-dl ''' outtmpl = song_title + '.%(ext)s' ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': outtmpl, 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': '192', }, {'key': 'FFmpegMetadata'}, ], } with youtube_dl.YoutubeDL(ydl_opts) as ydl: info_dict = ydl.extract_info(song_url, download=True)

 

Example 11

Project: TG-UserBot   Author: TG-UserBot   File: yt_dl.py    License: GNU General Public License v3.0 6 votes  

def list_formats(info_dict: dict) -> str: """YoutubeDL's list_formats method but without format notes. Args: info_dict (``dict``): Dictionary which is returned by YoutubeDL's extract_info method. Returns: ``str``: All available formats in order as a string instead of stdout. """ formats = info_dict.get('formats', [info_dict]) table = [ [f['format_id'], f['ext'], youtube_dl.YoutubeDL.format_resolution(f)] for f in formats if f.get('preference') is None or f['preference'] >= -1000] if len(formats) > 1: table[-1][-1] += (' ' if table[-1][-1] else '') + '(best)' header_line = ['format code', 'extension', 'resolution'] fmtStr = ( '`Available formats for %s:`\n`%s`' % (info_dict['title'], youtube_dl.render_table(header_line, table)) ) return fmtStr

Example 12

Project: Liked-Saved-Image-Downloader   Author: makuto   File: videoDownloader.py    License: MIT License 6 votes  

def shouldUseYoutubeDl(url): for siteMask in youtubeDlSitesSupported: if siteMask in url: isBlacklisted = False for blacklistSite in youtubeDlBlacklistSites: if blacklistSite in url: isBlacklisted = True break # Use the gfycat api for these, if available # Ever since the creation of RedGifs, use YoutubeDL for all gfycat links... # if settings.settings['Gfycat_Client_id'] and 'gfycat.com' in url: # isBlacklisted = True if isBlacklisted: # We probably have another downloader return False # YoutubeDL should support this site return True return False # Returns (success or failure, output file or failure message)

 

Example 13

Project: apex-sigma-core   Author: lu-ci   File: music.py    License: GNU General Public License v3.0 6 votes  

def __init__(self, requester, item_info): """ :param requester: The user that queued the item. :type requester: discord.Member :param item_info: Document containing the queued item's details. :type item_info: dict """ self.requester = requester self.item_info = item_info self.url = self.item_info.get('webpage_url') self.video_id = self.item_info.get('id', self.url) self.uploader = self.item_info.get('uploader', 'Unknown') self.title = self.item_info.get('title') self.thumbnail = self.item_info.get('thumbnail', 'https://i.imgur.com/CGPNJDT.png') self.duration = int(self.item_info.get('duration', 0)) self.downloaded = False self.loop = asyncio.get_event_loop() self.threads = ThreadPoolExecutor() self.ytdl_params = ytdl_params self.ytdl = youtube_dl.YoutubeDL(self.ytdl_params) self.token = self.tokenize() self.location = None

Example 14

Project: botamusique   Author: azlux   File: url.py    License: MIT License 6 votes  

def _get_info_from_url(self): self.log.info("url: fetching metadata of url %s " % self.url) ydl_opts = { 'noplaylist': True } succeed = False with youtube_dl.YoutubeDL(ydl_opts) as ydl: attempts = var.config.getint('bot', 'download_attempts', fallback=2) for i in range(attempts): try: info = ydl.extract_info(self.url, download=False) self.duration = info['duration'] self.title = info['title'] self.keywords = info['title'] succeed = True return True except youtube_dl.utils.DownloadError: pass except KeyError: # info has no 'duration' break if not succeed: self.ready = 'failed' self.log.error("url: error while fetching info from the URL") raise ValidationFailedError(constants.strings('unable_download', item=self.format_title()))

Example 15

Project: TheaterTrailers   Author: Electronickss   File: theaterTrailers.py    License: GNU General Public License v3.0 6 votes  

def videoDownloader(string, passedTitle, yearVar): # Options for the video downloader ydl1_opts = { 'outtmpl': os.path.join(TheaterTrailersHome, 'Trailers', '{0} ({1})'.format(passedTitle, yearVar), '{0} ({1}).mp4'.format(passedTitle, yearVar)), 'ignoreerrors': True, 'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best', } with youtube_dl.YoutubeDL(ydl1_opts) as ydl: logger.info("downloading {0} from {1}".format(passedTitle, string)) ydl.download([string]) shutil.copy2( os.path.join(trailerLocation, '{0} ({1})'.format(passedTitle, yearVar), '{0} ({1}).mp4'.format(passedTitle, yearVar)), os.path.join(trailerLocation, '{0} ({1})'.format(passedTitle, yearVar), '{0} ({1})-trailer.mp4'.format(passedTitle, yearVar)) ) shutil.copy2( os.path.join(TheaterTrailersHome, 'res', 'poster.jpg'), os.path.join(trailerLocation, '{0} ({1})'.format(passedTitle, yearVar)) ) updatePlex() # Downloads info for the videos from the playlist

Example 16

Project: youtube-dl-webui   Author: d0u9   File: worker.py    License: GNU General Public License v2.0 6 votes  

def run(self): self.intercept_ydl_opts() with YoutubeDL(self.ydl_opts) as ydl: try: if self.first_run: info_dict = ydl.extract_info(self.url, download=False) # self.logger.debug(json.dumps(info_dict, indent=4)) info_dict['description'] = info_dict['description'].replace('\n', '<br />'); payload = {'tid': self.tid, 'data': info_dict} self.msg_cli.put('info_dict', payload) self.logger.info('start downloading, url - %s' %(self.url)) ydl.download([self.url]) except DownloadError as e: # url error event_handler = FatalEvent(self.tid, self.msg_cli) event_handler.invalid_url(self.url); self.msg_cli.put('worker_done', {'tid': self.tid, 'data': {}})

Example 17

Project: BotHub   Author: mkaraniya   File: yt_dl.py    License: Apache License 2.0 6 votes  

def list_formats(info_dict: dict) -> str: """YoutubeDL's list_formats method but without format notes. Args: info_dict (``dict``): Dictionary which is returned by YoutubeDL's extract_info method. Returns: ``str``: All available formats in order as a string instead of stdout. """ formats = info_dict.get('formats', [info_dict]) table = [[ f['format_id'], f['ext'], youtube_dl.YoutubeDL.format_resolution(f) ] for f in formats if f.get('preference') is None or f['preference'] >= -1000] if len(formats) > 1: table[-1][-1] += (' ' if table[-1][-1] else '') + '(best)' header_line = ['format code', 'extension', 'resolution'] fmtStr = ( '`Available formats for %s:`\n`%s`' % (info_dict['title'], youtube_dl.render_table(header_line, table))) return fmtStr

Example 18

Project: gallery-dl   Author: mikf   File: ytdl.py    License: GNU General Public License v2.0 6 votes  

def __init__(self, job): DownloaderBase.__init__(self, job) extractor = job.extractor retries = self.config("retries", extractor._retries) options = { "format": self.config("format") or None, "ratelimit": text.parse_bytes(self.config("rate"), None), "retries": retries+1 if retries >= 0 else float("inf"), "socket_timeout": self.config("timeout", extractor._timeout), "nocheckcertificate": not self.config("verify", extractor._verify), "nopart": not self.part, "updatetime": self.config("mtime", True), "proxy": extractor.session.proxies.get("http"), } options.update(self.config("raw-options") or {}) if self.config("logging", True): options["logger"] = self.log self.forward_cookies = self.config("forward-cookies", False) outtmpl = self.config("outtmpl") self.outtmpl = DEFAULT_OUTTMPL if outtmpl == "default" else outtmpl self.ytdl = YoutubeDL(options)

Example 19

Project: lynda-video-downloader   Author: 22nds   File: download.py    License: GNU General Public License v3.0 6 votes  

def get_videos(url): """Download all videos in the course. """ # Lynda.com login and video filename options options = { 'username': USERNAME, 'password': PASSWORD, 'outtmpl': u'%(playlist_index)s-%(title)s.%(ext)s', 'writesubtitles': SUBTITLES, 'allsubtitles': SUBTITLES, 'download_archive': ARCHIVE, 'external_downloader': EXTERNAL_DL } try: with youtube_dl.YoutubeDL(options) as ydl: ydl.download([url]) except: print('Could not download the video in course: {}'.format(url))

Example 20

Project: playlistfromsong   Author: schollz   File: playlistfromsong.py    License: MIT License 6 votes  

def downloadURL(url, preferredCodec=None, preferredQuality=None): """ Downloads song using youtube_dl and the song's youtube url. """ codec, quality = getCodecAndQuality() ydl_opts = { 'format': 'bestaudio/best', 'quiet': True, 'no_warnings': True, 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': codec, 'preferredquality': quality, }, {'key': 'FFmpegMetadata'}, ], } try: with YoutubeDL(ydl_opts) as ydl: return ydl.extract_info(url, download=True) except: print("Problem downloading " + url) return None

Example 21

Project: music-bot   Author: tafarelyan   File: bot.py    License: GNU General Public License v3.0 6 votes  

def download(title, video_url): ydl_opts = { 'outtmpl': '{}.%(ext)s'.format(title), 'format': 'bestaudio/best', 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': '192', }], } with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download([video_url]) return { 'audio': open(title + '.mp3', 'rb'), 'title': title, }

Example 22

Project: tubeup   Author: bibanon   File: test_tubeup.py    License: GNU General Public License v3.0 6 votes  

def test_create_basenames_from_ydl_info_dict_playlist(self): ydl = YoutubeDL() result = self.tu.create_basenames_from_ydl_info_dict( ydl, info_dict_playlist) expected_result = set([ 'Live Streaming Rafid Aslam-7gjgkH5iPaE', 'Live Streaming Rafid Aslam-q92kxPm-pqM', 'Cara Membuat Laptop Menjadi Hotspot WiFi Dengan CMD-YjFwMSDNphM', '[CSO] Defeat Boss in Dead End With Thanatos 7-EEm6MwXLse0', 'Cara Bermain Minecraft Multiplayer Dengan LAN-g2vTZ2ka-tM', 'Live Streaming Rafid Aslam-AXhuSS5_9YU', 'Cara Membuat Disk Baru di Komputer-KDOygJnK7Sw', 'Cara Mendownload Lewat Torrent-cC-9RghkvXs'] ) self.assertEqual(result, expected_result)

Example 23

Project: VK-Scraper   Author: vanyasem   File: app.py    License: GNU General Public License v3.0 6 votes  

def determine_max_video_res(item, save_dir): if 'files' in item: if 'mp4_1080' in item['files']: return item['files']['mp4_1080'] if 'mp4_720' in item['files']: return item['files']['mp4_720'] if 'mp4_480' in item['files']: return item['files']['mp4_480'] if 'mp4_360' in item['files']: return item['files']['mp4_360'] if 'mp4_240' in item['files']: return item['files']['mp4_240'] elif 'player' in item: # TODO: parse VK videos here to download user-owned private files ydl_opts = { 'outtmpl': save_dir + '/%(title)s.%(ext)s', 'noplaylist': True, 'logger': VkScraper.VideoLogger(), } with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download([item['player']])

Example 24

Project: bulk-downloader-for-reddit   Author: aliparlakci   File: youtube.py    License: GNU General Public License v3.0 6 votes  

def download(self,filename,directory,url): ydl_opts = { "format": "best", "outtmpl": str(directory / (filename + ".%(ext)s")), "progress_hooks": [self._hook], "playlistend": 1, "nooverwrites": True, "quiet": True } with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download([url]) location = directory/(filename+".mp4") if GLOBAL.arguments.no_dupes: try: fileHash = createHash(location) except FileNotFoundError: return None if fileHash in GLOBAL.downloadedPosts(): os.remove(location) raise FileAlreadyExistsError GLOBAL.downloadedPosts.add(fileHash)

Example 25

Project: video2commons   Author: toolforge   File: urlextract.py    License: GNU General Public License v3.0 5 votes  

def do_extract_url(url): """Extract a video url.""" params = { 'format': 'bestvideo+bestaudio/best', 'outtmpl': '/dev/null', 'writedescription': True, 'writeinfojson': True, 'writesubtitles': False, 'subtitlesformat': 'srt/ass/vtt/best', 'cachedir': '/tmp/', 'noplaylist': True, # not implemented in video2commons } info = youtube_dl.YoutubeDL(params).extract_info(url, download=False) assert 'formats' in info or info.get('direct'), \ 'Your url cannot be processed correctly' ie_key = info['extractor_key'] title = (info.get('title') or '').strip() url = info.get('webpage_url') or url filedesc = FILEDESC_TEMPLATE % { 'desc': _desc(url, ie_key, title, info), 'date': _date(url, ie_key, title, info), 'source': _source(url, ie_key, title, info), 'uploader': _uploader(url, ie_key, title, info), 'license': _license(url, ie_key, title, info) } return { 'url': url, 'extractor': ie_key, 'filedesc': filedesc.strip(), 'filename': sanitize(title) }

Example 26

Project: wuy   Author: manatlan   File: dlyt.py    License: GNU General Public License v2.0 5 votes  

def get(self,q): if "http" in q.lower(): u=q.strip() else: u='https://www.youtube.com/watch?v='+q y = yt.YoutubeDL() return y.extract_info(u, download=False)

Example 27

Project: JJMumbleBot   Author: DuckBoss   File: youtube_helper.py    License: GNU General Public License v3.0 5 votes  

def download_specific(index): queue_list = list(YoutubeHelper.queue_instance.queue_storage) if len(queue_list) > 0: youtube_url = queue_list[index]['std_url'] else: return if os.path.isfile(f"{dir_utils.get_temp_med_dir()}/youtube/{queue_list[index]['img_id']}.jpg"): return try: with youtube_dl.YoutubeDL(YoutubeHelper.ydl_opts) as ydl: ydl.extract_info(youtube_url, download=True) except youtube_dl.utils.DownloadError: return return

Example 28

Project: raveberry   Author: raveberry   File: youtube.py    License: GNU Lesser General Public License v3.0 5 votes  

def _download(self) -> bool: error = None location = None try: with youtube_dl.YoutubeDL(self.ydl_opts) as ydl: ydl.download([self.get_external_url()]) location = self._get_path() base = os.path.splitext(location)[0] thumbnail = base + ".jpg" try: os.remove(thumbnail) except FileNotFoundError: logging.info("tried to delete %s but does not exist", thumbnail) try: # tag the file with replaygain to perform volume normalization subprocess.call( ["rganalysis", location], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) except OSError as e: if e.errno == errno.ENOENT: pass # the rganalysis package was not found. Skip normalization else: raise except youtube_dl.utils.DownloadError as e: error = e if error is not None or location is None: logging.error("accessible video could not be downloaded: %s", self.id) logging.error("location: %s", location) logging.error(error) return False return True

Example 29

Project: raveberry   Author: raveberry   File: youtube.py    License: GNU Lesser General Public License v3.0 5 votes  

def fetch_metadata(self) -> bool: # in case of a radio playist, restrict the number of songs that are downloaded if self.is_radio(): self.ydl_opts[ "playlistend" ] = self.musiq.base.settings.basic.max_playlist_items try: with youtube_dl.YoutubeDL(self.ydl_opts) as ydl: info_dict = ydl.extract_info(self.id, download=False) except (youtube_dl.utils.ExtractorError, youtube_dl.utils.DownloadError) as e: self.error = e return False if info_dict["_type"] != "playlist" or "entries" not in info_dict: # query was not a playlist url -> search for the query assert False assert self.id == info_dict["id"] if "title" in info_dict: self.title = info_dict["title"] for entry in info_dict["entries"]: self.urls.append("https://www.youtube.com/watch?v=" + entry["id"]) assert self.key is None return True

Example 30

Project: catt   Author: skorokithakis   File: stream_info.py    License: BSD 2-Clause "Simplified" License 5 votes  

def __init__(self, video_url, device_info=None, ytdl_options=None, throw_ytdl_dl_errs=False): self._throw_ytdl_dl_errs = throw_ytdl_dl_errs self.local_ip = get_local_ip(device_info.ip) if device_info else None self.port = random.randrange(45000, 47000) if device_info else None if "://" in video_url: self._ydl = youtube_dl.YoutubeDL(dict(ytdl_options) if ytdl_options else DEFAULT_YTDL_OPTS) self._preinfo = self._get_stream_preinfo(video_url) # Some playlist urls needs to be re-processed (such as youtube channel urls). if self._preinfo.get("ie_key"): self._preinfo = self._get_stream_preinfo(self._preinfo["url"]) self.is_local_file = False model = (device_info.manufacturer, device_info.model_name) if device_info else None cast_type = device_info.cast_type if device_info else None if "format" in self._ydl.params: # We pop the "format" item, as it will make get_stream_info fail, # if it holds an invalid value. self._best_format = self._ydl.params.pop("format") elif cast_type and cast_type in AUDIO_DEVICE_TYPES: self._best_format = AUDIO_FORMAT elif model and model in ULTRA_MODELS: self._best_format = ULTRA_FORMAT else: self._best_format = STANDARD_FORMAT if self.is_playlist: self._entries = list(self._preinfo["entries"]) # There appears to be no way to extract both a YouTube video id, # and ditto playlist id in one go (in the case of an url containing both), # so we set the "noplaylist" option and then fetch preinfo again. self._ydl.params.update({"noplaylist": True}) vpreinfo = self._get_stream_preinfo(video_url) self._info = self._get_stream_info(vpreinfo) if "entries" not in vpreinfo else None else: self._info = self._get_stream_info(self._preinfo) else: self._local_file = video_url self.is_local_file = True

 
 
Posted by uniqueone
,