When youtube-dl is not available in PATH, use yt-dlp instead
authorJoey Hess <joeyh@joeyh.name>
Mon, 21 Nov 2022 18:39:26 +0000 (14:39 -0400)
committerSean Whitton <spwhitton@spwhitton.name>
Mon, 21 Nov 2022 23:26:48 +0000 (16:26 -0700)
Debian is going to drop youtube-dl which is not active upstream, and yt-dlp
is the replacement. This will make it be used if youtube-dl gets removed.

If an old version of youtube-dl remains installed, git-annex will still use
it. That might not be desirable, but changing git-annex to use yt-dlp in
preference to youtube-dl when both are installed risks breaking when
the user has annex.youtube-dl-options set to something that is supported
by youtube-dl, but not by yt-dlp.

Sponsored-by: Boyd Stephen Smith Jr. on Patreon
(cherry picked from commit 5256be61c12fb030fe2eebe2751ee1601a5e7514)

Annex/YoutubeDl.hs
debian/control
doc/git-annex.mdwn

index e466f01eba2b171761891bb52ab4f3a600df3165..ba050d4024dcefd45b1cc9f31953bd64a12fc9f1 100644 (file)
@@ -249,8 +249,9 @@ youtubeDlOpts addopts = do
        return (opts ++ addopts)
 
 youtubeDlCommand :: Annex String
-youtubeDlCommand = fromMaybe "youtube-dl" . annexYoutubeDlCommand 
-       <$> Annex.getGitConfig
+youtubeDlCommand = annexYoutubeDlCommand <$> Annex.getGitConfig >>= \case
+       Just c -> pure c
+       Nothing -> fromMaybe "yt-dlp" <$> liftIO (searchPath "youtube-dl")
 
 supportedScheme :: UrlOptions -> URLString -> Bool
 supportedScheme uo url = case parseURIRelaxed url of
index 236699115f9ae789b5d010859a0d7d4d54eeab24..cf150a58877c2595a1a0e8b71dac75b238d1efb6 100644 (file)
@@ -129,7 +129,7 @@ Suggests:
        tahoe-lafs,
        libnss-mdns,
        uftp,
-       youtube-dl,
+       yt-dlp,
 Breaks: datalad (<< 0.12.3~)
 Description: manage files with git, without checking their contents into git
  git-annex allows managing large files with git, without storing the file 
index 5eca6600c8de4c4b62908a67572d858125a0715c..60811dce06ff31e0eeb50e521473a81d8fe517b8 100644 (file)
@@ -1719,8 +1719,8 @@ Remotes are configured using these settings in `.git/config`.
 
 * `annex.youtube-dl-options`
 
-  Options to pass to youtube-dl when using it to find the url to download
-  for a video.
+  Options to pass to youtube-dl (or yt-dlp) when using it to find the url
+  to download for a video.
 
   Some options may break git-annex's integration with youtube-dl. For
   example, the --output option could cause it to store files somewhere
@@ -1730,7 +1730,8 @@ Remotes are configured using these settings in `.git/config`.
 
 * `annex.youtube-dl-command`
 
-  Command to run for youtube-dl. Default is "youtube-dl".
+  Command to run for youtube-dl. Default is to use "youtube-dl" or 
+  if that is not available in the PATH, to use "yt-dlp".
 
 * `annex.aria-torrent-options`