addurl --file: Fix a bug that made youtube-dl be used unneccessarily when adding an html url that does not contain any media.

This commit is contained in:
Joey Hess 2019-03-18 13:34:29 -04:00
parent a87da159c1
commit 8758f9c561
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 11 additions and 2 deletions

View file

@ -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 <id@joeyh.name> Wed, 20 Feb 2019 14:20:59 -0400

View file

@ -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)

View file

@ -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]]