Skip to content

Commit

Permalink
Dependencies auto-install
Browse files Browse the repository at this point in the history
  • Loading branch information
Carleslc committed Jul 1, 2020
1 parent 903bd41 commit 4d29359
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@

- [Python 3.6+](https://www.python.org/downloads/)

##### Python dependencies
🇪🇸 *Las dependencias de Python se instalarán automáticamente la primera vez que ejecutes el programa.*

🇪🇸 Ejecuta el siguiente comando. A veces el comando de dependencias para Python3 es `pip3` en vez de `pip`.
También puedes instalarlas manualmente con el siguiente comando:

🇬🇧 Run the following command. Sometimes dependencies command for Python3 is `pip3` instead of `pip`.
```shell
pip install --user -r dependencies.txt
```

A veces el comando para Python3 es `pip3` en lugar de `pip`.

🇬🇧 *Python dependencies will be installed automatically the first time you run the program.*

Dependencies can also be installed manually with the following command:

```shell
pip install --user -r dependencies.txt
```

Sometimes dependencies command for Python3 is `pip3` instead of `pip`.

*Instalará / Will install:*

- (EPUB/MOBI format) [Kindle Comic Converter](https://github.com/ciromattia/kcc)
Expand All @@ -26,27 +36,17 @@ pip install --user -r dependencies.txt
- [colorama](https://pypi.org/project/colorama/)
- [img2pdf](https://pypi.org/project/img2pdf/)

(*Opcional*) Puedes usar `virtualenv` para evitar conflictos con otras versiones de Python:

```bash
sudo pip install virtualenv
virtualenv env
. env/bin/activate # Bash/Tcsh console
#. env/bin/activate.fish # Fish console
pip install -r dependencies.txt
```

#### MOBI / Kindle

Para convertir un manga al formato MOBI (Kindle) necesitarás la dependencia [KindleGen](https://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211).
Para convertir un manga al formato MOBI (Kindle) necesitarás instalar [KindleGen](https://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211).

En las últimas versiones de Mac OS X es posible que la anterior versión no funcione, así que necesitarás instalar [Kindle Previewer 3](https://www.amazon.com/gp/feature.html?ie=UTF8&docId=1003018611) y añadir el ejecutable `kindlegen` a tu PATH ejecutando el siguiente comando después de instalarlo: `cp /Applications/Kindle\ Previewer\ 3.app/Contents/MacOS/lib/fc/bin/kindlegen /usr/local/bin/kindlegen`

Puedes enviar tus capítulos directamente al Kindle con la aplicación [SendToKindle](https://www.amazon.com/gp/sendtokindle).

#### PDF

En la conversión a PDF algunas imágenes pueden dar el error `Exception: Refusing to work on images with alpha channel`. Para corregir esto se debe eliminar la transparencia de estas imágenes. Puedes añadir la opción `--remove-alpha` para hacerlo automáticamente. Para que funcione debes instalar [Wand + ImageMagick](http://docs.wand-py.org/en/0.5.9/guide/install.html).
En la conversión a PDF algunas imágenes pueden dar el error `Exception: Refusing to work on images with alpha channel`. Para corregir esto se debe eliminar la transparencia de estas imágenes. Puedes añadir la opción `--remove-alpha` para hacerlo automáticamente. Para que funcione debes instalar [Wand + ImageMagick](http://docs.wand-py.org/en/0.6.1/guide/install.html).

### 🇪🇸 Uso

Expand All @@ -65,7 +65,7 @@ uso: manga.py [-h] [--chapters CHAPTERS] [--directory DIRECTORY] [--single]
parámetros posicionales:
 manga                 título del manga a descargar
optional arguments:
parámetros opcionales:
 -h, --help           muestra este mensaje de ayuda (en inglés)
--chapters CHAPTERS, --chapter CHAPTERS
                       capítulos a descargar. Formato: primero..último o capítulos
Expand Down
23 changes: 21 additions & 2 deletions manga.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,30 @@
import signal
import argparse
import tempfile
from urllib.parse import quote_plus
from multiprocessing import freeze_support

def install_dependencies(dependencies_file):
# Check dependencies
import subprocess
import sys
from pathlib import Path
import pkg_resources
dependencies_path = Path(__file__).with_name(dependencies_file)
dependencies = pkg_resources.parse_requirements(dependencies_path.open())
try:
for dependency in dependencies:
dependency = str(dependency)
pkg_resources.require(dependency)
except pkg_resources.DistributionNotFound as e:
print("Some dependencies are missing, installing...")
# Install missing dependencies
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", dependencies_file])

install_dependencies("dependencies.txt")
from requests import get, post
from bs4 import BeautifulSoup
from urllib.parse import quote_plus
from colorama import Fore, Style, init as init_console_colors
from multiprocessing import freeze_support

WEBSITE = "https://inmanga.com"
IMAGE_WEBSITE = f"{WEBSITE}/page/getPageImage/?identification="
Expand Down

0 comments on commit 4d29359

Please sign in to comment.