Added annex.youtube-dl-command config
This can be used to run some forks of youtube-dl. Sponsored-by: Brett Eisenberg on Patreon
This commit is contained in:
parent
3093e8fcc3
commit
6d4a728455
4 changed files with 20 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
{- youtube-dl integration for git-annex
|
{- youtube-dl integration for git-annex
|
||||||
-
|
-
|
||||||
- Copyright 2017-2020 Joey Hess <id@joeyh.name>
|
- Copyright 2017-2021 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -68,7 +68,7 @@ youtubeDl url workdir p = ifM ipAddressesUnlimited
|
||||||
|
|
||||||
youtubeDl' :: URLString -> FilePath -> MeterUpdate -> UrlOptions -> Annex (Either String (Maybe FilePath))
|
youtubeDl' :: URLString -> FilePath -> MeterUpdate -> UrlOptions -> Annex (Either String (Maybe FilePath))
|
||||||
youtubeDl' url workdir p uo
|
youtubeDl' url workdir p uo
|
||||||
| supportedScheme uo url = ifM (liftIO $ inSearchPath "youtube-dl")
|
| supportedScheme uo url = ifM (liftIO . inSearchPath =<< youtubeDlCommand)
|
||||||
( runcmd >>= \case
|
( runcmd >>= \case
|
||||||
Right True -> workdirfiles >>= \case
|
Right True -> workdirfiles >>= \case
|
||||||
(f:[]) -> return (Right (Just f))
|
(f:[]) -> return (Right (Just f))
|
||||||
|
@ -88,6 +88,7 @@ youtubeDl' url workdir p uo
|
||||||
runcmd = youtubeDlMaxSize workdir >>= \case
|
runcmd = youtubeDlMaxSize workdir >>= \case
|
||||||
Left msg -> return (Left msg)
|
Left msg -> return (Left msg)
|
||||||
Right maxsize -> do
|
Right maxsize -> do
|
||||||
|
cmd <- youtubeDlCommand
|
||||||
opts <- youtubeDlOpts (dlopts ++ maxsize)
|
opts <- youtubeDlOpts (dlopts ++ maxsize)
|
||||||
oh <- mkOutputHandlerQuiet
|
oh <- mkOutputHandlerQuiet
|
||||||
-- The size is unknown to start. Once youtube-dl
|
-- The size is unknown to start. Once youtube-dl
|
||||||
|
@ -97,7 +98,7 @@ youtubeDl' url workdir p uo
|
||||||
let unknownsize = Nothing :: Maybe FileSize
|
let unknownsize = Nothing :: Maybe FileSize
|
||||||
ok <- metered (Just p) unknownsize $ \meter meterupdate ->
|
ok <- metered (Just p) unknownsize $ \meter meterupdate ->
|
||||||
liftIO $ commandMeter'
|
liftIO $ commandMeter'
|
||||||
parseYoutubeDlProgress oh (Just meter) meterupdate "youtube-dl" opts
|
parseYoutubeDlProgress oh (Just meter) meterupdate cmd opts
|
||||||
(\pr -> pr { cwd = Just workdir })
|
(\pr -> pr { cwd = Just workdir })
|
||||||
return (Right ok)
|
return (Right ok)
|
||||||
dlopts =
|
dlopts =
|
||||||
|
@ -181,7 +182,8 @@ youtubeDlCheck' :: URLString -> UrlOptions -> Annex (Either String Bool)
|
||||||
youtubeDlCheck' url uo
|
youtubeDlCheck' url uo
|
||||||
| supportedScheme uo url = catchMsgIO $ htmlOnly url False $ do
|
| supportedScheme uo url = catchMsgIO $ htmlOnly url False $ do
|
||||||
opts <- youtubeDlOpts [ Param url, Param "--simulate" ]
|
opts <- youtubeDlOpts [ Param url, Param "--simulate" ]
|
||||||
liftIO $ snd <$> processTranscript "youtube-dl" (toCommand opts) Nothing
|
cmd <- youtubeDlCommand
|
||||||
|
liftIO $ snd <$> processTranscript cmd (toCommand opts) Nothing
|
||||||
| otherwise = return (Right False)
|
| otherwise = return (Right False)
|
||||||
|
|
||||||
-- Ask youtube-dl for the filename of media in an url.
|
-- Ask youtube-dl for the filename of media in an url.
|
||||||
|
@ -218,7 +220,8 @@ youtubeDlFileNameHtmlOnly' url uo
|
||||||
, Param "--no-warnings"
|
, Param "--no-warnings"
|
||||||
, Param "--no-playlist"
|
, Param "--no-playlist"
|
||||||
]
|
]
|
||||||
let p = (proc "youtube-dl" (toCommand opts))
|
cmd <- youtubeDlCommand
|
||||||
|
let p = (proc cmd (toCommand opts))
|
||||||
{ std_out = CreatePipe
|
{ std_out = CreatePipe
|
||||||
, std_err = CreatePipe
|
, std_err = CreatePipe
|
||||||
}
|
}
|
||||||
|
@ -245,6 +248,10 @@ youtubeDlOpts addopts = do
|
||||||
opts <- map Param . annexYoutubeDlOptions <$> Annex.getGitConfig
|
opts <- map Param . annexYoutubeDlOptions <$> Annex.getGitConfig
|
||||||
return (opts ++ addopts)
|
return (opts ++ addopts)
|
||||||
|
|
||||||
|
youtubeDlCommand :: Annex String
|
||||||
|
youtubeDlCommand = fromMaybe "yooutube-dl" . annexYoutubeDlCommand
|
||||||
|
<$> Annex.getGitConfig
|
||||||
|
|
||||||
supportedScheme :: UrlOptions -> URLString -> Bool
|
supportedScheme :: UrlOptions -> URLString -> Bool
|
||||||
supportedScheme uo url = case parseURIRelaxed url of
|
supportedScheme uo url = case parseURIRelaxed url of
|
||||||
Nothing -> False
|
Nothing -> False
|
||||||
|
|
|
@ -17,6 +17,8 @@ git-annex (8.20210804) UNRELEASED; urgency=medium
|
||||||
* Fix test suite failure on Windows.
|
* Fix test suite failure on Windows.
|
||||||
* New --batch-keys option added to these commands:
|
* New --batch-keys option added to these commands:
|
||||||
get, drop, move, copy, whereis
|
get, drop, move, copy, whereis
|
||||||
|
* Added annex.youtube-dl-command config. This can be used to run some
|
||||||
|
forks of youtube-dl.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Tue, 03 Aug 2021 12:22:45 -0400
|
-- Joey Hess <id@joeyh.name> Tue, 03 Aug 2021 12:22:45 -0400
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ data GitConfig = GitConfig
|
||||||
, annexDebugFilter :: Maybe String
|
, annexDebugFilter :: Maybe String
|
||||||
, annexWebOptions :: [String]
|
, annexWebOptions :: [String]
|
||||||
, annexYoutubeDlOptions :: [String]
|
, annexYoutubeDlOptions :: [String]
|
||||||
|
, annexYoutubeDlCommand :: Maybe String
|
||||||
, annexAriaTorrentOptions :: [String]
|
, annexAriaTorrentOptions :: [String]
|
||||||
, annexCrippledFileSystem :: Bool
|
, annexCrippledFileSystem :: Bool
|
||||||
, annexLargeFiles :: GlobalConfigurable (Maybe String)
|
, annexLargeFiles :: GlobalConfigurable (Maybe String)
|
||||||
|
@ -180,6 +181,7 @@ extractGitConfig configsource r = GitConfig
|
||||||
, annexDebugFilter = getmaybe (annexConfig "debugfilter")
|
, annexDebugFilter = getmaybe (annexConfig "debugfilter")
|
||||||
, annexWebOptions = getwords (annexConfig "web-options")
|
, annexWebOptions = getwords (annexConfig "web-options")
|
||||||
, annexYoutubeDlOptions = getwords (annexConfig "youtube-dl-options")
|
, annexYoutubeDlOptions = getwords (annexConfig "youtube-dl-options")
|
||||||
|
, annexYoutubeDlCommand = getmaybe (annexConfig "youtube-dl-command")
|
||||||
, annexAriaTorrentOptions = getwords (annexConfig "aria-torrent-options")
|
, annexAriaTorrentOptions = getwords (annexConfig "aria-torrent-options")
|
||||||
, annexCrippledFileSystem = getbool (annexConfig "crippledfilesystem") False
|
, annexCrippledFileSystem = getbool (annexConfig "crippledfilesystem") False
|
||||||
, annexLargeFiles = configurable Nothing $
|
, annexLargeFiles = configurable Nothing $
|
||||||
|
|
|
@ -1657,6 +1657,10 @@ Remotes are configured using these settings in `.git/config`.
|
||||||
file any options that cause youtube-dl to download more than one file,
|
file any options that cause youtube-dl to download more than one file,
|
||||||
or to store the file anywhere other than the current working directory.
|
or to store the file anywhere other than the current working directory.
|
||||||
|
|
||||||
|
* `annex.youtube-dl-command`
|
||||||
|
|
||||||
|
Command to run for youtube-dl. Default is "youtube-dl".
|
||||||
|
|
||||||
* `annex.aria-torrent-options`
|
* `annex.aria-torrent-options`
|
||||||
|
|
||||||
Options to pass to aria2c when using it to download a torrent.
|
Options to pass to aria2c when using it to download a torrent.
|
||||||
|
|
Loading…
Reference in a new issue