importfeed: Avoid using youtube-dl when a feed does not contain an enclosure, but only a link to an url which youtube-dl does not support
This is common in some feeds, which might mix some items with enclosures, with others that link to posts or whatever. Before this, it would try to use youtube-dl and fail, or if youtube-dl was not allowed, it would incorrectly complain that an url was supported by youtube-dl.
This commit is contained in:
parent
16315b7812
commit
ed68a2166d
2 changed files with 26 additions and 21 deletions
|
@ -20,6 +20,8 @@ git-annex (8.20201128) UNRELEASED; urgency=medium
|
||||||
* Fix reversion in 8.20201116 that made include= and exclude= in
|
* Fix reversion in 8.20201116 that made include= and exclude= in
|
||||||
preferred/required content expressions match a path relative to the
|
preferred/required content expressions match a path relative to the
|
||||||
current directory, rather than the path from the top of the repository.
|
current directory, rather than the path from the top of the repository.
|
||||||
|
* importfeed: Avoid using youtube-dl when a feed does not contain an
|
||||||
|
enclosure, but only a link to an url which youtube-dl does not support.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Mon, 30 Nov 2020 12:55:49 -0400
|
-- Joey Hess <id@joeyh.name> Mon, 30 Nov 2020 12:55:49 -0400
|
||||||
|
|
||||||
|
|
|
@ -308,27 +308,30 @@ performDownload addunlockedmatcher opts cache todownload = case location todownl
|
||||||
|
|
||||||
downloadmedia linkurl mediaurl mediakey
|
downloadmedia linkurl mediaurl mediakey
|
||||||
| rawOption (downloadOptions opts) = downloadlink
|
| rawOption (downloadOptions opts) = downloadlink
|
||||||
| otherwise = do
|
| otherwise = ifM (youtubeDlSupported linkurl)
|
||||||
r <- withTmpWorkDir mediakey $ \workdir -> do
|
( do
|
||||||
dl <- youtubeDl linkurl (fromRawFilePath workdir) nullMeterUpdate
|
r <- withTmpWorkDir mediakey $ \workdir -> do
|
||||||
case dl of
|
dl <- youtubeDl linkurl (fromRawFilePath workdir) nullMeterUpdate
|
||||||
Right (Just mediafile) -> do
|
case dl of
|
||||||
let ext = case takeExtension mediafile of
|
Right (Just mediafile) -> do
|
||||||
[] -> ".m"
|
let ext = case takeExtension mediafile of
|
||||||
s -> s
|
[] -> ".m"
|
||||||
ok <- rundownload linkurl ext $ \f ->
|
s -> s
|
||||||
checkCanAdd (downloadOptions opts) f $ \canadd -> do
|
ok <- rundownload linkurl ext $ \f ->
|
||||||
addWorkTree canadd addunlockedmatcher webUUID mediaurl f mediakey (Just (toRawFilePath mediafile))
|
checkCanAdd (downloadOptions opts) f $ \canadd -> do
|
||||||
return (Just [mediakey])
|
addWorkTree canadd addunlockedmatcher webUUID mediaurl f mediakey (Just (toRawFilePath mediafile))
|
||||||
return (Just ok)
|
return (Just [mediakey])
|
||||||
-- youtude-dl didn't support it, so
|
return (Just ok)
|
||||||
-- download it as if the link were
|
-- youtube-dl didn't support it, so
|
||||||
-- an enclosure.
|
-- download it as if the link were
|
||||||
Right Nothing -> Just <$> downloadlink
|
-- an enclosure.
|
||||||
Left msg -> do
|
Right Nothing -> Just <$> downloadlink
|
||||||
warning msg
|
Left msg -> do
|
||||||
return Nothing
|
warning $ linkurl ++ ": " ++ msg
|
||||||
return (fromMaybe False r)
|
return Nothing
|
||||||
|
return (fromMaybe False r)
|
||||||
|
, downloadlink
|
||||||
|
)
|
||||||
where
|
where
|
||||||
downloadlink = performDownload addunlockedmatcher opts cache todownload
|
downloadlink = performDownload addunlockedmatcher opts cache todownload
|
||||||
{ location = Enclosure linkurl }
|
{ location = Enclosure linkurl }
|
||||||
|
|
Loading…
Add table
Reference in a new issue