packages feed

pixiv 0.1.0 → 0.1.1

raw patch · 10 files changed

+44/−45 lines, 10 filesdep −directorydep ~aesondep ~bytestringdep ~exceptions

Dependencies removed: directory

Dependency ranges changed: aeson, bytestring, exceptions, filepath, http-client, http-client-tls, lens, mtl, process, servant, servant-client, servant-client-core, template-haskell, text, time, transformers, transformers-base, zip-archive

Files

CHANGELOG.md view
@@ -1,5 +1,11 @@ # pixiv +## 0.1.1++- Remove password login that no longer works (see https://github.com/upbit/pixivpy/issues/158)++- Add popular sorting method for searching illusts (untested, needs premium account)+ ## 0.1.0  Initial release
README.md view
@@ -12,7 +12,7 @@  In most cases, it is enough to import only `Web.Pixiv`. If you want to use lenses to access and operate data types, you should import `Web.Pixiv.Types.Lens` as well. Pixiv API requires authentication before being accessed, thus the `PixivT` monad transformer provides an user-friendly and thread-safe interface-to manage, and renew access token on demand, where you just need to give the username and password of your pixiv account.+to manage, and renew access token on demand, where you just need to give the ~~username and password~~ refresh token (See https://github.com/upbit/pixivpy/issues/158) of your pixiv account.  ### Example @@ -26,7 +26,7 @@  main :: IO () main = do-  let credential = Password "username" "password"+  let credential = RefreshToken "token"   result <- runPixivT' credential action   case result of     Left err -> print err
pixiv.cabal view
@@ -1,6 +1,6 @@ cabal-version:   3.0 name:            pixiv-version:         0.1.0+version:         0.1.1 synopsis:        Pixiv API binding based on servant-client description:   Pixiv API binding based on servant-client.@@ -22,15 +22,20 @@   README.md  tested-with:-  GHC ==8.8.3 || ==8.8.4 || ==8.10.1 || ==8.10.2 || ==8.10.3+  GHC ==8.8.3+   || ==8.8.4+   || ==8.10.4+   || ==8.10.5+   || ==9.0.1+   || ==9.0.2  common common-attrs   build-depends:-    , aeson            ^>=1.5.4-    , base             >=4.10    && <5-    , bytestring       ^>=0.10.12-    , http-client      ^>=0.6.4-    , http-client-tls  ^>=0.3.5+    , aeson            >=1.5.4 && <2.1+    , base             >=4.10  && <5+    , bytestring       >=0.10  && <=0.12+    , http-client      >=0.5+    , http-client-tls    default-language:   Haskell2010   ghc-options:@@ -76,21 +81,20 @@ library   import:          common-attrs   build-depends:-    , base16-bytestring    ^>=0.1.1+    , base16-bytestring    >=0.1.1    && <1.1     , cryptohash-md5       ^>=0.11.100-    , directory            ^>=1.3.6     , exceptions           ^>=0.10.4     , filepath             ^>=1.4.2-    , lens                 ^>=4.19.2+    , lens                 >=4.19     && <5.2     , monad-control        ^>=1.0.2-    , mtl                  ^>=2.2.2-    , process              ^>=1.6.9-    , servant              ^>=0.18.2-    , servant-client       ^>=0.18.2-    , servant-client-core  ^>=0.18.2-    , template-haskell+    , mtl+    , process+    , servant              >=0.18.2   && <0.20+    , servant-client       >=0.18.2   && <0.20+    , servant-client-core  >=0.18.2   && <0.20+    , template-haskell     ^>=2.15.0 || ^>=2.16.0 || ^>=2.17.0 || ^>=2.18.0     , temporary            ^>=1.3-    , text                 ^>=1.2.3+    , text     , time                 ^>=1.9.3     , transformers         ^>=0.5.6     , transformers-base    ^>=0.4.5
src/Web/Pixiv.hs view
@@ -10,7 +10,7 @@ -- -- main :: IO () -- main = do---   let credential = Password "username" "password"+--   let credential = RefreshToken "token" --   illust <- runPixivT' credential $ getIllustDetail 70479649 --   print illust -- @@@ -21,7 +21,7 @@   ( module Web.Pixiv.API,     module Web.Pixiv.Types,     module Web.Pixiv.Types.PixivT,-    Credential (Password),+    Credential (..),   ) where 
src/Web/Pixiv/API.hs view
@@ -202,14 +202,12 @@   MonadPixiv m =>   -- | word   Text ->-  -- | sorting method-  Maybe SortingMethod ->   -- | page   Int ->   m [UserPreview]-searchUser searchWord sortingMethod (pageToOffset 30 -> offset) = do+searchUser searchWord (pageToOffset 30 -> offset) = do   p <- getAccessTokenWithAccpetLanguage-  ups <- clientIn (Proxy @SearchUser) Proxy p searchWord sortingMethod offset+  ups <- clientIn (Proxy @SearchUser) Proxy p searchWord offset   pure $ unNextUrl ups  -----------------------------------------------------------------------------
src/Web/Pixiv/API/PixivEntry.hs view
@@ -17,7 +17,7 @@  instance HasClient m api => HasClient m (PixivEntry :> api) where   type Client m (PixivEntry :> api) = (Token, Maybe Text) -> Client m api-  clientWithRoute pm Proxy req = \(unToken -> token, mLanguage) ->+  clientWithRoute pm Proxy req (unToken -> token, mLanguage) =     clientWithRoute pm (Proxy @api) $       req         & addHeader @Text "User-Agent" "PixivAndroidApp/5.0.175 (Android 6.0; PixivHaskell)"
src/Web/Pixiv/API/Search.hs view
@@ -23,6 +23,5 @@ type SearchUser =   PixivEntry :> "v1" :> "search" :> "user"     :> QueryParam' '[Required, Strict] "word" Text-    :> QueryParam "sort" SortingMethod     :> OffsetParam     :> Get '[JSON] UserPreviews
src/Web/Pixiv/Auth.hs view
@@ -56,24 +56,15 @@  -- | Authentication credentials for pixiv API. ----- Normally, users are supposed to create value of this data type using 'Password' constructor,--- then pass it to 'Web.Pixiv.Types.PixivT.runPixivT'.-data Credential-  = Password-      { username :: ByteString,-        password :: ByteString-      }-  | RefreshToken-      { cr_refreshToken :: Token-      }+-- Password authentication is no longer supported by pixiv.+-- You may consult <https://github.com/upbit/pixivpy/issues/158> to get the information of how to acquire refresh token.+-- Normally, users are supposed to create value of this data type and then pass it to 'Web.Pixiv.Types.PixivT.runPixivT'.+newtype Credential = RefreshToken+  { cr_refreshToken :: Token+  }   deriving stock (Show, Eq)  mkAuthParts :: Applicative m => Credential -> [PartM m]-mkAuthParts Password {..} =-  [ partBS "grant_type" "password",-    partBS "username" username,-    partBS "password" password-  ] mkAuthParts RefreshToken {..} =   [ partBS "grant_type" "refresh_token",     partBS "refresh_token" (encodeUtf8 . unToken $ cr_refreshToken)@@ -89,7 +80,7 @@  derivePixivJSON "oa_" ''OAuth2Token --- | Authentication failure reasions.+-- | Authentication failure reasons. data Errors   = InvalidRequest   | InvalidClient
src/Web/Pixiv/TH.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TemplateHaskellQuotes #-}  -- | Copyright: (c) 2021 The closed eye of love -- SPDX-License-Identifier: BSD-3-Clause
src/Web/Pixiv/Types.hs view
@@ -564,10 +564,11 @@  -- | Sorting method query parm. ----- See 'Web.Pixiv.API.searchIllust' and 'Web.Pixiv.API.searchUser'.+-- See 'Web.Pixiv.API.searchIllust'. data SortingMethod   = DateDesc   | DateAsc+  | PopularDesc   deriving stock (Show, Eq, Ord, Enum, Read)  deriveEnumToHttpApiData' ''SortingMethod