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 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 = [notBareRepo $ withOptions [templateOption, relaxedOption] $
|
||||
command "importfeed" (paramRepeating paramUrl) seek
|
||||
|
@ -62,6 +51,17 @@ perform relaxed cache url = do
|
|||
next $ return True
|
||||
_ -> 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
|
||||
{ knownurls :: S.Set URLString
|
||||
, template :: Utility.Format.Format
|
||||
|
@ -111,7 +111,7 @@ downloadEnclosure relaxed cache enclosure
|
|||
url = location enclosure
|
||||
|
||||
defaultTemplate :: String
|
||||
defaultTemplate = "${feedtitle}/${itemtitle}.${extension}"
|
||||
defaultTemplate = "${feedtitle}/${itemtitle}${extension}"
|
||||
|
||||
{- Generate a unique filename for the feed item by filling
|
||||
- out the template.
|
||||
|
@ -131,7 +131,7 @@ feedFile tmpl i = makeUnique 0 $
|
|||
, fieldMaybe "itemdescription" $ getItemDescription $ item i
|
||||
, fieldMaybe "itemrights" $ getItemRights $ item i
|
||||
, fieldMaybe "itemid" $ snd <$> getItemId (item i)
|
||||
, field "extension" $ takeExtension $ location i
|
||||
, ("extension", map sanitize $ takeExtension $ location i)
|
||||
]
|
||||
where
|
||||
field k v =
|
||||
|
|
Loading…
Add table
Reference in a new issue