mannou package¶
Subpackages¶
Submodules¶
mannou.anilist module¶
Interraction module to AniList API.
See also
mannou.api : An implementation of this module.
-
mannou.anilist.
API_URL
= 'https://graphql.anilist.co'¶ AniList GraphQL API.
-
mannou.anilist.
QUERY
= '\nquery ($name: String) {\n Media (search: $name, type: MANGA) {\n id\n idMal\n title {\n romaji\n english\n native\n userPreferred\n }\n genres\n description\n siteUrl\n }\n}\n'¶ Default query that sent to AniList API.
-
class
mannou.anilist.
AniList
(name)¶ Bases:
object
Main class to communicate with AniList API.
-
api_url
¶ str – AniList API url
-
query
¶ str – Query that you want to sent to. It must be GraphQL query and exists in AniList API.
Parameters: name (str) – Name of the manga that you want to get. -
api_url
= 'https://graphql.anilist.co'
-
info
()¶ Get response in dictionary.
Returns: Parsed response from self.json. Return type: dict
-
json
()¶ Get response in JSON format.
Returns: Response from API server in JSON format. Return type: str
-
query
= '\nquery ($name: String) {\n Media (search: $name, type: MANGA) {\n id\n idMal\n title {\n romaji\n english\n native\n userPreferred\n }\n genres\n description\n siteUrl\n }\n}\n'
-
mannou.api module¶
Main Mannou API.
This module provide the easy way to use mannou.anilist.AniList and mannou.mannou.Mannou.
Note
Every functions in this module are imported in main package mannou. If you want to use mannou.api.get function, you only need to type mannou.get.
Please use mannou.AniList and mannou.Mannou
See also
mannou.AniList : main class for getting manga info. mannou.Mannou : main class for downloading manga.
-
mannou.api.
info
(search, parser=None)¶ Get an anime info.
It can search by url or title of the manga.
Parameters: search (str) – Anime title or url that you want to search.
Please remember searching by url takes longer than by name because it needs to parse an url first to get manga’s title.
Returns: Manga information. Return type: dict
-
mannou.api.
get
(url, parser=None)¶ Get manga chapters.
Returns: - obj: mannou.parser.Manga subclass. – It will return correct :obj: that handle url specified in mannou.Mannou.parsers.
- obj: parser – If parser is not None
-
mannou.api.
download
(url, parser=None, save_location=None, **limits)¶ Download chapter(s) in specified url.
It will download chapter(s) in and save it in your machine.
Parameters: - url (str) – URL of manga that you want to download.
- parser (class, optional) – Custom parser to parse url. It preferred that parser is subclassing mannou.parser.Manga.
- save_location (str, optional) – The save location, the default is
~/home
for UNIX or%USERPROFILE%\Manga
for Windows. - start (int, float, optional.) – The starting chapter, default to 0.
- end (int, float, optional.) – The last chapter that you want to download, default to None.
Returns: The saved location in your machine.
Return type: obj: of pathlib.Path
mannou.cli module¶
Main Mannou API.
A command line interface for mannou. This command:
$ mannou
is as same as:
$ python3 -m mannou
Example
For downloading manga from ‘https://manganelo.com/manga/aiura’, from chapter 2 to 3, you can type:
$ mannou https://manganelo.com/manga/aiura --start 2 --end 3
For further feature, please type:
$ mannou --help
-
mannou.cli.
main
()¶ Main function.
This function will run if you type:
$ mannou
in your terminal.
-
mannou.cli.
cli
()¶ Main cli function.
mannou.exception module¶
Main exception module.
Every exception must be listed in here.
-
exception
mannou.exception.
ParserNotFoundError
¶ Bases:
Exception
Raise when url there is no parser found in mannou.Mannou.parsers.
mannou.mannou module¶
Main module for downloading manga.
See also
mannou.api : An implementation for this module.
-
class
mannou.mannou.
Mannou
(url, parser=None)¶ Bases:
object
Main class for mannou.
This class used for unify the parsers and downloading manga.
-
parsers
¶ list
of :class: subclassingmannou.parser.Manga
– The stable parsers class that can parser certain site.
-
parser
¶ Class: subclassing mannou.parser.Manga
– The used parser.
-
manga
¶ Obj: of :class: subclassing mannou.parser.Manga
– An object that have an ability to parse url.
-
root
¶ pathlib.Path
– The save location in your machine.
Parameters: - url (str) – Manga’s url.
- parser (:class:, optional) – Custom class for parsing url. It recommended if this class subclassing mannou.parser.Manga
Raises: URLError
– If url is not an url.-
download
(start=0, end=None)¶ Download manga and save it in local machine.
Parameters: - start (int, float, optional) – The first chapter, default to 0.
- end (int, float, optional) – The last chapter that you want to download, default to None.
Returns: Saved manga directory if succeeded.
Return type: pathlib.Path
-
manga
= None
-
parse
()¶ Assign self.manga to
self.parser
Raises: ParserNotFoundError
– If self.parser is None
-
parser
= None
-
parsers
= [<class 'mannou.site.manganelo.Manganelo'>, <class 'mannou.site.komikid.Komikid'>]
-
root
= PosixPath('/home/docs/Manga')
-
set_parser
()¶ Set self.parser to correct parser.
-
mannou.parser module¶
Parser module for manga website.
This module is used for parsing manga website.
-
class
mannou.parser.
Image
¶ Bases:
tuple
Represent an image.
Parameters: - name (str) – The image name with extension.
- url (str) – The image source.
-
name
¶ Alias for field number 0
-
url
¶ Alias for field number 1
-
class
mannou.parser.
Chapter
¶ Bases:
tuple
Represent a chapter.
Parameters: - number (str) – The chapter number. str is used over int due there is some ‘decimal’ chapter, like 10.5. Why do not use float? It is weird to see chapter 1.0, I think.
- url (str) – The url of specific chapter.
-
number
¶ Alias for field number 0
-
url
¶ Alias for field number 1
-
class
mannou.parser.
Manga
(url)¶ Bases:
abc.ABC
An abstract base class for manga site parser.
Every parser class must inherit this class to ensure that every parser has the same functionality. The subclass also must has domain attribute to check whether url argument is valid url or not.
-
domain
¶ str – Domain of the site
Parameters: - url (str) – Url of the manga.
- soup (
BeautifulSoup
) – BeautifulSoup object from url.
Raises: URLError
– If not url is not a valid url.-
chapters
¶ list
ofmannou.parser.Chapter
– Available chapters.
-
classmethod
check_url
(url)¶ Check whether url is actually from self.domain or not.
Parameters: url (str) – URL that you want to check. Returns: True if it is url from self.domain, False otherwise. Return type: bool
-
filter_chapters
(start=0, stop=None)¶ Filter chapter in manga.
This is general algorithm for class parser that follow the rules. You may or may not override this method.
Parameters: - start (int, float, optional) – From what chapter? Default to 0.
- stop (int, float, optional) – What chapter to stop? default to None.
Returns: Filtered chapters.
Return type: list
ofmannou.parser.Chapter
-
get_chapter_images
(chapter_url)¶ Parse chapter_url.
Returns: - :obj:`list` of (obj: mannou.parser.Image) – List of images name and source location.
- You can override this method as static method.
-
title
¶ str – The title of manga
-
mannou.util module¶
Utility modules.
This module contains miscellaneous function used in every other packages and or modules.
Notes
If module grow complex, there is a chance to group similar function in the new modules.
-
mannou.util.
mkdir
(dirpath)¶ Create a directory.
Only create directory if
dirpath
is not exists.dirpath
must be an object frompathlib.Path
Parameters: dirpath ( pathlib.Path
) –Returns: True if successful, False otherwise. Return type: bool
-
mannou.util.
clear_screen
()¶ Clear terminal screen.
Only work for Windows and UNIX-like OS.
-
mannou.util.
is_url
(url)¶ Validate url.
Parameters: url (str) – An url to validate. Returns: True if valid url, False otherwise. Return type: bool
-
mannou.util.
get_200
(url, max_retries=10, **options)¶ Sends GET request until it get 200.
By default, it will try 10 times before raise.
Parameters: - url (str) – URL that you want to GET
- max_retries (int, optional) – Decide how many times sending GET request before raise.
- user_agent (str, optional) – User agent that you want to use
- stream (bool, optional) – Decide if you want to stream or not.
Returns: Return type: requests.Response
Raises: HTTPError
– If max_retries exceeded.
-
mannou.util.
make_soup
(url)¶ Create bs4.BeautifulSoup object from url.
Parameters: url (str) – URL that you want to scrap. Returns: Return type: bs4.BeautifulSoup
Raises: exception.HTTPError
– From mannou.util.get_200
-
mannou.util.
download
(url, filepath)¶ Downloader, with progress bar.
Send GET request and save it to local computer.
Parameters: - url (str) – URL that you want to download.
- filepath (
str
) – Saved file location
Module contents¶
Mannou Manga Downloader¶
Mannou is a manga downloader for downloading manga from various sites. Basic usage:
>>> import mannou
>>> url = 'https://manganelo.com/manga/aiura'
>>> manga = mannou.get(url)
>>> str(manga) # or manga.title
Aiura
>>> manga[0] # or manga.chapters[0]
Chapter(number='1', url='https://manganelo.com/chapter/aiura/chapter_1')
>>> images = manga.get_chapter_images(manga[0].url)
>>> images[0]
Image(name='1.jpg', url='http://s8.mkklcdn.com/mangakakalot/a1/aiura/chapter_1/1.jpg')
>>> mannou.download(url, start=1, end=5) # Download every chapters 1 until 5 in 'Aiura' and save it to default location (~/Manga or %USERPROFILE%\Manga)
The other methods and properties are supported. Full documentation is at <https://mannou.readthedocs.io>.