1 from manga_py
.provider
import Provider
2 from .helpers
.std
import Std
5 class MangaPandaCom(Provider
, Std
):
6 _cdn
= 'https://img.mghubcdn.com/file/imghub'
7 _api_url
= 'https://api.mghubcdn.com/graphql'
9 def get_chapter_index(self
) -> str:
10 return self
.chapter_for_json()
12 def get_content(self
):
13 return self
._get
_content
('{}/manga/{}')
15 def get_manga_name(self
) -> str:
16 return self
._get
_name
(r
'\.\w{2,7}/manga/([^/]+)')
18 def get_chapters(self
):
19 # curl 'https://api.mghubcdn.com/graphql' -H 'Content-Type: application/json' --data-raw '{"query": "{latestPopular(x:mr02){id}manga(x:mr02,slug:\"mahou-tsukai-no-yome\"){id,rank,title,slug,status,image,latestChapter,author,artist,genres,description,alternativeTitle,mainSlug,isYaoi,isPorn,isSoftPorn,unauthFile,noCoverAd,isLicensed,createdDate,updatedDate,chapters{id,number,title,slug,date}}}"}'
22 'id', 'rank', 'title', 'slug', 'status', 'chapters'
26 r
'{manga(x:mr02,slug:"%(name)s"){%(keys)s{id,number,title,slug,date}}}'
27 % {'name': self
.manga_name
, 'keys': ','.join(keys
)}
30 chapters
= data
.get('data', {}).get('manga', {}).get('chapters', []) # type: list
36 r
'{chapter(x:mr02,slug:"%(name)s",number:%(number)f){id,title,mangaID,number,slug,date,pages}}'
37 % {'name': self
.manga_name
, 'number': self
.chapter
['number']}
40 images
= data
.get('data', {}).get('chapter', {}).get('pages', [])
42 if type(images
) == str:
43 images
= self
.json
.loads(images
) # type: list
45 return list(map(lambda x
: '{}/{}'.format(self
._cdn
, images
[x
]), images
))
48 return self
._cover
_from
_content
('.manga-thumb')
50 def chapter_for_json(self
) -> str:
51 number
= str(self
.chapter
['number']).replace('.', '-')
52 slug
= self
.chapter
['slug']
54 return '{}_{}'.format(number
, slug
)
56 def _api(self
, query
: str) -> dict:
57 response
= self
.http().requests(self
._api
_url
, method
='post', data
={
60 'Accept': 'application/json',
63 return response
.json()