Skip to content

Commit

Permalink
Push version v0.5.0 to Master
Browse files Browse the repository at this point in the history
Push version v0.5.0 to Master
  • Loading branch information
schemen authored Nov 1, 2018
2 parents 92404d8 + 3df8c82 commit 8c56428
Show file tree
Hide file tree
Showing 23 changed files with 415 additions and 228 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.pyc
.vscode
test\ Kopie.db
_test.db
test.db
__pycache__
comic/*
data/*
kindlegen.exe
.idea
venv
main.db
log/*
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ _test.db
test.db
__pycache__
comic/*
data/*
kindlegen.exe
.idea
venv
main.db
log/*
log/*
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.6-slim

MAINTAINER Schemen <[email protected]>


WORKDIR /usr/src/app

VOLUME /usr/src/app/data

ENTRYPOINT ["/usr/bin/dumb-init", "--"]

COPY requirements.txt ./
RUN apt-get update && apt-get install dumb-init gcc wget -y && \
rm -rf /var/lib/apt/lists/* && \
pip install --no-cache-dir -r requirements.txt && \
apt-get purge gcc -y && apt-get autoremove -y && apt-get clean

RUN wget http://kindlegen.s3.amazonaws.com/kindlegen_linux_2.6_i386_v2_9.tar.gz -O /tmp/kindlegen.tar.gz && \
tar xvf /tmp/kindlegen.tar.gz -C /tmp && mv /tmp/kindlegen /usr/bin && \
rm -r /tmp/*


COPY . .

CMD [ "python","m2em.py", "--daemon", "-s"]
50 changes: 38 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Not living in Japan has me not really having any readable access of weekly chapt

M2em let's you automatically download Mangas via RSS Feed that updates at a configurable interval (and comics in the future?), convert them into eMangas and send them off via Email (Target being the Email to Kindle function of Amazon)!

## Supported Websites

* Mangastream
* MangaFox
* Cdmnet

# Setup

M2em requires Python3 and I highly recommend working in a virtualenv. Some OS require the python-dev package!
Expand Down Expand Up @@ -39,6 +45,24 @@ deactivate

Get Kindlegen here: https://www.amazon.com/gp/feature.html?docId=1000765211

## Docker Setup
You can use the Dockerfile or the image schemen/m2em. All options in the config.ini are available as environment variable. Make sure you write the exactly the same!

Example Compose file:
```
version: '2'
services:
m2em:
image: schemen/m2em:latest
environment:
- SMTPServer=mail.example.com
- [email protected]
- EmailAddressPw=verysecurepassword
volumes:
- <DATA_DIRECTORY>:/usr/src/app/data
```

## Concept
As a concept, M2em has different workers that run in a loop. All Chapter/user data is saved in a SQLite3 Database.
* RssParser - Parsing the RSS feed and saving the information of each chapter
Expand All @@ -64,15 +88,16 @@ Example: if you wish to download all chapters you have saved in your database, y
You can directly apply an action to one chapter with the options --download, --convert or --send. You need to pass
the ID of said chapter, you can find that out with "-Lc" or "-lc".
You can pass multiple IDs.
Example:

Also, you can process N chapters with the "--process/-p" option:
```
./m2em.py --download 100 #Downloads chapter with ID 100
./m2em.py -p 100 #Downloads, Converts and Sends chapter with ID 100
```


## Supported Websites
* Mangastream
* MangaFox
```
./m2em.py --download 100 #Downloads chapter with ID 100
```

# Usage

Expand All @@ -81,9 +106,10 @@ Example:
usage: m2em.py [-h] [-af ADD_FEED] [-au] [-lm [LIST_MANGA]] [-lc] [-Lc] [-lf]
[-lu] [-cd] [-s] [--send [SEND [SEND ...]]]
[--convert [CONVERT [CONVERT ...]]]
[--download [DOWNLOAD [DOWNLOAD ...]]] [-a ACTION]
[-ss SWITCH_SEND] [-sc SWITCH_CHAPTER] [-dc DELETE_CHAPTER]
[-du DELETE_USER] [-df DELETE_FEED] [--daemon] [-d] [-v]
[--download [DOWNLOAD [DOWNLOAD ...]]]
[-p [PROCESS [PROCESS ...]]] [-a ACTION] [-ss SWITCH_SEND]
[-dc DELETE_CHAPTER] [-du DELETE_USER] [-df DELETE_FEED]
[--daemon] [-d] [-v]
Manga to eManga - m2em
Expand Down Expand Up @@ -112,13 +138,14 @@ optional arguments:
--download [DOWNLOAD [DOWNLOAD ...]]
Downloads Chapter directly by chapter ID. Multiple IDs
can be given
-p [PROCESS [PROCESS ...]], --process [PROCESS [PROCESS ...]]
Processes chapter(s) by chapter ID, Download, convert,
send. Multiple IDs can be given
-a ACTION, --action ACTION
Start action. Options are: rssparser (collecting feed
data), downloader, converter or sender
-ss SWITCH_SEND, --switch-send SWITCH_SEND
Pass ID of User. Switches said user Send eBook status
-sc SWITCH_CHAPTER, --switch-chapter SWITCH_CHAPTER
Pass ID of Chapter. Switches said Chapter Sent status
-dc DELETE_CHAPTER, --delete-chapter DELETE_CHAPTER
Pass ID of Chapter. Deletes said Chapter
-du DELETE_USER, --delete-user DELETE_USER
Expand Down Expand Up @@ -147,7 +174,7 @@ For the sending to work, you need to have an email account so the program can se
```
[CONFIG]
# Location relative to the code position
SaveLocation = comic/
SaveLocation = data/
# Database name
Database = main.db
# Duration the program sleeps after one run is finished in seconds
Expand Down Expand Up @@ -203,7 +230,6 @@ If you wish to disable/enable sending status of a user, use the -ss command
```



### A complete run with nothing happening:
```
Starting Loop at 2017-11-15 18:13:05
Expand Down
17 changes: 17 additions & 0 deletions bin/Config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

import configparser
import os

def load_config(location='config.ini'):
config = {}
config_reader = configparser.ConfigParser()
config_reader.optionxform = str
config_reader.read(location)

for key, value in config_reader.items("CONFIG"):
if key in os.environ:
config[key] = os.environ[key]
else:
config[key] = value

return config
8 changes: 7 additions & 1 deletion bin/Converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import zipfile
import subprocess
import bin.Config as Config
import bin.Helper as helper


Expand All @@ -22,9 +23,14 @@ def __init__(self):



def data_collector(self, config, chapter):
def data_collector(self, chapter):
""" Method that collects data"""

# Load config right at the start
config = None
if not config:
config = Config.load_config()

# Load configs required here
self.saveloc = config["SaveLocation"]
self.ebformat = config["EbookFormat"]
Expand Down
12 changes: 6 additions & 6 deletions bin/ConverterHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import bin.Helper as helper
from bin.Converter import Converter

def ConverterHandler(config, args):
def ConverterHandler(args):
""" Function that handles the Converter in a loop """

# Load Chapters!
Expand All @@ -15,14 +15,14 @@ def ConverterHandler(config, args):


# Verify if chapter has been downloaded already
if not helper.verifyDownload(config, chapter):
if not helper.verifyDownload(chapter):
logging.debug("Manga %s has not been downloaded!", chapter.title)
else:


# Spawn an Converter Object & get basic data from database & config
current_conversation = Converter()
current_conversation.data_collector(config, chapter)
current_conversation.data_collector(chapter)

# Check if Download loop & Download task is selected
if not args.start:
Expand All @@ -41,7 +41,7 @@ def ConverterHandler(config, args):



def directConverter(config, chapterids=[]):
def directConverter(chapterids=[]):
""" Function that handles direct calls of the Converter """

logging.debug("Following Chapters are directly converted:")
Expand All @@ -57,14 +57,14 @@ def directConverter(config, chapterids=[]):
for chapter in chapters:

# Verify if chapter has been downloaded already
if not helper.verifyDownload(config, chapter):
if not helper.verifyDownload(chapter):
logging.info("Manga %s has not been downloaded!", chapter[2])
else:


# Spawn an Converter Object & get basic data from database & config
current_conversation = Converter()
current_conversation.data_collector(config, chapter)
current_conversation.data_collector(chapter)

if os.path.exists(current_conversation.cbzlocation):
logging.info("Manga %s converted to CBZ already!",
Expand Down
Loading

0 comments on commit 8c56428

Please sign in to comment.