addurl: Added --raw option, which bypasses special handling of quvi, bittorrent etc urls.
This commit is contained in:
parent
6ee0d6c46d
commit
504dda82a4
4 changed files with 37 additions and 19 deletions
|
@ -38,7 +38,7 @@ import qualified Utility.Quvi as Quvi
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cmd :: [Command]
|
cmd :: [Command]
|
||||||
cmd = [notBareRepo $ withOptions [fileOption, pathdepthOption, relaxedOption] $
|
cmd = [notBareRepo $ withOptions [fileOption, pathdepthOption, relaxedOption, rawOption] $
|
||||||
command "addurl" (paramRepeating paramUrl) seek
|
command "addurl" (paramRepeating paramUrl) seek
|
||||||
SectionCommon "add urls to annex"]
|
SectionCommon "add urls to annex"]
|
||||||
|
|
||||||
|
@ -51,14 +51,18 @@ pathdepthOption = fieldOption [] "pathdepth" paramNumber "path components to use
|
||||||
relaxedOption :: Option
|
relaxedOption :: Option
|
||||||
relaxedOption = flagOption [] "relaxed" "skip size check"
|
relaxedOption = flagOption [] "relaxed" "skip size check"
|
||||||
|
|
||||||
|
rawOption :: Option
|
||||||
|
rawOption = flagOption [] "raw" "disable special handling for torrents, quvi, etc"
|
||||||
|
|
||||||
seek :: CommandSeek
|
seek :: CommandSeek
|
||||||
seek us = do
|
seek us = do
|
||||||
optfile <- getOptionField fileOption return
|
optfile <- getOptionField fileOption return
|
||||||
relaxed <- getOptionFlag relaxedOption
|
relaxed <- getOptionFlag relaxedOption
|
||||||
|
raw <- getOptionFlag rawOption
|
||||||
pathdepth <- getOptionField pathdepthOption (return . maybe Nothing readish)
|
pathdepth <- getOptionField pathdepthOption (return . maybe Nothing readish)
|
||||||
forM_ us $ \u -> do
|
forM_ us $ \u -> do
|
||||||
r <- Remote.claimingUrl u
|
r <- Remote.claimingUrl u
|
||||||
if Remote.uuid r == webUUID
|
if Remote.uuid r == webUUID || raw
|
||||||
then void $ commandAction $ startWeb relaxed optfile pathdepth u
|
then void $ commandAction $ startWeb relaxed optfile pathdepth u
|
||||||
else do
|
else do
|
||||||
pathmax <- liftIO $ fileNameLengthLimit "."
|
pathmax <- liftIO $ fileNameLengthLimit "."
|
||||||
|
|
|
@ -28,7 +28,7 @@ import Types.UrlContents
|
||||||
import Logs.Web
|
import Logs.Web
|
||||||
import qualified Utility.Format
|
import qualified Utility.Format
|
||||||
import Utility.Tmp
|
import Utility.Tmp
|
||||||
import Command.AddUrl (addUrlFile, downloadRemoteFile, relaxedOption)
|
import Command.AddUrl (addUrlFile, downloadRemoteFile, relaxedOption, rawOption)
|
||||||
import Annex.Perms
|
import Annex.Perms
|
||||||
import Annex.UUID
|
import Annex.UUID
|
||||||
import Backend.URL (fromUrl)
|
import Backend.URL (fromUrl)
|
||||||
|
@ -42,7 +42,7 @@ import Logs.MetaData
|
||||||
import Annex.MetaData
|
import Annex.MetaData
|
||||||
|
|
||||||
cmd :: [Command]
|
cmd :: [Command]
|
||||||
cmd = [notBareRepo $ withOptions [templateOption, relaxedOption] $
|
cmd = [notBareRepo $ withOptions [templateOption, relaxedOption, rawOption] $
|
||||||
command "importfeed" (paramRepeating paramUrl) seek
|
command "importfeed" (paramRepeating paramUrl) seek
|
||||||
SectionCommon "import files from podcast feeds"]
|
SectionCommon "import files from podcast feeds"]
|
||||||
|
|
||||||
|
@ -53,23 +53,30 @@ seek :: CommandSeek
|
||||||
seek ps = do
|
seek ps = do
|
||||||
tmpl <- getOptionField templateOption return
|
tmpl <- getOptionField templateOption return
|
||||||
relaxed <- getOptionFlag relaxedOption
|
relaxed <- getOptionFlag relaxedOption
|
||||||
|
raw <- getOptionFlag rawOption
|
||||||
|
let opts = Opts { relaxedOpt = relaxed, rawOpt = raw }
|
||||||
cache <- getCache tmpl
|
cache <- getCache tmpl
|
||||||
withStrings (start relaxed cache) ps
|
withStrings (start opts cache) ps
|
||||||
|
|
||||||
start :: Bool -> Cache -> URLString -> CommandStart
|
data Opts = Opts
|
||||||
start relaxed cache url = do
|
{ relaxedOpt :: Bool
|
||||||
|
, rawOpt :: Bool
|
||||||
|
}
|
||||||
|
|
||||||
|
start :: Opts -> Cache -> URLString -> CommandStart
|
||||||
|
start opts cache url = do
|
||||||
showStart "importfeed" url
|
showStart "importfeed" url
|
||||||
next $ perform relaxed cache url
|
next $ perform opts cache url
|
||||||
|
|
||||||
perform :: Bool -> Cache -> URLString -> CommandPerform
|
perform :: Opts -> Cache -> URLString -> CommandPerform
|
||||||
perform relaxed cache url = do
|
perform opts cache url = do
|
||||||
v <- findDownloads url
|
v <- findDownloads url
|
||||||
case v of
|
case v of
|
||||||
[] -> do
|
[] -> do
|
||||||
feedProblem url "bad feed content"
|
feedProblem url "bad feed content"
|
||||||
next $ return True
|
next $ return True
|
||||||
l -> do
|
l -> do
|
||||||
ok <- and <$> mapM (performDownload relaxed cache) l
|
ok <- and <$> mapM (performDownload opts cache) l
|
||||||
unless ok $
|
unless ok $
|
||||||
feedProblem url "problem downloading item"
|
feedProblem url "problem downloading item"
|
||||||
next $ cleanup url True
|
next $ cleanup url True
|
||||||
|
@ -138,15 +145,15 @@ downloadFeed url = do
|
||||||
, return Nothing
|
, return Nothing
|
||||||
)
|
)
|
||||||
|
|
||||||
performDownload :: Bool -> Cache -> ToDownload -> Annex Bool
|
performDownload :: Opts -> Cache -> ToDownload -> Annex Bool
|
||||||
performDownload relaxed cache todownload = case location todownload of
|
performDownload opts cache todownload = case location todownload of
|
||||||
Enclosure url -> checkknown url $
|
Enclosure url -> checkknown url $
|
||||||
rundownload url (takeExtension url) $ \f -> do
|
rundownload url (takeExtension url) $ \f -> do
|
||||||
r <- Remote.claimingUrl url
|
r <- Remote.claimingUrl url
|
||||||
if Remote.uuid r == webUUID
|
if Remote.uuid r == webUUID || rawOpt opts
|
||||||
then do
|
then do
|
||||||
urlinfo <- Url.withUrlOptions (Url.getUrlInfo url)
|
urlinfo <- Url.withUrlOptions (Url.getUrlInfo url)
|
||||||
maybeToList <$> addUrlFile relaxed url urlinfo f
|
maybeToList <$> addUrlFile (relaxedOpt opts) url urlinfo f
|
||||||
else do
|
else do
|
||||||
res <- tryNonAsync $ maybe
|
res <- tryNonAsync $ maybe
|
||||||
(error $ "unable to checkUrl of " ++ Remote.name r)
|
(error $ "unable to checkUrl of " ++ Remote.name r)
|
||||||
|
@ -156,10 +163,10 @@ performDownload relaxed cache todownload = case location todownload of
|
||||||
Left _ -> return []
|
Left _ -> return []
|
||||||
Right (UrlContents sz _) ->
|
Right (UrlContents sz _) ->
|
||||||
maybeToList <$>
|
maybeToList <$>
|
||||||
downloadRemoteFile r relaxed url f sz
|
downloadRemoteFile r (relaxedOpt opts) url f sz
|
||||||
Right (UrlMulti l) -> do
|
Right (UrlMulti l) -> do
|
||||||
kl <- forM l $ \(url', sz, subf) ->
|
kl <- forM l $ \(url', sz, subf) ->
|
||||||
downloadRemoteFile r relaxed url' (f </> fromSafeFilePath subf) sz
|
downloadRemoteFile r (relaxedOpt opts) url' (f </> fromSafeFilePath subf) sz
|
||||||
return $ if all isJust kl
|
return $ if all isJust kl
|
||||||
then catMaybes kl
|
then catMaybes kl
|
||||||
else []
|
else []
|
||||||
|
@ -177,7 +184,7 @@ performDownload relaxed cache todownload = case location todownload of
|
||||||
let videourl = Quvi.linkUrl link
|
let videourl = Quvi.linkUrl link
|
||||||
checkknown videourl $
|
checkknown videourl $
|
||||||
rundownload videourl ("." ++ Quvi.linkSuffix link) $ \f ->
|
rundownload videourl ("." ++ Quvi.linkSuffix link) $ \f ->
|
||||||
maybeToList <$> addUrlFileQuvi relaxed quviurl videourl f
|
maybeToList <$> addUrlFileQuvi (relaxedOpt opts) quviurl videourl f
|
||||||
#else
|
#else
|
||||||
return False
|
return False
|
||||||
#endif
|
#endif
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -31,6 +31,8 @@ git-annex (5.2015022) UNRELEASED; urgency=medium
|
||||||
(For example, a newly checked out git submodule.)
|
(For example, a newly checked out git submodule.)
|
||||||
* Added SETURIPRESENT and SETURIMISSING to external special remote protocol,
|
* Added SETURIPRESENT and SETURIMISSING to external special remote protocol,
|
||||||
useful for things like ipfs that don't use regular urls.
|
useful for things like ipfs that don't use regular urls.
|
||||||
|
* addurl: Added --raw option, which bypasses special handling of quvi,
|
||||||
|
bittorrent etc urls.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Thu, 19 Feb 2015 14:16:03 -0400
|
-- Joey Hess <id@joeyh.name> Thu, 19 Feb 2015 14:16:03 -0400
|
||||||
|
|
||||||
|
|
|
@ -236,6 +236,10 @@ subdirectories).
|
||||||
Urls to torrent files (including magnet links) will cause the content of
|
Urls to torrent files (including magnet links) will cause the content of
|
||||||
the torrent to be downloaded, using `aria2c`.
|
the torrent to be downloaded, using `aria2c`.
|
||||||
|
|
||||||
|
To prevent special handling of urls by quvi, bittorrent, and other
|
||||||
|
special remotes, specify `--raw`. This will for example, make addurl
|
||||||
|
download the .torrent file and not the contents it points to.
|
||||||
|
|
||||||
* `rmurl file url`
|
* `rmurl file url`
|
||||||
|
|
||||||
Record that the file is no longer available at the url.
|
Record that the file is no longer available at the url.
|
||||||
|
@ -289,7 +293,8 @@ subdirectories).
|
||||||
The default template is '${feedtitle}/${itemtitle}${extension}'
|
The default template is '${feedtitle}/${itemtitle}${extension}'
|
||||||
(Other available variables: feedauthor, itemauthor, itemsummary, itemdescription, itemrights, itemid, itempubdate, title, author)
|
(Other available variables: feedauthor, itemauthor, itemsummary, itemdescription, itemrights, itemid, itempubdate, title, author)
|
||||||
|
|
||||||
The `--relaxed` and `--fast` options behave the same as they do in addurl.
|
The `--relaxed`, `--fast`, and `--raw` options behave the same as they
|
||||||
|
do in addurl.
|
||||||
|
|
||||||
When quvi is installed, links in the feed are tested to see if they
|
When quvi is installed, links in the feed are tested to see if they
|
||||||
are on a video hosting site, and the video is downloaded. This allows
|
are on a video hosting site, and the video is downloaded. This allows
|
||||||
|
|
Loading…
Reference in a new issue