Fix for #34 , #36 and #37

Fix for #34 , #36 and #37.
This commit is contained in:
Dhruv Kanojia 2017-07-24 21:11:02 +05:30
parent f1b9c4e029
commit 05b5cbee0d
7 changed files with 52 additions and 15 deletions

View File

@ -39,4 +39,7 @@
- Support to download only selected chapters (range) [2017.07.06]
- Fix for #32 [2017.07.07]
- Support for converting downloaded images into pdf #17 [2017.07.07]
- Fix for #33 [2017.07.07]
- Fix for #33 [2017.07.07]
- Fix for #34 [2017.07.24]
- Fix for #36 [2017.07.24]
- Fix for #37 [2017.07.24]

View File

@ -34,7 +34,7 @@ Comic-dl is a command line tool to download Comics and Manga from various Manga
You can check the list of supported websites [**`HERE`**](https://github.com/Xonshiz/comic-dl/blob/master/Supported_Sites.md).
## Dependencies Installation
This script can run on multiple Operating Systems. You need `Node.js` in your system's path for this script to work. Download the `Node.Js` from [Node.js official website](https://nodejs.org/en/). Doesn't matter which operating system you're on, this is a must. Follow the instructions mentioned below, according to your OS.
This script can run on multiple Operating Systems. You need `Node.js` in your system's path for this script to work (You need this on each and every Operating System, even on WINDOWS :/). Download the `Node.Js` from [Node.js official website](https://nodejs.org/en/). Doesn't matter which operating system you're on, this is a must. Follow the instructions mentioned below, according to your OS.
### Linux/Debian :
Since most (if not all) Linux/Debian OS come with python pre-installed, you don't have to install python manually. Make sure you're using python >= 2.7.x though.
@ -78,7 +78,7 @@ phantomjs --version
```
### Windows :
If you're on windows, then it is recommended to download the [`windows binary`](https://github.com/Xonshiz/comic-dl#windows-binary) for this script. If you use the windows binary, you don't need to install anything. But, if for some weird reason you want to use Python script instead, then follow these steps :
If you're on windows, then it is recommended to download the [`windows binary`](https://github.com/Xonshiz/comic-dl#windows-binary) for this script. If you use the windows binary, you don't need to install anything, except Node.js. But, if for some weird reason you want to use Python script instead, then follow these steps :
* Install Python > 2.7.6. Download the desired installer from [here](https://www.python.org/downloads/).
* [Add it in the system path](http://superuser.com/questions/143119/how-to-add-python-to-the-windows-path) (if not already added).
@ -91,6 +91,8 @@ pip install -r requirements.txt
* It should install the required external libraries.
* Download PhantomJS : http://phantomjs.org/download.html
Now, install Node.Js as well and make sure it's in your path.
Well, if everything came up good without any error(s), then you're good to go!
### Mac OS X :
@ -140,7 +142,7 @@ Currently, the script supports these arguments :
--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)]
--conversion Tells the script to convert the downloaded Images to PDF or anything else. (Supported Values : pdf) (Default : No) [By default, script will not convert anything.]
--convert Tells the script to convert the downloaded Images to PDF or anything else. (Supported Values : pdf) (Default : No) [By default, script will not convert anything.]
--keep Tells the script whether to keep the files after conversion or not. (Supported : No, False) (Default : Yes/True) [By default, images will be kept even after conversion.]
```
#### Note :
@ -164,7 +166,7 @@ After you've saved this script in a directory/folder, you need to open `command
*If you're using the windows binary :*
`comic-dl.exe -i <URL TO THE COMIC>`
`comic_dl.exe -i <URL TO THE COMIC>`
*If you're using the Python Script :*

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__version__ = "2017.07.07"
__version__ = "2017.07.24"

View File

@ -20,11 +20,10 @@ class ComicDL(object):
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')
parser.add_argument('--convert', nargs=1, help='Tells the script to convert the downloaded Images to PDF or anything else.',default='None')
parser.add_argument('--convert', nargs=1, help='Tells the script to convert the downloaded Images to PDF or anything else.')
parser.add_argument('--keep', nargs=1, help='Tells the script whether to keep the files after conversion or not.', default='True')
required_args = parser.add_argument_group('Required Arguments :')
required_args.add_argument('-i', '--input', nargs=1, help='Inputs the URL to anime.')
parser.add_argument('-i', '--input', nargs=1, help='Inputs the URL to anime.')
parser.add_argument("-v", "--verbose", help="Prints important debugging messages on screen.",
action="store_true")

View File

@ -102,6 +102,7 @@ class GlobalFunctions(object):
print('{:^80}'.format('=====================================================================\n'))
def conversion(self, directory_path, conversion, delete_files, comic_name, chapter_number):
if str(conversion).lower().strip() in ['pdf']:
# Such kind of lambda functions and breaking is dangerous...
im_files = [image_files for image_files in sorted(glob.glob(str(directory_path) + "/" + "*.jpg"),
@ -118,7 +119,14 @@ class GlobalFunctions(object):
# Let's not delete the files if the conversion failed...
delete_files = "No"
pass
elif str(conversion) is None:
try:
self.conversion_cleaner(file_path=str(directory_path) + "/" + str(pdf_file_name))
except Exception as FileMoveError:
print("Could not move the pdf file.")
print(FileMoveError)
pass
elif str(conversion) == "None":
pass
else:
print("Seems like that conversion isn't supported yet. Please report it on the repository...")
@ -133,3 +141,23 @@ class GlobalFunctions(object):
print(FileDeleteError)
pass
print("Deleted the files...")
def conversion_cleaner(self, file_path):
print("Cleaning Up...")
path_breaker = str(file_path).split("/")
path_breaker.pop()
old_path = '/'.join(path_breaker)
path_breaker = str(old_path).split("\\")
path_breaker.pop()
new_path = str('/'.join(path_breaker)) + "/"
try:
shutil.move(file_path, new_path)
shutil.rmtree(old_path)
except Exception as FileDeleteError:
print("Couldn't move the file or delete the directory.")
print(FileDeleteError)
pass

View File

@ -39,4 +39,7 @@
- Support to download only selected chapters (range) [2017.07.06]
- Fix for #32 [2017.07.07]
- Support for converting downloaded images into pdf #17 [2017.07.07]
- Fix for #33 [2017.07.07]
- Fix for #33 [2017.07.07]
- Fix for #34 [2017.07.24]
- Fix for #36 [2017.07.24]
- Fix for #37 [2017.07.24]

View File

@ -34,7 +34,7 @@ Comic-dl is a command line tool to download Comics and Manga from various Manga
You can check the list of supported websites [**`HERE`**](https://github.com/Xonshiz/comic-dl/blob/master/Supported_Sites.md).
## Dependencies Installation
This script can run on multiple Operating Systems. You need `Node.js` in your system's path for this script to work. Download the `Node.Js` from [Node.js official website](https://nodejs.org/en/). Doesn't matter which operating system you're on, this is a must. Follow the instructions mentioned below, according to your OS.
This script can run on multiple Operating Systems. You need `Node.js` in your system's path for this script to work (You need this on each and every Operating System, even on WINDOWS :/). Download the `Node.Js` from [Node.js official website](https://nodejs.org/en/). Doesn't matter which operating system you're on, this is a must. Follow the instructions mentioned below, according to your OS.
### Linux/Debian :
Since most (if not all) Linux/Debian OS come with python pre-installed, you don't have to install python manually. Make sure you're using python >= 2.7.x though.
@ -78,7 +78,7 @@ phantomjs --version
```
### Windows :
If you're on windows, then it is recommended to download the [`windows binary`](https://github.com/Xonshiz/comic-dl#windows-binary) for this script. If you use the windows binary, you don't need to install anything. But, if for some weird reason you want to use Python script instead, then follow these steps :
If you're on windows, then it is recommended to download the [`windows binary`](https://github.com/Xonshiz/comic-dl#windows-binary) for this script. If you use the windows binary, you don't need to install anything, except Node.js. But, if for some weird reason you want to use Python script instead, then follow these steps :
* Install Python > 2.7.6. Download the desired installer from [here](https://www.python.org/downloads/).
* [Add it in the system path](http://superuser.com/questions/143119/how-to-add-python-to-the-windows-path) (if not already added).
@ -91,6 +91,8 @@ pip install -r requirements.txt
* It should install the required external libraries.
* Download PhantomJS : http://phantomjs.org/download.html
Now, install Node.Js as well and make sure it's in your path.
Well, if everything came up good without any error(s), then you're good to go!
### Mac OS X :
@ -140,7 +142,7 @@ Currently, the script supports these arguments :
--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)]
--conversion Tells the script to convert the downloaded Images to PDF or anything else. (Supported Values : pdf) (Default : No) [By default, script will not convert anything.]
--convert Tells the script to convert the downloaded Images to PDF or anything else. (Supported Values : pdf) (Default : No) [By default, script will not convert anything.]
--keep Tells the script whether to keep the files after conversion or not. (Supported : No, False) (Default : Yes/True) [By default, images will be kept even after conversion.]
```
#### Note :
@ -164,7 +166,7 @@ After you've saved this script in a directory/folder, you need to open `command
*If you're using the windows binary :*
`comic-dl.exe -i <URL TO THE COMIC>`
`comic_dl.exe -i <URL TO THE COMIC>`
*If you're using the Python Script :*