better extension handling
When there's no extension, don't use "none", but "". When there is an extension, it starts with a dot, so don't put a redundant dot in the default format.
This commit is contained in:
parent
fdb6593b90
commit
8c55970413
1 changed files with 13 additions and 13 deletions
|
@ -23,17 +23,6 @@ import qualified Utility.Format
|
||||||
import Utility.Tmp
|
import Utility.Tmp
|
||||||
import Command.AddUrl (addUrlFile, relaxedOption)
|
import Command.AddUrl (addUrlFile, relaxedOption)
|
||||||
|
|
||||||
data ToDownload = ToDownload
|
|
||||||
{ feed :: Feed
|
|
||||||
, item :: Item
|
|
||||||
, location :: URLString
|
|
||||||
}
|
|
||||||
|
|
||||||
mkToDownload :: Feed -> Item -> Maybe ToDownload
|
|
||||||
mkToDownload f i = case getItemEnclosure i of
|
|
||||||
Nothing -> Nothing
|
|
||||||
Just (enclosureurl, _, _) -> Just $ ToDownload f i enclosureurl
|
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [notBareRepo $ withOptions [templateOption, relaxedOption] $
|
def = [notBareRepo $ withOptions [templateOption, relaxedOption] $
|
||||||
command "importfeed" (paramRepeating paramUrl) seek
|
command "importfeed" (paramRepeating paramUrl) seek
|
||||||
|
@ -62,6 +51,17 @@ perform relaxed cache url = do
|
||||||
next $ return True
|
next $ return True
|
||||||
_ -> stop
|
_ -> stop
|
||||||
|
|
||||||
|
data ToDownload = ToDownload
|
||||||
|
{ feed :: Feed
|
||||||
|
, item :: Item
|
||||||
|
, location :: URLString
|
||||||
|
}
|
||||||
|
|
||||||
|
mkToDownload :: Feed -> Item -> Maybe ToDownload
|
||||||
|
mkToDownload f i = case getItemEnclosure i of
|
||||||
|
Nothing -> Nothing
|
||||||
|
Just (enclosureurl, _, _) -> Just $ ToDownload f i enclosureurl
|
||||||
|
|
||||||
data Cache = Cache
|
data Cache = Cache
|
||||||
{ knownurls :: S.Set URLString
|
{ knownurls :: S.Set URLString
|
||||||
, template :: Utility.Format.Format
|
, template :: Utility.Format.Format
|
||||||
|
@ -111,7 +111,7 @@ downloadEnclosure relaxed cache enclosure
|
||||||
url = location enclosure
|
url = location enclosure
|
||||||
|
|
||||||
defaultTemplate :: String
|
defaultTemplate :: String
|
||||||
defaultTemplate = "${feedtitle}/${itemtitle}.${extension}"
|
defaultTemplate = "${feedtitle}/${itemtitle}${extension}"
|
||||||
|
|
||||||
{- Generate a unique filename for the feed item by filling
|
{- Generate a unique filename for the feed item by filling
|
||||||
- out the template.
|
- out the template.
|
||||||
|
@ -131,7 +131,7 @@ feedFile tmpl i = makeUnique 0 $
|
||||||
, fieldMaybe "itemdescription" $ getItemDescription $ item i
|
, fieldMaybe "itemdescription" $ getItemDescription $ item i
|
||||||
, fieldMaybe "itemrights" $ getItemRights $ item i
|
, fieldMaybe "itemrights" $ getItemRights $ item i
|
||||||
, fieldMaybe "itemid" $ snd <$> getItemId (item i)
|
, fieldMaybe "itemid" $ snd <$> getItemId (item i)
|
||||||
, field "extension" $ takeExtension $ location i
|
, ("extension", map sanitize $ takeExtension $ location i)
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
field k v =
|
field k v =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue