Skip to content

Commit

Permalink
Fix for #34 , #36 and #37
Browse files Browse the repository at this point in the history
Fix for #34 , #36 and #37.
  • Loading branch information
Xonshiz committed Jul 24, 2017
1 parent f1b9c4e commit 05b5cbe
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 15 deletions.
5 changes: 4 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
10 changes: 6 additions & 4 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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).
Expand All @@ -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 :
Expand Down Expand Up @@ -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 :
Expand All @@ -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 :*

Expand Down
2 changes: 1 addition & 1 deletion comic_dl/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

__version__ = "2017.07.07"
__version__ = "2017.07.24"
5 changes: 2 additions & 3 deletions comic_dl/comic_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ def __init__(self, argv):
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")
Expand Down
30 changes: 29 additions & 1 deletion comic_dl/globalFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def info_printer(self, anime_name, episode_number, **kwargs):
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"),
Expand All @@ -118,7 +119,14 @@ def conversion(self, directory_path, conversion, delete_files, comic_name, chapt
# 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...")
Expand All @@ -133,3 +141,23 @@ def conversion(self, directory_path, conversion, delete_files, comic_name, chapt
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

5 changes: 4 additions & 1 deletion docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
10 changes: 6 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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).
Expand All @@ -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 :
Expand Down Expand Up @@ -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 :
Expand All @@ -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 :*

Expand Down

0 comments on commit 05b5cbe

Please sign in to comment.