]> dgit.raspbian.org Git - git-annex.git/commitdiff
display error message if unable to run youtube-dl
authorJoey Hess <joeyh@joeyh.name>
Sat, 13 Nov 2021 13:07:43 +0000 (09:07 -0400)
committerJoey Hess <joeyh@joeyh.name>
Sat, 13 Nov 2021 13:07:43 +0000 (09:07 -0400)
This would have made the typo of the command name that was just fixed
obvious earlier, when --no-raw was used to force using it.

Command/AddUrl.hs
Command/ImportFeed.hs

index a24d4c8c9bbce1998a6dfac9aba20dd35e61e6e9..cf240d00691c8a2d2f3b75eb15a2eca68dbe7e2f 100644 (file)
@@ -271,7 +271,8 @@ performWeb addunlockedmatcher o url file urlinfo = ifAnnexed file addurl geturl
        addurl = addUrlChecked o url file webUUID $ \k ->
                ifM (pure (not (rawOption (downloadOptions o))) <&&> youtubeDlSupported url)
                        ( return (True, True, setDownloader url YoutubeDownloader)
-                       , checkRaw (downloadOptions o) $ return (Url.urlExists urlinfo, Url.urlSize urlinfo == fromKey keySize k, url)
+                       , checkRaw Nothing (downloadOptions o) $
+                               return (Url.urlExists urlinfo, Url.urlSize urlinfo == fromKey keySize k, url)
                        )
 
 {- Check that the url exists, and has the same size as the key,
@@ -332,7 +333,7 @@ downloadWeb addunlockedmatcher o url urlinfo file =
                        in ifAnnexed f
                                (alreadyannexed (fromRawFilePath f))
                                (dl f)
-               Left _ -> checkRaw o (normalfinish tmp)
+               Left err -> checkRaw (Just err) o (normalfinish tmp)
          where
                dl dest = withTmpWorkDir mediakey $ \workdir -> do
                        let cleanuptmp = pruneTmpWorkDirBefore tmp (liftIO . removeWhenExistsWith R.removeLink)
@@ -346,7 +347,7 @@ downloadWeb addunlockedmatcher o url urlinfo file =
                                                                showDestinationFile (fromRawFilePath dest)
                                                                addWorkTree canadd addunlockedmatcher webUUID mediaurl dest mediakey (Just (toRawFilePath mediafile))
                                                                return $ Just mediakey
-                                               Right Nothing -> checkRaw o (normalfinish tmp)
+                                               Right Nothing -> checkRaw Nothing o (normalfinish tmp)
                                                Left msg -> do
                                                        cleanuptmp
                                                        warning msg
@@ -363,9 +364,12 @@ downloadWeb addunlockedmatcher o url urlinfo file =
                                        warning $ dest ++ " already exists; not overwriting"
                                        return Nothing
        
-checkRaw :: DownloadOptions -> Annex a -> Annex a
-checkRaw o a
-       | noRawOption o = giveup "Unable to use youtube-dl or a special remote and --no-raw was specified."
+checkRaw :: (Maybe String) -> DownloadOptions -> Annex a -> Annex a
+checkRaw failreason o a
+       | noRawOption o = giveup $ "Unable to use youtube-dl or a special remote and --no-raw was specified" ++
+               case failreason of
+                       Just msg -> ": " ++ msg
+                       Nothing -> ""
        | otherwise = a
 
 {- The destination file is not known at start time unless the user provided
@@ -487,7 +491,7 @@ nodownloadWeb addunlockedmatcher o url urlinfo file
                then nomedia
                else youtubeDlFileName url >>= \case
                        Right mediafile -> usemedia (toRawFilePath mediafile)
-                       Left _ -> checkRaw o nomedia
+                       Left err -> checkRaw (Just err) o nomedia
        | otherwise = do
                warning $ "unable to access url: " ++ url
                return Nothing
index 9fbaf34ffde04451a7828916e995614b510b298e..a8d21365e3fde3f9e205a1377fa272f59e13e5b1 100644 (file)
@@ -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 checkRaw (downloadOptions opts) $ do
+                               then checkRaw Nothing (downloadOptions opts) $ do
                                        let dlopts = (downloadOptions opts)
                                                -- force using the filename
                                                -- chosen here
@@ -326,7 +326,7 @@ performDownload addunlockedmatcher opts cache todownload = case location todownl
                        , downloadlink
                        )
          where
-               downloadlink = checkRaw (downloadOptions opts) $
+               downloadlink = checkRaw Nothing (downloadOptions opts) $
                        performDownload addunlockedmatcher opts cache todownload
                                { location = Enclosure linkurl }