myanimelist-export 0.1.0.0 → 0.1.0.1
raw patch · 4 files changed
+45/−10 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +5/−0
- README.md +19/−0
- app/Main.hs +19/−9
- myanimelist-export.cabal +2/−1
ChangeLog.md view
@@ -1,3 +1,8 @@+## 0.1.0.1++* Executable: support for only downloading one list+* Add help for executable to README+ ## 0.1.0.0 * Initial release
README.md view
@@ -3,3 +3,22 @@ Export anime or manga lists from MyAnimeList in XML format. Uses the web interface, because the malappinfo API exports in a slightly different format which causes problems on importing.++## Executable++For convenience, an executable is provided which will export lists and save them+to local files. In order to run it, a configuration file must be created first.++On GNU/Linux: ~/.config/myanimelist-export.yaml++On Windows: %APPDATA%\myanimelist-export.yaml++```yaml+username: username+password: password+animeXmlPath: /path/to/save/anime.xml+mangaXmlPath: /path/to/save/manga.xml+```++Leave out the `animeXmlPath` or `mangaXmlPath` field if you don't wish to export+the respective list.
app/Main.hs view
@@ -19,6 +19,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} +import Data.Maybe (mapMaybe) import Data.Function (fix) import Data.ByteString (ByteString)@@ -27,13 +28,15 @@ import Data.Text (Text) import Data.Yaml (decodeFileEither)-import Data.Aeson.TH (deriveJSON, defaultOptions)+import Data.Aeson.TH (deriveJSON, defaultOptions, omitNothingFields) import Control.Monad import Control.Monad.IO.Class import Control.Exception (throwIO) +import Data.Functor.Compose (Compose(Compose))+ import Data.Conduit import Data.Conduit.Zlib (ungzip) import Data.Conduit.Binary (sinkFile)@@ -52,11 +55,11 @@ data Config = Config { username :: Text , password :: Text- , animeXmlPath :: FilePath- , mangaXmlPath :: FilePath+ , animeXmlPath :: Maybe FilePath+ , mangaXmlPath :: Maybe FilePath } -$(deriveJSON defaultOptions ''Config)+$(deriveJSON defaultOptions {omitNothingFields = True} ''Config) main :: IO ()@@ -65,11 +68,14 @@ Config {..} <- either throwIO pure =<< decodeFileEither configPath manager <- newTlsManager putStrLn "exporting"- [animeUri, mangaUri] <- exportLists username password manager [Anime, Manga]- putStrLn "downloading anime list"- downloadList manager animeUri animeXmlPath- putStrLn "downloading manga list"- downloadList manager mangaUri mangaXmlPath+ let wanted = mapMaybe sequence [ (Anime, animeXmlPath)+ , (Manga, mangaXmlPath)+ ]+ Compose uris <- exportLists username password manager $ Compose $+ fmap (\x -> (x, fst x)) wanted+ forM_ uris $ \((mt, fp), uri) -> do+ putStrLn $ "downloading " ++ mediaTypeString mt ++ " list"+ downloadList manager uri fp downloadList :: Manager -> URI -> FilePath -> IO () downloadList manager uri fp = do@@ -83,3 +89,7 @@ sourceBodyReader br = fix $ \r -> do x <- liftIO $ brRead br unless (BS.null x) (yield x >> r)++mediaTypeString :: MediaType -> String+mediaTypeString Anime = "anime"+mediaTypeString Manga = "manga"
myanimelist-export.cabal view
@@ -1,11 +1,12 @@ name: myanimelist-export-version: 0.1.0.0+version: 0.1.0.1 synopsis: Export from MyAnimeList description: Export anime or manga lists from MyAnimeList in XML format. Uses the web interface, because the malappinfo API exports in a slightly different format which causes problems on importing. homepage: https://github.com/mat8913/myanimelist-export#readme+bug-reports: https://github.com/mat8913/myanimelist-export/issues license: GPL-3 license-file: LICENSE author: Matthew Harm Bekkema