addurl, importfeed: Added --no-raw option

Forces eg, download with youtube-dl without falling back to raw download.

Since youtube-dl failing due to an url not being supported is difficult to
distinguish from it failing due to being blocked in some way, this can be
useful to avoid the fallback of git-annex downloading the raw web page and
adding that.

Since --raw also prevents using special remotes, --no-raw also
allows special remote downloads. Although it's always possible that some
special remote may claim an url and fall back to raw download of the
content, which --no-raw cannot prevent.

Sponsored-by: Boyd Stephen Smith Jr. on Patreon
This commit is contained in:
Joey Hess 2021-06-27 11:13:38 -04:00
parent 3a14648142
commit b8e32e200e
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 39 additions and 10 deletions

View file

@ -42,7 +42,7 @@ import Types.MetaData
import Logs.MetaData
import Annex.MetaData
import Annex.FileMatcher
import Command.AddUrl (addWorkTree)
import Command.AddUrl (addWorkTree, checkRaw)
import Annex.UntrustedFilePath
import qualified Annex.Branch
import Logs
@ -185,7 +185,7 @@ performDownload addunlockedmatcher opts cache todownload = case location todownl
let f' = fromRawFilePath f
r <- Remote.claimingUrl url
if Remote.uuid r == webUUID || rawOption (downloadOptions opts)
then do
then checkRaw (downloadOptions opts) $ do
let dlopts = (downloadOptions opts)
-- force using the filename
-- chosen here
@ -326,8 +326,9 @@ performDownload addunlockedmatcher opts cache todownload = case location todownl
, downloadlink
)
where
downloadlink = performDownload addunlockedmatcher opts cache todownload
{ location = Enclosure linkurl }
downloadlink = checkRaw (downloadOptions opts) $
performDownload addunlockedmatcher opts cache todownload
{ location = Enclosure linkurl }
addmediafast linkurl mediaurl mediakey =
ifM (pure (not (rawOption (downloadOptions opts)))