From f395ca7a41ed6913334ca22acb0e39d56e813e7d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 8 May 2015 13:39:00 -0400 Subject: [PATCH] Improve quvi 0.4 output parsing to handle cases wher there is no known filename extension. This is currently the case when using quvi with youtube. In this case, the extension ".m" will be used. --- Command/AddUrl.hs | 2 +- Command/ImportFeed.hs | 2 +- Utility/Quvi.hs | 6 +++--- debian/changelog | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index 5defc52d97..6474f26141 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -178,7 +178,7 @@ startWeb relaxed optfile pathdepth s = go $ fromMaybe bad $ parseURI urlstring pathmax <- liftIO $ fileNameLengthLimit "." let file = flip fromMaybe optfile $ truncateFilePath pathmax $ sanitizeFilePath $ - Quvi.pageTitle page ++ "." ++ Quvi.linkSuffix link + Quvi.pageTitle page ++ "." ++ fromMaybe "m" (Quvi.linkSuffix link) showStart "addurl" file next $ performQuvi relaxed urlstring (Quvi.linkUrl link) file #else diff --git a/Command/ImportFeed.hs b/Command/ImportFeed.hs index 2a278dea17..379350c80e 100644 --- a/Command/ImportFeed.hs +++ b/Command/ImportFeed.hs @@ -196,7 +196,7 @@ performDownload opts cache todownload = case location todownload of Just link -> do let videourl = Quvi.linkUrl link checkknown videourl $ - rundownload videourl ("." ++ Quvi.linkSuffix link) $ \f -> + rundownload videourl ("." ++ fromMaybe "m" (Quvi.linkSuffix link)) $ \f -> maybeToList <$> addUrlFileQuvi (relaxedOpt opts) quviurl videourl f #else return False diff --git a/Utility/Quvi.hs b/Utility/Quvi.hs index 0669e7351a..4dc15fe927 100644 --- a/Utility/Quvi.hs +++ b/Utility/Quvi.hs @@ -30,7 +30,7 @@ data Page = Page } deriving (Show) data Link = Link - { linkSuffix :: String + { linkSuffix :: Maybe String , linkUrl :: URLString } deriving (Show) @@ -43,7 +43,7 @@ instance FromJSON Page where instance FromJSON Link where parseJSON (Object v) = Link - <$> v .: "file_suffix" + <$> v .:? "file_suffix" <*> v .: "url" parseJSON _ = mzero @@ -53,7 +53,7 @@ parseEnum s = Page <$> get "QUVI_MEDIA_PROPERTY_TITLE" <*> ((:[]) <$> ( Link - <$> get "QUVI_MEDIA_STREAM_PROPERTY_CONTAINER" + <$> Just <$> (get "QUVI_MEDIA_STREAM_PROPERTY_CONTAINER") <*> get "QUVI_MEDIA_STREAM_PROPERTY_URL" ) ) diff --git a/debian/changelog b/debian/changelog index fc7fcd46c8..e677334dfc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -32,6 +32,9 @@ git-annex (5.20150421) UNRELEASED; urgency=medium Closes: #698559 (fsck can still need to write to the repository if it find problems, but a successful fsck can be done read-only) + * Improve quvi 0.4 output parsing to handle cases wher there is no known + filename extension. This is currently the case when using quvi with + youtube. In this case, the extension ".m" will be used. * Dropped support for older versions of yesod, warp, and dbus than the ones in Debian Jessie. * Switch from the obsolete dataenc library for base64 encoding to sandi.