From 8758f9c561a169be3fd691a5207e9f6e74f41060 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 18 Mar 2019 13:34:29 -0400 Subject: [PATCH] addurl --file: Fix a bug that made youtube-dl be used unneccessarily when adding an html url that does not contain any media. --- CHANGELOG | 2 ++ Command/AddUrl.hs | 9 +++++++-- ...be-dl_could_potentially_access_any_address__34__.mdwn | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 90f748c860..1adb524d9d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,8 @@ git-annex (7.20190220) UNRELEASED; urgency=medium * Fix cleanup of git-annex:export.log after git-annex forget --drop-dead. * Makefile: Added install-home target which installs git-annex into the HOME directory. + * addurl --file: Fix a bug that made youtube-dl be used unneccessarily + when adding an html url that does not contain any media. -- Joey Hess Wed, 20 Feb 2019 14:20:59 -0400 diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index 51ba1f0063..df7973d95d 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -218,7 +218,7 @@ performWeb :: AddUrlOptions -> URLString -> FilePath -> Url.UrlInfo -> CommandPe performWeb o url file urlinfo = ifAnnexed file addurl geturl where geturl = next $ isJust <$> addUrlFile (downloadOptions o) url urlinfo file - addurl = addUrlChecked o url file webUUID $ \k -> + addurl = addUrlChecked o url file webUUID $ \k -> ifM (pure (not (rawOption (downloadOptions o))) <&&> youtubeDlSupported url) ( return (True, True, setDownloader url YoutubeDownloader) , return (Url.urlExists urlinfo, Url.urlSize urlinfo == keySize k, url) @@ -277,7 +277,6 @@ downloadWeb o url urlinfo file = liftIO $ createDirectoryIfMissing True (parentDir file) finishDownloadWith tmp webUUID url file tryyoutubedl tmp - | isJust (fileOption o) = dl file -- Ask youtube-dl what filename it will download -- first, and check if that is already an annexed file, -- to avoid unnecessary work in that case. @@ -286,6 +285,12 @@ downloadWeb o url urlinfo file = (alreadyannexed dest) (dl dest) Left _ -> normalfinish tmp + -- Ask youtube-dl what filename it will download + -- fist, so it's only used when the file contains embedded + -- media. + | isJust (fileOption o) = youtubeDlFileNameHtmlOnly url >>= \case + Right _ -> dl file + Left _ -> normalfinish tmp where dl dest = withTmpWorkDir mediakey $ \workdir -> do let cleanuptmp = pruneTmpWorkDirBefore tmp (liftIO . nukeFile) diff --git a/doc/bugs/addurl_fails_with_non-youtube_url_with___34__This_url_is_supported_by_youtube-dl__44___but_youtube-dl_could_potentially_access_any_address__34__.mdwn b/doc/bugs/addurl_fails_with_non-youtube_url_with___34__This_url_is_supported_by_youtube-dl__44___but_youtube-dl_could_potentially_access_any_address__34__.mdwn index dc6069bd4c..2affb61b31 100644 --- a/doc/bugs/addurl_fails_with_non-youtube_url_with___34__This_url_is_supported_by_youtube-dl__44___but_youtube-dl_could_potentially_access_any_address__34__.mdwn +++ b/doc/bugs/addurl_fails_with_non-youtube_url_with___34__This_url_is_supported_by_youtube-dl__44___but_youtube-dl_could_potentially_access_any_address__34__.mdwn @@ -29,3 +29,5 @@ local repository version: 5 The same happens if I remove `youtube-dl` from the system entirely! [[!meta author=yoh]] +> due to using --file which bypasses the usual check that youtube-dl +> can extract media. [[fixed|done]] --[[Joey]]