From 1694932d1d7f4f71ffe5676bfe05d4235a4f23f1 Mon Sep 17 00:00:00 2001 From: Dhruv Kanojia Date: Thu, 6 Jul 2017 20:24:44 +0530 Subject: [PATCH] Support for #11 Read the Changelog for more information and also do check the ReadMe for updated commands. --- .gitignore | 1 + Changelog.md | 3 ++- ReadMe.md | 5 ++++- comic_dl/__version__.py | 2 +- comic_dl/comic_dl.py | 5 ++++- comic_dl/honcho.py | 16 ++++++++-------- comic_dl/sites/acQQ.py | 15 ++++++++++++--- comic_dl/sites/comicNaver.py | 17 ++++++++++++++--- comic_dl/sites/foolSlide.py | 17 ++++++++++++++--- comic_dl/sites/mangaFox.py | 17 ++++++++++++++--- comic_dl/sites/mangaHere.py | 17 ++++++++++++++--- comic_dl/sites/omgBeauPeep.py | 20 ++++++++++++++++++-- comic_dl/sites/rawSenManga.py | 17 ++++++++++++++--- comic_dl/sites/readcomicOnlineto.py | 18 +++++++++++++++--- docs/Changelog.md | 3 ++- docs/index.md | 5 ++++- 16 files changed, 141 insertions(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index 8754ef1..7ea593a 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,4 @@ Temporary Items *.spec comic_dl/Logo.ico comic_dl/build/__main__/warn__main__.txt +*.old diff --git a/Changelog.md b/Changelog.md index 684727e..f3d2819 100644 --- a/Changelog.md +++ b/Changelog.md @@ -35,4 +35,5 @@ - Downloader now prints file size, internet speed [2017.06.12] - Added Support for [ac.qq.com](http://ac.qq.com) [2017.06.15] - Fix for #23 [2017.06.30] -- Custom Download Location Support Added (#20) [2017.06.30] \ No newline at end of file +- Custom Download Location Support Added (#20) [2017.06.30] +- Support to download only selected chapters (range) [2017.07.06] \ No newline at end of file diff --git a/ReadMe.md b/ReadMe.md index 34c2ec4..030a49c 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -139,9 +139,12 @@ Currently, the script supports these arguments : -v,--verbose Enables Verbose logging. --sorting Sorts the download order.(VALUES = asc, ascending,old,new,desc,descending,latest,new) -dd,--download-directory Specifies custom download location for the comics/manga. +-rn,--range Selects the range of Chapters to download (Default = All) [ Ex : --range 1-10 (This will download first 10 episodes of a series)] ``` #### Note : -Some websites like bato.to don't let you view some pages if you're not logged in. You'll have to create an account and pass the login information to the script via `-p` and `-u` arguments. +1.) Some websites like bato.to don't let you view some pages if you're not logged in. You'll have to create an account and pass the login information to the script via `-p` and `-u` arguments. + +2.) Since omgbeaupeep is uh... well, you just need to pass the absolute chapter numbers in the range section for that. For eg : Check out [Richie Rich](http://www.omgbeaupeep.com/comics/Richie_Rich/647/). If you want to download first 600 episodes, you would pass : --range 001-600. Just check the URLs for those chapters and pass accordingly. ## Youtube Tutorial [![Check The YouTube Tutorial](https://img.youtube.com/vi/TmQYhLHEZxA/0.jpg)](https://www.youtube.com/watch?v=TmQYhLHEZxA) diff --git a/comic_dl/__version__.py b/comic_dl/__version__.py index 1562e7c..f454d3d 100644 --- a/comic_dl/__version__.py +++ b/comic_dl/__version__.py @@ -1,4 +1,4 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -__version__ = "2017.06.30" \ No newline at end of file +__version__ = "2017.07.06" \ No newline at end of file diff --git a/comic_dl/comic_dl.py b/comic_dl/comic_dl.py index f989791..54085df 100644 --- a/comic_dl/comic_dl.py +++ b/comic_dl/comic_dl.py @@ -19,6 +19,7 @@ class ComicDL(object): parser.add_argument('--version', action='store_true', help='Shows version and exits.') parser.add_argument('-s', '--sorting', nargs=1, help='Decides downloading order of chapters.') parser.add_argument('-dd', '--download-directory', nargs=1, help='Decides the download directory of the comics/manga.') + parser.add_argument('-rn', '--range', nargs=1, help='Specifies the range of chapters to download.', default='All') required_args = parser.add_argument_group('Required Arguments :') required_args.add_argument('-i', '--input', nargs=1, help='Inputs the URL to anime.') @@ -56,10 +57,12 @@ class ComicDL(object): args.sorting = ["ascending"] if not args.download_directory: args.download_directory = [os.getcwd()] + if type(args.range) == list: + args.range = args.range[0] start_time = time.time() honcho.Honcho().checker(comic_url=str(args.input[0]).strip(), current_directory=os.getcwd(), - sorting_order=args.sorting[0], logger=logger, download_directory=args.download_directory[0]) + sorting_order=args.sorting[0], logger=logger, download_directory=args.download_directory[0], chapter_range=args.range) end_time = time.time() total_time = end_time - start_time print("Total Time Taken To Complete : %s" % total_time) diff --git a/comic_dl/honcho.py b/comic_dl/honcho.py index 1eacad5..d00095b 100644 --- a/comic_dl/honcho.py +++ b/comic_dl/honcho.py @@ -18,7 +18,7 @@ import globalFunctions class Honcho(object): - def checker(self, comic_url, download_directory, **kwargs): + def checker(self, comic_url, download_directory, chapter_range, **kwargs): user_name = kwargs.get("username") password = kwargs.get("password") @@ -37,7 +37,7 @@ class Honcho(object): if domain in fool_slide: foolSlide.FoolSlide(manga_url=comic_url, logger=logging, current_directory=current_directory, - sorting_order=sorting, log_flag=log_flag, download_directory=download_directory) + sorting_order=sorting, log_flag=log_flag, download_directory=download_directory, chapter_range=chapter_range) return 0 elif domain in ["www.readcomiconline.to", "readcomiconline.to"]: readcomicOnlineto.ReadComicOnlineTo(manga_url=comic_url, logger=logging, @@ -45,27 +45,27 @@ class Honcho(object): return 0 elif domain in ["www.comic.naver.com", "comic.naver.com"]: comicNaver.ComicNaver(manga_url=comic_url, logger=logging, current_directory=current_directory, - sorting_order=sorting, log_flag=log_flag, download_directory=download_directory) + sorting_order=sorting, log_flag=log_flag, download_directory=download_directory, chapter_range=chapter_range) return 0 elif domain in ["www.mangahere.co", "mangahere.co"]: mangaHere.MangaHere(manga_url=comic_url, logger=logging, current_directory=current_directory, - sorting_order=sorting, log_flag=log_flag, download_directory=download_directory) + sorting_order=sorting, log_flag=log_flag, download_directory=download_directory, chapter_range=chapter_range) return 0 elif domain in ["www.raw.senmanga.com", "raw.senmanga.com"]: rawSenManga.RawSenaManga(manga_url=comic_url, logger=logging, current_directory=current_directory, - sorting_order=sorting, log_flag=log_flag, download_directory=download_directory) + sorting_order=sorting, log_flag=log_flag, download_directory=download_directory, chapter_range=chapter_range) return 0 elif domain in ["www.mangafox.me", "mangafox.me"]: mangaFox.MangaFox(manga_url=comic_url, logger=logging, current_directory=current_directory, - sorting_order=sorting, log_flag=log_flag, download_directory=download_directory) + sorting_order=sorting, log_flag=log_flag, download_directory=download_directory, chapter_range=chapter_range) return 0 elif domain in ["www.omgbeaupeep.com", "omgbeaupeep.com"]: omgBeauPeep.OmgBeauPeep(manga_url=comic_url, logger=logging, current_directory=current_directory, - sorting_order=sorting, log_flag=log_flag, download_directory=download_directory) + sorting_order=sorting, log_flag=log_flag, download_directory=download_directory, chapter_range=chapter_range) return 0 elif domain in ["www.ac.qq.com", "ac.qq.com"]: acQQ.AcQq(manga_url=comic_url, logger=logging, current_directory=current_directory, - sorting_order=sorting, log_flag=log_flag, download_directory=download_directory) + sorting_order=sorting, log_flag=log_flag, download_directory=download_directory, chapter_range=chapter_range) return 0 elif domain in ["www.kissmanga.com", "kissmanga.com"]: # kissManga.KissManga(manga_url = comic_url, logger = logging, current_directory = current_directory, sorting_order = sorting) diff --git a/comic_dl/sites/acQQ.py b/comic_dl/sites/acQQ.py index e3750e4..f79532e 100644 --- a/comic_dl/sites/acQQ.py +++ b/comic_dl/sites/acQQ.py @@ -9,7 +9,7 @@ Original code for ac.qq.com : https://github.com/abcfy2/getComic/ """ class AcQq(object): - def __init__(self, manga_url, download_directory, **kwargs): + def __init__(self, manga_url, download_directory, chapter_range, **kwargs): current_directory = kwargs.get("current_directory") self.logging = kwargs.get("log_flag") self.sorting = kwargs.get("sorting_order") @@ -18,7 +18,7 @@ class AcQq(object): self.single_chapter(manga_url, self.comic_name, download_directory) else: self.full_series(comic_url=manga_url, comic_name=self.comic_name, sorting=self.sorting, - download_directory=download_directory) + download_directory=download_directory, chapter_range=chapter_range) @@ -64,7 +64,7 @@ class AcQq(object): globalFunctions.GlobalFunctions().downloader(image_link, file_name, comic_url, directory_path, log_flag=self.logging) - def full_series(self, comic_url, comic_name, sorting, download_directory, **kwargs): + def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, **kwargs): chapter_list = "http://m.ac.qq.com/GetData/getChapterList?id=" + str(comic_name) source, cookies = globalFunctions.GlobalFunctions().page_downloader(manga_url=chapter_list) content_json = json.loads(str(source)) @@ -82,6 +82,15 @@ class AcQq(object): all_links.append(chapter_url) logging.debug("all_links : %s" % all_links) + if chapter_range != "All": + # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! + starting = int(str(chapter_range).split("-")[0]) - 1 + ending = int(str(chapter_range).split("-")[1]) + indexes = [x for x in range(starting, ending)] + # [::-1] in sub_list in beginning to start this from the 1st episode and at the last, it is to reverse the list again, becasue I'm reverting it again at the end. + all_links = [all_links[::-1][x] for x in indexes][::-1] + else: + all_links = all_links if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: diff --git a/comic_dl/sites/comicNaver.py b/comic_dl/sites/comicNaver.py index acfc6ac..dfa9c3b 100644 --- a/comic_dl/sites/comicNaver.py +++ b/comic_dl/sites/comicNaver.py @@ -8,14 +8,14 @@ import logging class ComicNaver(object): - def __init__(self, manga_url, download_directory, **kwargs): + def __init__(self, manga_url, download_directory, chapter_range, **kwargs): current_directory = kwargs.get("current_directory") self.logging = kwargs.get("log_flag") self.sorting = kwargs.get("sorting_order") self.comic_name = self.name_cleaner(manga_url) if "list.nhn" in manga_url: - self.full_series(manga_url, self.comic_name, self.sorting, download_directory) + self.full_series(manga_url, self.comic_name, self.sorting, download_directory, chapter_range=chapter_range) elif "detail.nhn" in manga_url: self.single_chapter(manga_url, self.comic_name, download_directory) @@ -53,7 +53,7 @@ class ComicNaver(object): file_name = "0" + str(image_list.index(link)) + ".jpg" # 0 for #18 (Leading 0s) globalFunctions.GlobalFunctions().downloader(link, file_name, comic_url, directory_path, log_flag=self.logging) - def full_series(self, comic_url, comic_name, sorting, download_directory, **kwargs): + def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, **kwargs): source, cookies = globalFunctions.GlobalFunctions().page_downloader(manga_url=comic_url) # print(source) @@ -66,6 +66,17 @@ class ComicNaver(object): all_links.append(chapter_url) logging.debug("All Links : %s" % all_links) + # Uh, so the logic is that remove all the unnecessary chapters beforehand and then pass the list for further operations. + if chapter_range != "All": + # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! + starting = int(str(chapter_range).split("-")[0]) - 1 + ending = int(str(chapter_range).split("-")[1]) + indexes = [x for x in range(starting, ending)] + # [::-1] in sub_list in beginning to start this from the 1st episode and at the last, it is to reverse the list again, becasue I'm reverting it again at the end. + all_links = [all_links[::-1][x] for x in indexes][::-1] + else: + all_links = all_links + if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: self.single_chapter(comic_url=chap_link, comic_name=comic_name, download_directory=download_directory) diff --git a/comic_dl/sites/foolSlide.py b/comic_dl/sites/foolSlide.py index 3d89b0b..1e7fde5 100644 --- a/comic_dl/sites/foolSlide.py +++ b/comic_dl/sites/foolSlide.py @@ -9,7 +9,7 @@ import logging class FoolSlide(object): - def __init__(self, manga_url, download_directory, **kwargs): + def __init__(self, manga_url, download_directory, chapter_range, **kwargs): current_directory = kwargs.get("current_directory") self.logging = kwargs.get("log_flag") @@ -18,7 +18,7 @@ class FoolSlide(object): self.manga_name = self.name_cleaner(manga_url) if "/reader/series/" in manga_url: - self.full_manga(manga_url=manga_url, comic_name=self.manga_name, sorting=self.sorting, download_directory=download_directory) + self.full_manga(manga_url=manga_url, comic_name=self.manga_name, sorting=self.sorting, download_directory=download_directory, chapter_range=chapter_range) elif "/reader/read/" in manga_url: self.single_chapter(manga_url, self.manga_name, download_directory) @@ -69,7 +69,7 @@ class FoolSlide(object): return anime_name - def full_manga(self, manga_url, comic_name, sorting, download_directory, **kwargs): + def full_manga(self, manga_url, comic_name, sorting, download_directory, chapter_range, **kwargs): source, cookies = globalFunctions.GlobalFunctions().page_downloader(manga_url=manga_url) # print(source) chapter_text = source.findAll('div', {'class': 'title'}) @@ -82,6 +82,17 @@ class FoolSlide(object): all_links.append(url) logging.debug("All Links : %s" % all_links) + # Uh, so the logic is that remove all the unnecessary chapters beforehand and then pass the list for further operations. + if chapter_range != "All": + # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! + starting = int(str(chapter_range).split("-")[0]) - 1 + ending = int(str(chapter_range).split("-")[1]) + indexes = [x for x in range(starting, ending)] + # [::-1] in sub_list in beginning to start this from the 1st episode and at the last, it is to reverse the list again, becasue I'm reverting it again at the end. + all_links = [all_links[::-1][x] for x in indexes][::-1] + else: + all_links = all_links + if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: self.single_chapter(chapter_url=chap_link, comic_name=comic_name, download_directory=download_directory) diff --git a/comic_dl/sites/mangaFox.py b/comic_dl/sites/mangaFox.py index 3d15ccc..dbc51c8 100644 --- a/comic_dl/sites/mangaFox.py +++ b/comic_dl/sites/mangaFox.py @@ -9,7 +9,7 @@ import time class MangaFox(object): - def __init__(self, manga_url, download_directory, **kwargs): + def __init__(self, manga_url, download_directory, chapter_range, **kwargs): current_directory = kwargs.get("current_directory") self.logging = kwargs.get("log_flag") @@ -18,7 +18,7 @@ class MangaFox(object): url_split = str(manga_url).split("/") if len(url_split) is 6: - self.full_series(comic_url=manga_url, comic_name=self.comic_name, sorting=self.sorting, download_directory=download_directory) + self.full_series(comic_url=manga_url, comic_name=self.comic_name, sorting=self.sorting, download_directory=download_directory, chapter_range=chapter_range) else: self.single_chapter(manga_url, self.comic_name, download_directory) @@ -68,12 +68,23 @@ class MangaFox(object): return 0 - def full_series(self, comic_url, comic_name, sorting, download_directory, **kwargs): + def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, **kwargs): source, cookies = globalFunctions.GlobalFunctions().page_downloader(manga_url=comic_url) all_links = re.findall(r"href=\"(.*?)\" title=\"Thanks for", str(source)) logging.debug("All Links : %s" % all_links) + # Uh, so the logic is that remove all the unnecessary chapters beforehand and then pass the list for further operations. + if chapter_range != "All": + # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! + starting = int(str(chapter_range).split("-")[0]) - 1 + ending = int(str(chapter_range).split("-")[1]) + indexes = [x for x in range(starting, ending)] + # [::-1] in sub_list in beginning to start this from the 1st episode and at the last, it is to reverse the list again, becasue I'm reverting it again at the end. + all_links = [all_links[::-1][x] for x in indexes][::-1] + else: + all_links = all_links + if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: self.single_chapter(comic_url=str(chap_link), comic_name=comic_name) diff --git a/comic_dl/sites/mangaHere.py b/comic_dl/sites/mangaHere.py index 770832e..24b8c76 100644 --- a/comic_dl/sites/mangaHere.py +++ b/comic_dl/sites/mangaHere.py @@ -8,7 +8,7 @@ import logging class MangaHere(object): - def __init__(self, manga_url, download_directory, **kwargs): + def __init__(self, manga_url, download_directory, chapter_range, **kwargs): current_directory = kwargs.get("current_directory") self.logging = kwargs.get("log_flag") @@ -18,7 +18,7 @@ class MangaHere(object): url_split = str(manga_url).split("/") if len(url_split) is 6: - self.full_series(comic_url=manga_url, comic_name=self.comic_name, sorting=self.sorting, download_directory=download_directory) + self.full_series(comic_url=manga_url, comic_name=self.comic_name, sorting=self.sorting, download_directory=download_directory, chapter_range=chapter_range) else: self.single_chapter(manga_url, self.comic_name, download_directory) @@ -72,7 +72,7 @@ class MangaHere(object): return anime_name - def full_series(self, comic_url, comic_name, sorting, download_directory, **kwargs): + def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range,**kwargs): source, cookies = globalFunctions.GlobalFunctions().page_downloader(manga_url=comic_url) all_links = re.findall(r"class=\"color_0077\" href=\"(.*?)\"", str(source)) @@ -87,6 +87,17 @@ class MangaHere(object): logging.debug("All Links : %s" % all_links) + # Uh, so the logic is that remove all the unnecessary chapters beforehand and then pass the list for further operations. + if chapter_range != "All": + # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! + starting = int(str(chapter_range).split("-")[0]) - 1 + ending = int(str(chapter_range).split("-")[1]) + indexes = [x for x in range(starting, ending)] + # [::-1] in sub_list in beginning to start this from the 1st episode and at the last, it is to reverse the list again, becasue I'm reverting it again at the end. + chapter_links = [chapter_links[::-1][x] for x in indexes][::-1] + else: + chapter_links = chapter_links + if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in chapter_links: self.single_chapter(comic_url=str(chap_link), comic_name=comic_name, download_directory=download_directory) diff --git a/comic_dl/sites/omgBeauPeep.py b/comic_dl/sites/omgBeauPeep.py index 00f5104..c2cf49d 100644 --- a/comic_dl/sites/omgBeauPeep.py +++ b/comic_dl/sites/omgBeauPeep.py @@ -8,13 +8,20 @@ import logging class OmgBeauPeep(object): - def __init__(self, manga_url, download_directory, **kwargs): + def __init__(self, manga_url, download_directory, chapter_range, **kwargs): current_directory = kwargs.get("current_directory") self.logging = kwargs.get("log_flag") self.sorting = kwargs.get("sorting_order") self.comic_name = self.name_cleaner(manga_url) - self.single_chapter(manga_url, self.comic_name, download_directory) + + # Since this website doesn't seem to have a dedicated page for series, I need to make a function just for the sake of range, huh. *sigh* + # You need to pass the ABSOLUTE chapter number for this website though. Otherwise, it'll generate wrong links to chapter and won't download anything. + # Please spare me such hard work. + if chapter_range != "All": + self.range_maker(manga_url=manga_url, chapter_range=chapter_range, download_directory=download_directory) + else: + self.single_chapter(manga_url, self.comic_name, download_directory) def name_cleaner(self, url): initial_name = str(url).split("/")[4].strip() @@ -49,3 +56,12 @@ class OmgBeauPeep(object): logging.debug("Chapter Url : %s" % chapter_url) logging.debug("Image Link : %s" % image_link) globalFunctions.GlobalFunctions().downloader(image_link, file_name, chapter_url, directory_path, log_flag=self.logging) + + def range_maker(self, manga_url, chapter_range, download_directory): + starting = int(str(chapter_range).split("-")[0]) + ending = int(str(chapter_range).split("-")[1]) + for comic_chapter in range(starting, ending): + chapter_number = str(manga_url).split("/")[5].strip() + # Dirty Hack, 'cause I'm a HackerMan! (Dumb Joke) + new_url = str(manga_url).replace(str(chapter_number), str(comic_chapter)) + self.single_chapter(new_url, self.comic_name, download_directory) \ No newline at end of file diff --git a/comic_dl/sites/rawSenManga.py b/comic_dl/sites/rawSenManga.py index fcf8dfe..05b318f 100644 --- a/comic_dl/sites/rawSenManga.py +++ b/comic_dl/sites/rawSenManga.py @@ -8,7 +8,7 @@ import logging class RawSenaManga(object): - def __init__(self, manga_url, download_directory, **kwargs): + def __init__(self, manga_url, download_directory, chapter_range, **kwargs): current_directory = kwargs.get("current_directory") self.logging = kwargs.get("log_flag") self.sorting = kwargs.get("sorting_order") @@ -16,7 +16,7 @@ class RawSenaManga(object): url_split = str(manga_url).split("/") if len(url_split) is 5: - self.full_series(comic_url=manga_url, comic_name=self.comic_name, sorting=self.sorting, download_directory=download_directory) + self.full_series(comic_url=manga_url, comic_name=self.comic_name, sorting=self.sorting, download_directory=download_directory, chapter_range=chapter_range) else: self.single_chapter(manga_url, self.comic_name, download_directory) @@ -62,7 +62,7 @@ class RawSenaManga(object): cookies=cookies_main, log_flag=self.logging) return 0 - def full_series(self, comic_url, comic_name, sorting, download_directory, **kwargs): + def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, **kwargs): series_name_raw = str(comic_url).split("/")[3].strip() source, cookies = globalFunctions.GlobalFunctions().page_downloader(manga_url=comic_url) # a href="/Flying-Witch-Ishizuka-Chihiro/34/1" @@ -71,6 +71,17 @@ class RawSenaManga(object): all_links = list(re.findall(link_regex, str(source))) logging.debug("All Links : %s" % all_links) + # Uh, so the logic is that remove all the unnecessary chapters beforehand and then pass the list for further operations. + if chapter_range != "All": + # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! + starting = int(str(chapter_range).split("-")[0]) - 1 + ending = int(str(chapter_range).split("-")[1]) + indexes = [x for x in range(starting, ending)] + # [::-1] in sub_list in beginning to start this from the 1st episode and at the last, it is to reverse the list again, becasue I'm reverting it again at the end. + all_links = [all_links[::-1][x] for x in indexes][::-1] + else: + all_links = all_links + if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for link in all_links: chap_link = "http://raw.senmanga.com/" + str(series_name_raw) + "/" + str( diff --git a/comic_dl/sites/readcomicOnlineto.py b/comic_dl/sites/readcomicOnlineto.py index beb1f10..8c825ee 100644 --- a/comic_dl/sites/readcomicOnlineto.py +++ b/comic_dl/sites/readcomicOnlineto.py @@ -8,7 +8,7 @@ import logging class ReadComicOnlineTo(object): - def __init__(self, manga_url, download_directory, **kwargs): + def __init__(self, manga_url, download_directory, chapter_range, **kwargs): current_directory = kwargs.get("current_directory") self.logging = kwargs.get("log_flag") @@ -23,7 +23,7 @@ class ReadComicOnlineTo(object): url_split = str(manga_url).split("/") if len(url_split) is 5: - self.full_series(comic_url=manga_url.replace("&readType=1", ""), comic_name=self.comic_name, sorting=self.sorting, download_directory=download_directory) + self.full_series(comic_url=manga_url.replace("&readType=1", ""), comic_name=self.comic_name, sorting=self.sorting, download_directory=download_directory, chapter_range=chapter_range) else: self.single_chapter(manga_url, self.comic_name, download_directory) @@ -60,7 +60,7 @@ class ReadComicOnlineTo(object): return manga_name - def full_series(self, comic_url, comic_name, sorting, download_directory, **kwargs): + def full_series(self, comic_url, comic_name, sorting, download_directory, chapter_range, **kwargs): series_name_raw = str(comic_url).split("/")[3].strip() source, cookies = globalFunctions.GlobalFunctions().page_downloader(manga_url=comic_url) @@ -68,6 +68,18 @@ class ReadComicOnlineTo(object): all_links = list(re.findall(link_regex, str(source))) logging.debug("All Links : %s" % all_links) + + # Uh, so the logic is that remove all the unnecessary chapters beforehand and then pass the list for further operations. + if chapter_range != "All": + # -1 to shift the episode number accordingly to the INDEX of it. List starts from 0 xD! + starting = int(str(chapter_range).split("-")[0]) - 1 + ending = int(str(chapter_range).split("-")[1]) + indexes = [x for x in range(starting, ending)] + # [::-1] in sub_list in beginning to start this from the 1st episode and at the last, it is to reverse the list again, becasue I'm reverting it again at the end. + all_links = [all_links[::-1][x] for x in indexes][::-1] + else: + all_links = all_links + if str(sorting).lower() in ['new', 'desc', 'descending', 'latest']: for chap_link in all_links: chap_link = "http://readcomiconline.to/Comic/" + chap_link diff --git a/docs/Changelog.md b/docs/Changelog.md index 684727e..f3d2819 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -35,4 +35,5 @@ - Downloader now prints file size, internet speed [2017.06.12] - Added Support for [ac.qq.com](http://ac.qq.com) [2017.06.15] - Fix for #23 [2017.06.30] -- Custom Download Location Support Added (#20) [2017.06.30] \ No newline at end of file +- Custom Download Location Support Added (#20) [2017.06.30] +- Support to download only selected chapters (range) [2017.07.06] \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 34c2ec4..030a49c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -139,9 +139,12 @@ Currently, the script supports these arguments : -v,--verbose Enables Verbose logging. --sorting Sorts the download order.(VALUES = asc, ascending,old,new,desc,descending,latest,new) -dd,--download-directory Specifies custom download location for the comics/manga. +-rn,--range Selects the range of Chapters to download (Default = All) [ Ex : --range 1-10 (This will download first 10 episodes of a series)] ``` #### Note : -Some websites like bato.to don't let you view some pages if you're not logged in. You'll have to create an account and pass the login information to the script via `-p` and `-u` arguments. +1.) Some websites like bato.to don't let you view some pages if you're not logged in. You'll have to create an account and pass the login information to the script via `-p` and `-u` arguments. + +2.) Since omgbeaupeep is uh... well, you just need to pass the absolute chapter numbers in the range section for that. For eg : Check out [Richie Rich](http://www.omgbeaupeep.com/comics/Richie_Rich/647/). If you want to download first 600 episodes, you would pass : --range 001-600. Just check the URLs for those chapters and pass accordingly. ## Youtube Tutorial [![Check The YouTube Tutorial](https://img.youtube.com/vi/TmQYhLHEZxA/0.jpg)](https://www.youtube.com/watch?v=TmQYhLHEZxA)