From 88728713c82cbf1a36dc910b07f69936f13d7d0f Mon Sep 17 00:00:00 2001 From: pukkandan Date: Mon, 26 Apr 2021 07:22:24 +0530 Subject: [PATCH] Py2 compatibility for `FileNotFoundError` --- yt_dlp/downloader/dash.py | 6 +++++- yt_dlp/downloader/hls.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/yt_dlp/downloader/dash.py b/yt_dlp/downloader/dash.py index 65dc69f7e..03ed5df54 100644 --- a/yt_dlp/downloader/dash.py +++ b/yt_dlp/downloader/dash.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals +import errno try: import concurrent.futures can_threaded_download = True @@ -126,7 +127,10 @@ class DashSegmentsFD(FragmentFD): file.close() self._append_fragment(ctx, frag_content) return True - except FileNotFoundError: + except EnvironmentError as ose: + if ose.errno != errno.ENOENT: + raise + # FileNotFoundError if skip_unavailable_fragments: self.report_skip_fragment(frag_index) return True diff --git a/yt_dlp/downloader/hls.py b/yt_dlp/downloader/hls.py index 67b09144d..f4e41a6c7 100644 --- a/yt_dlp/downloader/hls.py +++ b/yt_dlp/downloader/hls.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals +import errno import re import binascii try: @@ -316,7 +317,10 @@ class HlsFD(FragmentFD): file.close() self._append_fragment(ctx, frag_content) return True - except FileNotFoundError: + except EnvironmentError as ose: + if ose.errno != errno.ENOENT: + raise + # FileNotFoundError if skip_unavailable_fragments: self.report_skip_fragment(frag_index) return True