update versions and readme + minor tweaks
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is failing

This commit is contained in:
Ivan Schaller 2022-05-09 21:07:37 +02:00
parent 3377fc111d
commit 6ea0193307
13 changed files with 308 additions and 141 deletions

View file

@ -12,9 +12,9 @@ platform:
trigger:
branch:
- master
- master
event:
- push
- push
# anchors
sq_secrets: &sq_secrets
@ -29,12 +29,12 @@ sq_analysis: &sq_analysis
# build steps
steps:
- name: 'sonarqube: analyse code'
<<: *sq_analysis
settings:
<<: *sq_secrets
sources: .
exclusions: contrib/**
- name: 'sonarqube: analyse code'
<<: *sq_analysis
settings:
<<: *sq_secrets
sources: .
exclusions: contrib/**
@ -52,7 +52,7 @@ platform:
trigger:
event:
- tag
- tag
# anchors
cr_secrets: &cr_secrets
@ -68,15 +68,15 @@ docker_build: &docker_build
# build steps arm64
steps:
- name: 'build and publish docker image'
<<: *docker_build
settings:
repo: olofvndrhr/manga-dlp
context: docker
dockerfile: docker/Dockerfile.arm64
auto_tag: true
auto_tag_suffix: linux-arm64
<<: *cr_secrets
- name: 'build and publish docker image'
<<: *docker_build
settings:
repo: olofvndrhr/manga-dlp
context: docker
dockerfile: docker/Dockerfile.arm64
auto_tag: true
auto_tag_suffix: linux-arm64
<<: *cr_secrets
---
@ -90,7 +90,7 @@ platform:
trigger:
event:
- tag
- tag
# anchors
cr_secrets: &cr_secrets
@ -106,15 +106,15 @@ docker_build: &docker_build
# build steps amd64
steps:
- name: 'build and publish docker image'
<<: *docker_build
settings:
repo: olofvndrhr/manga-dlp
context: docker
dockerfile: docker/Dockerfile.amd64
auto_tag: true
auto_tag_suffix: linux-amd64
<<: *cr_secrets
- name: 'build and publish docker image'
<<: *docker_build
settings:
repo: olofvndrhr/manga-dlp
context: docker
dockerfile: docker/Dockerfile.amd64
auto_tag: true
auto_tag_suffix: linux-amd64
<<: *cr_secrets
---
@ -128,7 +128,7 @@ platform:
trigger:
event:
- tag
- tag
# anchors
cr_secrets: &cr_secrets
@ -139,15 +139,51 @@ cr_secrets: &cr_secrets
# build steps
steps:
- name: 'publish manifest'
image: plugins/manifest
settings:
spec: docker/manifest.tmpl
auto_tag: true
ignore_missing: true
<<: *cr_secrets
- name: 'publish manifest'
image: plugins/manifest
settings:
spec: docker/manifest.tmpl
auto_tag: true
ignore_missing: true
<<: *cr_secrets
depends_on:
- docker-build-amd64
- docker-build-arm64
#---
#################
## publish pypi #
#################
#kind: pipeline
#type: docker
#name: publish-pypi-package
#
#platform:
# os: linux
# arch: arm64
#
#trigger:
# event:
# - tag
#
## anchors
#pypi_secrets: &pypi_secrets
# username:
# from_secret: pypi-username
# password:
# from_secret: pypi-token
#
#pypi_plugin: &pypi_plugin
# image: plugins/pypi
# pull: if-not-exists
# group: build
#
## build steps arm64
#steps:
# - name: 'publish or update pypi package'
# <<: *pypi_plugin
# settings:
# # repository:
# setupfile: setup.py
# <<: *pypi_secrets

143
.gitignore vendored
View file

@ -9,5 +9,146 @@ downloads/
__pycache__/
.pytest_cache/
chaps.txt
venv/
.idea/
venv
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/

View file

@ -9,6 +9,17 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Add support for more sites
## [2.0.1] - 2022-05-09
### Fixed
- Regex for removing illegal characters in the filenames now doesn't remove quotes
- Updated docker baseimage and fixed the mangadlp tag in it
- Update license for 2022
### Added
- Quick start section in README
- Preperation for pypi
## [2.0.0] - 2022-05-09
### Fixed

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2021 Ivan Schaller
Copyright (c) 2022 Ivan Schaller
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

10
MANIFEST.in Normal file
View file

@ -0,0 +1,10 @@
include *.json
include *.md
include *.properties
include *.py
include *.txt
include *.yml
recursive-include contrib *.py
recursive-include mangadlp *.py
recursive-include tests *.py
recursive-include tests *.txt

View file

@ -2,16 +2,11 @@
## python script to download mangas
---
[![Build Status](https://drone.44net.ch/api/badges/olofvndrhr/manga-dlp/status.svg)](https://drone.44net.ch/olofvndrhr/manga-dlp)
[![Quality Gate Status](https://sonarqube.44net.ch/api/project_badges/measure?project=olofvndrhr%3Amanga-dlp&metric=alert_status&token=677dfde6a5c7ea85463eb2fe4133c47f71494494)](https://sonarqube.44net.ch/dashboard?id=olofvndrhr%3Amanga-dlp)
---
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
## Description
A manga download script written in python. It only supports [mangadex.org](https://mangadex.org/) for now. But support
for other sites is planned.
@ -19,7 +14,7 @@ Before downloading a new chapter, the script always checks if there is already a
download directory. If found the chapter is skipped. So you can run the script on a schedule to only download new
chapters without any additional setup.
The default behaiviour is to pack the images to a [cbz archvie](https://en.wikipedia.org/wiki/Comic_book_archive). If
The default behaiviour is to pack the images to a [cbz archive](https://en.wikipedia.org/wiki/Comic_book_archive). If
you just want the folder with all the pictures use the flag `--nocbz`.
## *Currently* Supported sites
@ -28,6 +23,15 @@ you just want the folder with all the pictures use the flag `--nocbz`.
## Usage
### Quick start
```sh
python3 manga-dlp.py \
--url https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu \
--language "en" \
--chapters "all"
```
### With GitHub
```sh

View file

@ -1,61 +1 @@
import requests
import re
import mangadlp.utils as MUtils
class Mangadex():
# api information
api_base_url = ''
img_base_url = ''
# get infos to initiate class
def __init__(self, manga_url, manga_lang):
self.manga_url = manga_url
self.manga_lang = manga_lang
self.manga_title = self.get_manga_title(self.manga_uuid)
self.manga_chapter_data = self.get_manga_chapters(self.manga_uuid)
# get the title of the manga (and fix the filename)
def get_manga_title(self):
return MUtils.fix_name(title)
# get all chapter data for further parsing
def get_manga_chapters(self):
chap_data_list = []
# default mapping of chapter data
chapter_vol = [0]
chapter_num = [1]
chapter_uuid = [2]
chapter_hash = [3]
chapter_name = [4]
chapter_img_data = [5]
return chap_data_list
# get index of chapter
def get_chapter_index(self, chapter, forcevol):
return chapter_index
# create list of chapters
def create_chapter_list(self, chapter_data, forcevol):
chapter_list = []
return chapter_list
# get list of image urls
def get_img_urls(self, images):
img_urls = []
return img_urls
# to be done

View file

@ -1,4 +1,4 @@
FROM cr.44net.ch/baseimages/debian-s6-slim:1.3.1
FROM cr.44net.ch/baseimages/debian-s6:1.3.3
# set version label
ARG BUILD_DATE
@ -7,7 +7,7 @@ LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="Ivan Schaller"
# manga-dlp version
ARG MDLP_VERSION=1.0.1
ARG MDLP_VERSION=2.0.1
# install packages
RUN \

View file

@ -1,4 +1,4 @@
FROM cr.44net.ch/baseimages/debian-s6-slim:1.3.1
FROM cr.44net.ch/baseimages/debian-s6:1.3.3
# set version label
ARG BUILD_DATE
@ -7,7 +7,7 @@ LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="Ivan Schaller"
# manga-dlp version
ARG MDLP_VERSION=1.0.1
ARG MDLP_VERSION=2.0.1
# install packages
RUN \

View file

@ -11,19 +11,26 @@ docker-compose up -d
# with docker run
docker run -v ./downloads:/app/downloads -v ./mangas.txt:/app/mangas.txt olofvndrhr/manga-dlp
```
### Change UID/GID
> The default UID and GID are 4444.
You can change the UID and GID of the container user simply with:
```yml
# docker-compose.yml
environment:
- PUID=<userid>
- PGID=<groupid>
environment:
- PUID=<userid>
- PGID=<groupid>
```
```sh
docker run -e PUID=<userid> -e PGID=<groupid>
```
## Run commands in container
You can simply use the `docker exec` command to run the scripts like normal.
```sh
@ -32,42 +39,50 @@ docker exec <container name> python3 manga-dlp.py <options>
## Run your own schedule
The default config runs manga-dlp.py once a day at 03:00 and fetches every chapter of the mangas listed in the file mangas.txt in the root directory of this repo.
The default config runs manga-dlp.py once a day at 03:00 and fetches every chapter of the mangas listed in the file
mangas.txt in the root directory of this repo.
To use your own schedule you need to mount (override) the default crontab or add new ones to the cron directory.
```yml
# docker-compose.yml
volumes:
- ./crontab:/etc/cron.d/01-manga-dlp # overwrites the default one
- ./crontab2:/etc/cron.d/02-something # adds a new one
volumes:
- ./crontab:/etc/cron.d/01_manga-dlp # overwrites the default one
- ./crontab2:/etc/cron.d/02_something # adds a new one
```
```sh
docker run -v ./crontab:/etc/cron.d/01-manga-dlp # overwrites the default one
docker run -v ./crontab2:/etc/cron.d/02-something # adds a new one
docker run -v ./crontab:/etc/cron.d/01_manga-dlp # overwrites the default one
docker run -v ./crontab2:/etc/cron.d/02_something # adds a new one
```
## Add mangas to mangas.txt
If you use the default crontab you still need to add some mangas to mangas.txt. This is done almost identical to adding your own cron schedule.
If you use a custom cron schedule you need to mount the file you specified with `--read`.
If you use the default crontab you still need to add some mangas to mangas.txt. This is done almost identical to adding
your own cron schedule. If you use a custom cron schedule you need to mount the file you specified with `--read`.
```yml
# docker-compose.yml
volumes:
- ./mangas.txt:/app/mangas.txt
volumes:
- ./mangas.txt:/app/mangas.txt
```
```sh
docker run -v ./mangas.txt:/app/mangas.txt
```
## Change download directory
Per default as in the script, it downloads everything to "downloads" in the scripts root directory. This data does not persist with container recreation, so you need to mount it. This is already done in the quick start section.
If you want to change the path of the host, simply change `./media/mangas/` to a path of your choice.
Per default as in the script, it downloads everything to "downloads" in the scripts root directory. This data does not
persist with container recreation, so you need to mount it. This is already done in the quick start section. If you want
to change the path of the host, simply change `./media/mangas/` to a path of your choice.
```yml
# docker-compose.yml
volumes:
- ./media/mangas/:/app/downloads
volumes:
- ./media/mangas/:/app/downloads
```
```sh
docker run -v ./media/mangas/:/app/downloads
```

View file

@ -8,7 +8,7 @@ services:
security_opt:
- no-new-privileges:true
networks:
- mangadlp
- appnet
volumes:
- ./downloads/:/app/downloads/ # default manga download directory
- ./mangas.txt:/app/mangas.txt # default file for manga links to download
@ -19,5 +19,7 @@ services:
networks:
mangadlp:
appnet:
name: mangadlp
driver: bridge

View file

@ -1,7 +1,8 @@
from pathlib import Path
import shutil
from zipfile import ZipFile
import re
import shutil
from pathlib import Path
from zipfile import ZipFile
# create a cbz archive
def make_archive(chapter_path):
@ -52,7 +53,7 @@ def get_chapter_list(chapters):
# remove illegal characters etc
def fix_name(filename):
# remove illegal characters
filename = re.sub("[\\\/\<\>\:\;'\"\|\?\*\!\@]", ".", filename)
filename = re.sub("[\\\/\<\>\:\;\|\?\*\!\@]", "", filename)
# remove multiple dots
filename = re.sub("([\.]{2,})", ".", filename)
# remove dot(s) at the beginning and end of the filename

View file

@ -1,22 +1,29 @@
from pathlib import Path
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
readme = Path("README.md")
long_description = readme.read_text()
setuptools.setup(
name="manga-dlp-olofvndrhr",
version="0.0.1",
name="manga-dlp",
version="2.0.1",
author="Ivan Schaller",
author_email="ivan@schaller.sh",
description="A manga downloader",
description="A cli manga downloader",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/olofvndrhr/manga-dlp",
packages=setuptools.find_packages(),
project_urls={
"Bug Tracker": "https://github.com/olofvndrhr/manga-dlp/issues",
},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)
package_dir={"": "mangadlp"},
packages=setuptools.find_packages(where="mangadlp"),
py_modules=["manga-dlp"],
python_requires=">=3.6",
)