diff --git a/bulkredditdownloader/site_downloaders/youtube.py b/bulkredditdownloader/site_downloaders/youtube.py index ff770a3..cd2034b 100644 --- a/bulkredditdownloader/site_downloaders/youtube.py +++ b/bulkredditdownloader/site_downloaders/youtube.py @@ -20,19 +20,20 @@ class Youtube(BaseDownloader): super().__init__(post) def find_resources(self, authenticator: Optional[SiteAuthenticator] = None) -> list[Resource]: - return [self._download_video()] + ytdl_options = { + "format": "best", + "playlistend": 1, + "nooverwrites": True, + } + out = self._download_video(ytdl_options) + return [out] - def _download_video(self) -> Resource: + def _download_video(self, ytdl_options: dict) -> Resource: + ytdl_options['quiet'] = True with tempfile.TemporaryDirectory() as temp_dir: download_path = Path(temp_dir).resolve() - ydl_opts = { - "format": "best", - "outtmpl": str(download_path) + '/' + 'test.%(ext)s', - "playlistend": 1, - "nooverwrites": True, - "quiet": True - } - with youtube_dl.YoutubeDL(ydl_opts) as ydl: + ytdl_options['outtmpl'] = str(download_path) + '/' + 'test.%(ext)s' + with youtube_dl.YoutubeDL(ytdl_options) as ydl: ydl.download([self.post.url]) downloaded_file = list(download_path.iterdir())[0] diff --git a/bulkredditdownloader/tests/downloaders/test_youtube.py b/bulkredditdownloader/tests/downloaders/test_youtube.py index 0bbe10d..144de18 100644 --- a/bulkredditdownloader/tests/downloaders/test_youtube.py +++ b/bulkredditdownloader/tests/downloaders/test_youtube.py @@ -10,6 +10,7 @@ from bulkredditdownloader.site_downloaders.youtube import Youtube @pytest.mark.online @pytest.mark.reddit +@pytest.mark.long @pytest.mark.parametrize(('test_submission_id', 'expected_hash'), ( ('ltnoqp', '468136300a106c67f1463a7011a6db4a'), ))