diff options
author | Joey Hess <joey@kitenet.net> | 2013-08-22 18:25:21 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-08-22 18:50:43 -0400 |
commit | d40c7ca41b64013c76ce33e516579dbeae35744f (patch) | |
tree | 454bf4e4e52137d9a789c469829307560a8bf0d3 /Remote | |
parent | b485fa17ab070eaeb0501e2b249326056798f183 (diff) |
Youtube support! (And 53 other video hosts)
When quvi is installed, git-annex addurl automatically uses it to detect
when an page is a video, and downloads the video file.
web special remote: Also support using quvi, for getting files,
or checking if files exist in the web.
This commit was sponsored by Mark Hepburn. Thanks!
Diffstat (limited to 'Remote')
-rw-r--r-- | Remote/Web.hs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Remote/Web.hs b/Remote/Web.hs index 2c59528ef..b49ab0d1e 100644 --- a/Remote/Web.hs +++ b/Remote/Web.hs @@ -15,9 +15,11 @@ import Annex.Content import Config import Config.Cost import Logs.Web -import qualified Utility.Url as Url import Types.Key import Utility.Metered +import qualified Utility.Url as Url +import Annex.Quvi +import qualified Utility.Quvi as Quvi import qualified Data.Map as M @@ -67,7 +69,12 @@ downloadKey key _file dest _p = get =<< getUrls key return False get urls = do showOutput -- make way for download progress bar - downloadUrl urls dest + untilTrue urls $ \u -> do + let (u', downloader) = getDownloader u + case downloader of + QuviDownloader -> flip downloadUrl dest + =<< withQuviOptions Quvi.queryLinks [Quvi.httponly, Quvi.quiet] u' + _ -> downloadUrl [u] dest downloadKeyCheap :: Key -> FilePath -> Annex Bool downloadKeyCheap _ _ = return False @@ -90,6 +97,11 @@ checkKey key = do else return . Right =<< checkKey' key us checkKey' :: Key -> [URLString] -> Annex Bool checkKey' key us = untilTrue us $ \u -> do - showAction $ "checking " ++ u - headers <- getHttpHeaders - liftIO $ Url.check u headers (keySize key) + let (u', downloader) = getDownloader u + showAction $ "checking " ++ u' + case downloader of + QuviDownloader -> + withQuviOptions Quvi.check [Quvi.httponly, Quvi.quiet] u' + _ -> do + headers <- getHttpHeaders + liftIO $ Url.check u' headers (keySize key) |