avoid warning when youtube-dl is not installed
If a user does not have it installed, don't warn on every imported item about it.
This commit is contained in:
parent
a7b4358c05
commit
8a0038ec23
3 changed files with 13 additions and 15 deletions
|
@ -80,9 +80,12 @@ youtubeDlTo key url dest = do
|
||||||
return False
|
return False
|
||||||
Right r -> return r
|
Right r -> return r
|
||||||
|
|
||||||
|
youtubeDlSupported :: URLString -> Annex Bool
|
||||||
|
youtubeDlSupported url = either (const False) id <$> youtubeDlCheck url
|
||||||
|
|
||||||
-- Check if youtube-dl can still find media in an url.
|
-- Check if youtube-dl can still find media in an url.
|
||||||
youtubeDlSupported :: URLString -> Annex (Either String Bool)
|
youtubeDlCheck :: URLString -> Annex (Either String Bool)
|
||||||
youtubeDlSupported url = catchMsgIO $ do
|
youtubeDlCheck url = catchMsgIO $ do
|
||||||
opts <- map Param . annexYoutubeDlOptions <$> Annex.getGitConfig
|
opts <- map Param . annexYoutubeDlOptions <$> Annex.getGitConfig
|
||||||
let opts' = opts ++ [ Param url, Param "--simulate" ]
|
let opts' = opts ++ [ Param url, Param "--simulate" ]
|
||||||
liftIO $ snd <$> processTranscript "youtube-dl" (toCommand opts') Nothing
|
liftIO $ snd <$> processTranscript "youtube-dl" (toCommand opts') Nothing
|
||||||
|
|
|
@ -286,18 +286,13 @@ performDownload opts cache todownload = case location todownload of
|
||||||
return False
|
return False
|
||||||
Right b -> return b
|
Right b -> return b
|
||||||
|
|
||||||
addmediafast linkurl mediaurl mediakey =
|
addmediafast linkurl mediaurl mediakey = ifM (youtubeDlSupported linkurl)
|
||||||
youtubeDlSupported linkurl >>= \case
|
( rundownload linkurl ".m" $ \f -> do
|
||||||
Right True ->
|
addWorkTree webUUID mediaurl f mediakey Nothing
|
||||||
rundownload linkurl ".m" $ \f -> do
|
return [mediakey]
|
||||||
addWorkTree webUUID mediaurl f mediakey Nothing
|
, performDownload opts cache todownload
|
||||||
return [mediakey]
|
{ location = Enclosure linkurl }
|
||||||
Right False ->
|
)
|
||||||
performDownload opts cache todownload
|
|
||||||
{ location = Enclosure linkurl }
|
|
||||||
Left msg -> do
|
|
||||||
warning msg
|
|
||||||
return False
|
|
||||||
|
|
||||||
defaultTemplate :: String
|
defaultTemplate :: String
|
||||||
defaultTemplate = "${feedtitle}/${itemtitle}${extension}"
|
defaultTemplate = "${feedtitle}/${itemtitle}${extension}"
|
||||||
|
|
|
@ -106,7 +106,7 @@ checkKey' key us = firsthit us (Right False) $ \u -> do
|
||||||
let (u', downloader) = getDownloader u
|
let (u', downloader) = getDownloader u
|
||||||
showChecking u'
|
showChecking u'
|
||||||
case downloader of
|
case downloader of
|
||||||
YoutubeDownloader -> youtubeDlSupported u'
|
YoutubeDownloader -> youtubeDlCheck u'
|
||||||
_ -> do
|
_ -> do
|
||||||
Url.withUrlOptions $ catchMsgIO .
|
Url.withUrlOptions $ catchMsgIO .
|
||||||
Url.checkBoth u' (keySize key)
|
Url.checkBoth u' (keySize key)
|
||||||
|
|
Loading…
Reference in a new issue