Python youtube_dl.utils.DownloadError() Examples
The following are 5
code examples of youtube_dl.utils.DownloadError().
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 also want to check out all available functions/classes of the module
youtube_dl.utils
, or try the search function
.
Example #1
Source File: test_catt.py From catt with BSD 2-Clause "Simplified" License | 7 votes |
def ignore_tmr_failure(func): """ Ignore "Too many requests" failures in a test. YouTube will sometimes throttle us and cause the tests to flap. This decorator catches the "Too many requests" exceptions in tests and ignores them. """ def wrapper(*args): try: return func(*args) except DownloadError as err: if "HTTP Error 429:" in str(err): pass else: raise return wrapper
Example #2
Source File: mastodon.py From fediplay with MIT License | 6 votes |
def on_update(self, status): if options['debug']: print('incoming status: acct={!r}'.format(status.account.acct)) if self.users and normalize_username(status.account.acct, self.instance) not in self.users: if options['debug']: print('skipping status due to username filtering') return tags = extract_tags(status) if options['debug']: print('expecting: {!r}, extracted tags: {!r}'.format(LISTEN_TO_HASHTAG, tags)) if LISTEN_TO_HASHTAG in tags: links = extract_links(status) if options['debug']: print('links: {!r}'.format(links)) for link in links: try: click.echo('==> Trying {}'.format(link)) self.queue.add(link) return except DownloadError: pass
Example #3
Source File: download.py From pornhub-dl with MIT License | 4 votes |
def download_video(viewkey, name="single_videos"): """Download the video.""" # Decide which domain should be used, depending if the user has a premium account is_premium = os.path.exists("cookie_file") if is_premium: video_url = f"https://www.pornhubpremium.com/view_video.php?viewkey={viewkey}" else: video_url = f"https://www.pornhub.com/view_video.php?viewkey={viewkey}" options = { "outtmpl": f"~/pornhub/{name}/%(title)s.%(ext)s", "format": "best", "quiet": True, "retries": 3, "nooverwrites": False, "continuedl": True, } if is_premium: options["cookiefile"] = "cookie_file" ydl = youtube_dl.YoutubeDL(options) tries = 0 while True: try: logger.info(f"Start downloading: {video_url}") info = ydl.extract_info(video_url) info["out_path"] = f'~/pornhub/{name}/{info["title"]}.{info["ext"]}' return True, info except TypeError: # This is an error that seems to occurr from time to time # A short wait and retry often seems to fix the problem # This is something about pornhub not properly loading the video. logger.info("Got TypeError bug") time.sleep(20) tries += 1 # If this happens too many times, something else must be broken. if tries > 10: return False, None continue except DownloadError: # We got a download error. # Ignore for now and continue downloading the other videos logger.error(f"DownloadError: Failed to download video: {viewkey}.") return False, None time.sleep(6) return False, None
Example #4
Source File: playlist.py From rhinobot_heroku with MIT License | 4 votes |
def add_stream_entry(self, song_url, info=None, **meta): if info is None: info = {'title': song_url, 'extractor': None} try: info = await self.downloader.extract_info(self.loop, song_url, download=False) except DownloadError as e: if e.exc_info[0] == UnsupportedError: # ytdl doesn't like it but its probably a stream log.debug("Assuming content is a direct stream") elif e.exc_info[0] == URLError: if os.path.exists(os.path.abspath(song_url)): raise ExtractionError("This is not a stream, this is a file path.") else: # it might be a file path that just doesn't exist raise ExtractionError("Invalid input: {0.exc_info[0]}: {0.exc_info[1].reason}".format(e)) else: # traceback.print_exc() raise ExtractionError("Unknown error: {}".format(e)) except Exception as e: log.error('Could not extract information from {} ({}), falling back to direct'.format(song_url, e), exc_info=True) if info.get('is_live') is None and info.get('extractor', None) is not 'generic': # wew hacky raise ExtractionError("This is not a stream.") dest_url = song_url if info.get('extractor'): dest_url = info.get('url') if info.get('extractor', None) == 'twitch:stream': # may need to add other twitch types title = info.get('description') else: title = info.get('title', 'Untitled') # TODO: A bit more validation, "~stream some_url" should not just say :ok_hand: entry = StreamPlaylistEntry( self, song_url, title, destination = dest_url, **meta ) self._add_entry(entry) return entry, len(self.entries)
Example #5
Source File: playlist.py From MusicBot with MIT License | 4 votes |
def add_stream_entry(self, song_url, info=None, **meta): if info is None: info = {'title': song_url, 'extractor': None} try: info = await self.downloader.extract_info(self.loop, song_url, download=False) except DownloadError as e: if e.exc_info[0] == UnsupportedError: # ytdl doesn't like it but its probably a stream log.debug("Assuming content is a direct stream") elif e.exc_info[0] == URLError: if os.path.exists(os.path.abspath(song_url)): raise ExtractionError("This is not a stream, this is a file path.") else: # it might be a file path that just doesn't exist raise ExtractionError("Invalid input: {0.exc_info[0]}: {0.exc_info[1].reason}".format(e)) else: # traceback.print_exc() raise ExtractionError("Unknown error: {}".format(e)) except Exception as e: log.error('Could not extract information from {} ({}), falling back to direct'.format(song_url, e), exc_info=True) if info.get('is_live') is None and info.get('extractor', None) is not 'generic': # wew hacky raise ExtractionError("This is not a stream.") dest_url = song_url if info.get('extractor'): dest_url = info.get('url') if info.get('extractor', None) == 'twitch:stream': # may need to add other twitch types title = info.get('description') else: title = info.get('title', 'Untitled') # TODO: A bit more validation, "~stream some_url" should not just say :ok_hand: entry = StreamPlaylistEntry( self, song_url, title, destination = dest_url, **meta ) self._add_entry(entry) return entry, len(self.entries)