From 9aef24e1bba52b3c89203524556d216a62e994a7 Mon Sep 17 00:00:00 2001 From: David Luevano <55825613+luevano@users.noreply.github.com> Date: Sat, 12 Oct 2019 00:54:28 -0600 Subject: Bug fixes --- setup.py | 7 +-- tirante/__init__.py | 8 ++-- tirante/__version__.py | 23 --------- tirante/down_man.py | 116 ---------------------------------------------- tirante/download_manga.py | 116 ++++++++++++++++++++++++++++++++++++++++++++++ tirante/version.py | 23 +++++++++ 6 files changed, 147 insertions(+), 146 deletions(-) delete mode 100644 tirante/__version__.py delete mode 100644 tirante/down_man.py create mode 100644 tirante/download_manga.py create mode 100644 tirante/version.py diff --git a/setup.py b/setup.py index db182ba..9073b15 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ import os from setuptools import find_packages, setup -from tirante.__version__ import __version__ +# from tirante.version import __version__ # Package meta-data. NAME = 'tirante' @@ -39,8 +39,9 @@ DESCRIPTION = 'A (wannabe) manga downloader manager.' URL = 'https://github.com/luevano/tirante' EMAIL = 'lorentzeus@gmail.com' AUTHOR = 'David Luevano Alvarado' -REQUIRES_PYTHON = '>=3.7.4' -VERSION = __version__ +REQUIRES_PYTHON = '>=3.7' +# VERSION = __version__ +VERSION = '0.0.1' # What packages are required for this module to be executed? REQUIRED = [ diff --git a/tirante/__init__.py b/tirante/__init__.py index 94608f7..f667c54 100644 --- a/tirante/__init__.py +++ b/tirante/__init__.py @@ -20,10 +20,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from __version__ import __version__ -from cr_dat import create_database -from up_dat import update_database -from down_man import download_manga +# from version import __version__ +from create_database import create_database +from update_database import update_database +from download_manga import download_manga # If somebody does "from package import *", this is what they will # be able to access: diff --git a/tirante/__version__.py b/tirante/__version__.py deleted file mode 100644 index fab5843..0000000 --- a/tirante/__version__.py +++ /dev/null @@ -1,23 +0,0 @@ -"""MIT License - -Copyright (c) 2019 David Luevano Alvarado - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -""" -__version__ = '0.0.1' diff --git a/tirante/down_man.py b/tirante/down_man.py deleted file mode 100644 index c216bb7..0000000 --- a/tirante/down_man.py +++ /dev/null @@ -1,116 +0,0 @@ -"""MIT License - -Copyright (c) 2019 David Luevano Alvarado - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -""" -import os - -# Project specific imports. -from chapters_manager import chapters_csv_to_list -from chapter_images_manager import chapter_image_csv_to_list -from download_manager import download_chapter - - -def download_manga(manga_name, - manga_dir, - manga_data_dir): - """ - Downloads a whole manga, saving it to subfolders. - Uses the database already created. - that's used by the webpage. - manga_name: Actual name of the manga, as it appears in the webpage. - manga_dir: Main manga folder in computer, subfolders here will be created. - manga_data_dir: Main manga data folder in computer. - NOTE: This updates the manga, downloading the missing chapters - if they're listed in the database. - """ - - # A better "naming" for the manga, for use with folder creation. - # As well as the name of the main database. - m_name = '_'.join(word.lower() for word in manga_name.split()) - m_name_ext = ''.join([m_name, '.csv']) - - # Go to where the database is located. - os.chdir(manga_data_dir) - try: - os.chdir(m_name) - except FileNotFoundError: - print(''.join([m_name, - ' folder doesn\'t exist.', - ' Most likely, the database hasn\'t been created.'])) - raise NameError('Create database first.') - - # Get info of the files in the database. - data_list_dir = os.listdir() - - # Reads data from the main database. - if m_name_ext not in data_list_dir: - print(''.join([m_name, - ' database hasn\'t been created.', - ' Most likely, the database hasn\'t been created.'])) - raise NameError('Create database first.') - else: - chapters_list = chapters_csv_to_list(m_name_ext) - - # Navigate to the main manga dir, - # and either create or go to manga folder. - os.chdir(manga_dir) - try: - os.mkdir(manga_name) - os.chdir(manga_name) - except FileExistsError: - print(''.join([manga_name, - ' folder already exists.'])) - os.chdir(manga_name) - - # Get data of the folders in the manga folder. - manga_list_dir = os.listdir() - - for chapter in chapters_list: - # chapter_url = chapter[0] - chapter_name = chapter[1] - ch_name_ext = ''.join([chapter_name, '.csv']) - - if chapter_name not in manga_list_dir: - print(''.join(['Downloading ', - chapter_name, - ' now.'])) - # First, create the chapter folder. - os.mkdir(chapter_name) - - # Go to where the database is located. - os.chdir(manga_data_dir) - os.chdir(m_name) - chapter_image_list = chapter_image_csv_to_list(ch_name_ext) - - # Go back to where the manga is going ot be downloaded. - os.chdir(manga_dir) - os.chdir(manga_name) - os.chdir(chapter_name) - - # Download all the chapter images on its respective folder. - download_chapter(chapter_image_list) - - # Go back one folder to repeat the process - # for the next chapter. - os.chdir('..') - else: - print(''.join([chapter_name, - ' already downloaded.'])) diff --git a/tirante/download_manga.py b/tirante/download_manga.py new file mode 100644 index 0000000..c216bb7 --- /dev/null +++ b/tirante/download_manga.py @@ -0,0 +1,116 @@ +"""MIT License + +Copyright (c) 2019 David Luevano Alvarado + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" +import os + +# Project specific imports. +from chapters_manager import chapters_csv_to_list +from chapter_images_manager import chapter_image_csv_to_list +from download_manager import download_chapter + + +def download_manga(manga_name, + manga_dir, + manga_data_dir): + """ + Downloads a whole manga, saving it to subfolders. + Uses the database already created. + that's used by the webpage. + manga_name: Actual name of the manga, as it appears in the webpage. + manga_dir: Main manga folder in computer, subfolders here will be created. + manga_data_dir: Main manga data folder in computer. + NOTE: This updates the manga, downloading the missing chapters + if they're listed in the database. + """ + + # A better "naming" for the manga, for use with folder creation. + # As well as the name of the main database. + m_name = '_'.join(word.lower() for word in manga_name.split()) + m_name_ext = ''.join([m_name, '.csv']) + + # Go to where the database is located. + os.chdir(manga_data_dir) + try: + os.chdir(m_name) + except FileNotFoundError: + print(''.join([m_name, + ' folder doesn\'t exist.', + ' Most likely, the database hasn\'t been created.'])) + raise NameError('Create database first.') + + # Get info of the files in the database. + data_list_dir = os.listdir() + + # Reads data from the main database. + if m_name_ext not in data_list_dir: + print(''.join([m_name, + ' database hasn\'t been created.', + ' Most likely, the database hasn\'t been created.'])) + raise NameError('Create database first.') + else: + chapters_list = chapters_csv_to_list(m_name_ext) + + # Navigate to the main manga dir, + # and either create or go to manga folder. + os.chdir(manga_dir) + try: + os.mkdir(manga_name) + os.chdir(manga_name) + except FileExistsError: + print(''.join([manga_name, + ' folder already exists.'])) + os.chdir(manga_name) + + # Get data of the folders in the manga folder. + manga_list_dir = os.listdir() + + for chapter in chapters_list: + # chapter_url = chapter[0] + chapter_name = chapter[1] + ch_name_ext = ''.join([chapter_name, '.csv']) + + if chapter_name not in manga_list_dir: + print(''.join(['Downloading ', + chapter_name, + ' now.'])) + # First, create the chapter folder. + os.mkdir(chapter_name) + + # Go to where the database is located. + os.chdir(manga_data_dir) + os.chdir(m_name) + chapter_image_list = chapter_image_csv_to_list(ch_name_ext) + + # Go back to where the manga is going ot be downloaded. + os.chdir(manga_dir) + os.chdir(manga_name) + os.chdir(chapter_name) + + # Download all the chapter images on its respective folder. + download_chapter(chapter_image_list) + + # Go back one folder to repeat the process + # for the next chapter. + os.chdir('..') + else: + print(''.join([chapter_name, + ' already downloaded.'])) diff --git a/tirante/version.py b/tirante/version.py new file mode 100644 index 0000000..fab5843 --- /dev/null +++ b/tirante/version.py @@ -0,0 +1,23 @@ +"""MIT License + +Copyright (c) 2019 David Luevano Alvarado + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" +__version__ = '0.0.1' -- cgit v1.2.3-70-g09d2