Skip to content

Commit

Permalink
UPDATE 0.4.3 from develop
Browse files Browse the repository at this point in the history
NEW
New docker container. Containing all the tools. More info in the wiki page
Better file manager for linux
New GUI for tool selector
New Settings file so specify library path and covers path (file selector opens in that location by default)

Added
Clear Queue button for WebpConverter
Optimizations if no comicinfo is present it will be added and not backed up (faster)
Skip restore if no Old_ComicInfo.xml.bak is present
Changed

All tests were reworked
Centered Epub2cbz ui
Reworked Cover Manager ui

Fixed
Metadata Manager was completely broken.
WebpConverter
Lot's of fixes
  • Loading branch information
ThePromidius authored Jun 9, 2022
2 parents d4953d1 + e721c98 commit 85b25f9
Show file tree
Hide file tree
Showing 56 changed files with 2,288 additions and 2,796 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/Build_Docker_Images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build Docker

on:
schedule:
- cron: '41 11 * * 3'
push:
branches: [ main, develop, test ]
env:
IMAGE_NAME: "thepromidius/manga-manager"
jobs:
docker_dev:
name: Nightly Build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ env.IMAGE_NAME }}:nightly
docker_stable:
name: Stable Build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ env.IMAGE_NAME }}:latest
docker_test:
name: Test Build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/test' }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ env.IMAGE_NAME }}:test

5 changes: 3 additions & 2 deletions .github/workflows/Run_Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

name: Python tests

on: push

on:
- push
- pull_request

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ undo.json
/testing/
.pytest_cache
*.log*
/.idea/webResources.xml
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM ghcr.io/linuxserver/baseimage-rdesktop-web:jammy

ENV DEBIAN_FRONTEND=noninteractive
ENV UID=1000
ENV GID=1000
ENV NO_UPDATE_NOTIFIER=true
ENV GUIAUTOSTART=true

WORKDIR /tmp
COPY requirements.txt /tmp/

# Copy App
COPY --chown=$UID:$GID [ "/MangaManager", "/app" ]

# Setup Dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
# Desktop Environment
mousepad \
xfce4-terminal \
xfce4 \
xubuntu-default-settings \
xubuntu-icon-theme \
# Python
python3-tk \
python3-pip && \
# Manga Manager Dependencies
pip install -r requirements.txt && \
# Cleanup
apt-get autoclean && \
rm -rf \
/var/lib/apt/lists/* \
/var/tmp/* \
/tmp/* && \
# Try making python3 callable by just running "python" on Ubuntu :) (optional)
ln -s /usr/bin/python3 /usr/bin/python || true && \
chmod -R +x /app

# Setup environment & branding/customization
COPY /docker-root /
RUN \
chmod -R +x /config/Desktop && \
chmod -R +x /config/.config/xfce4/panel


WORKDIR /app

EXPOSE 3000
VOLUME /manga
VOLUME /covers
2 changes: 2 additions & 0 deletions MangaManager/CommonLib/ScrolledFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ def on_mousewheel(event):
return on_mousewheel


# noinspection PyUnresolvedReferences
class ScrolledFrame(ttk.Frame):
VERTICAL = 'vertical'
HORIZONTAL = 'horizontal'
BOTH = 'both'
_framecls = ttk.Frame
_sbarcls = ttk.Scrollbar

# noinspection PyMissingConstructor
def __init__(self, master=None, **kw):
self.scrolltype = kw.pop('scrolltype', self.VERTICAL)
self.usemousewheel = tk.getboolean(kw.pop('usemousewheel', False))
Expand Down
56 changes: 40 additions & 16 deletions MangaManager/CommonLib/WebpConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_estimated_time(start_time: float, processed_files: int, total_files: int
from CommonLib.HelperFunctions import get_estimated_time, get_elapsed_time
import tkinter as tk

from tkinter import filedialog
from tkinter.filedialog import askopenfiles
from tkinter.ttk import Style, Progressbar

current_time = time.time()
Expand Down Expand Up @@ -202,8 +202,7 @@ def __init__(self, interval, total):
"""
:param interval:
:param function:
:param iteration:
:param total:
"""
self._timer = None
self.interval = interval
Expand Down Expand Up @@ -265,9 +264,10 @@ def stop(self):
app.iterate_files()
# app = WebpConverter(filenames)
else:
# noinspection PyUnboundLocalVariable
class App:
# TODO: Add UI
def __init__(self, master: tk.Tk, overrideSupportedFormat=supportedFormats):
def __init__(self, master: tk.Toplevel, overrideSupportedFormat=supportedFormats, settings=None):
"""
:param master: tkinter integration
:param overrideSupportedFormat: Override these formats to include any that is supported by PIL
Expand All @@ -279,6 +279,8 @@ def __init__(self, master: tk.Tk, overrideSupportedFormat=supportedFormats):
self.cbzFilePathList = list[str]()
self.overrideSupportedFormat = overrideSupportedFormat

self.settings = settings

def start(self):

if not self.cbzFilePathList:
Expand Down Expand Up @@ -335,7 +337,7 @@ def start(self):
self._supported_formats = self.overrideSupportedFormat
# logger.info("Processing...")
try:
self._process()
self._process(cbzFilepath, self._tmpname)

os.remove(self.zipFilePath)
os.rename(self._tmpname, self.zipFilePath)
Expand All @@ -361,9 +363,9 @@ def start(self):
# _printProgressBar(i + 1, l, prefix=f"Progress:", suffix='Complete', length=50)
logger.info("Completed processing for all selected files")

def _process(self):
with zipfile.ZipFile(self.zipFilePath, 'r') as zin:
with zipfile.ZipFile(self._tmpname, 'w') as zout:
def _process(self, cbzFilepath, tmp_path):
with zipfile.ZipFile(cbzFilepath, 'r') as zin:
with zipfile.ZipFile(tmp_path, 'w') as zout:
for zipped_file in zin.infolist():
# logger.debug(f"Processing file {zipped_file.filename}")
file_format = re.findall(r"(?i)\.[a-z]+$", zipped_file.filename)
Expand All @@ -385,9 +387,11 @@ def _process(self):

def _select_files(self):

self.epubsPathList = list[str]()
files_IO = filedialog.askopenfiles(title="Select .cbz files to convert its content to .webp",
filetypes=(("epub Files", ".cbz"),))
self.clear_queue()
files_IO = askopenfiles(parent=self.master,
initialdir=self.settings.get("library_folder_path"),
title="Select .cbz files to convert its content to .webp",
filetypes=(("epub Files", ".cbz"),))
for file in files_IO:
self.cbzFilePathList.append(file.name)
displayed_file_path = f"...{file.name[-65:]}"
Expand All @@ -396,7 +400,17 @@ def _select_files(self):

# self.run()

def clear_queue(self):
self.cbzFilePathList = list[str]()
try:
logger.debug(" Try to clear treeview")
self.listbox_1.delete(0, tk.END)
logger.info("Cleared queue")
except Exception as e:
logger.error("Can't clear treeview", exc_info=e)

def start_ui(self):
self.master.title("Webp Converter")
# build ui
self.frame_1 = tk.Frame(self.master)

Expand All @@ -407,10 +421,18 @@ def start_ui(self):
self.label_2.configure(font='{SUBTITLE} 12 {}',
text='This script converts the images to .webp format.')
self.label_2.grid(column='0', row='1')
self.button_1 = tk.Button(self.frame_1)

self.button_box = tk.Frame(self.frame_1)
self.button_box.grid(column='0', row='2')

self.button_1 = tk.Button(self.button_box)
self.button_1.configure(text='Load .cbz files')
self.button_1.grid(column='0', row='2')
self.button_1.grid(column='0', row='0')
self.button_1.configure(command=self._select_files)
self.button_3 = tk.Button(self.button_box)
self.button_3.configure(compound='top', font='TkTextFont', text='Clear Queue')
self.button_3.grid(column='1', row='0', sticky='ew')
self.button_3.configure(command=self.clear_queue)
self.label_3 = tk.Label(self.frame_1)
self.label_3.configure(text='Selected files:')
self.label_3.grid(column='0', row='3')
Expand All @@ -421,9 +443,11 @@ def start_ui(self):
self.button_2.configure(text='Process')
self.button_2.grid(column='0', row='5')
self.button_2.configure(command=self.start)
self.frame_1.configure(height='200', padx='50', pady='50', width='200')
self.frame_1.grid(column='0', row='0')
self.frame_1.rowconfigure('2', pad='20')

self.frame_1.configure(height='200', padx='60', pady='60', width='200')
self.frame_1.pack(anchor='center', expand='true', fill='both', side='top')
self.frame_1.grid_anchor('center')

self._progressbar_frame = tk.Frame(self.frame_1)
self._progressbar_frame.grid(column=0, row=6)

Expand Down
28 changes: 19 additions & 9 deletions MangaManager/ConvertersLib/epub2cbz/epub2cbz.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
import tkinter as tk
import zipfile
from pathlib import Path
from tkinter import filedialog

from tkinter.filedialog import askopenfiles, askdirectory
from tkinter.ttk import Style, Progressbar

# from CommonLib import webp_converter as convert_to_webp

logger = logging.getLogger(__name__)


# noinspection PyUnboundLocalVariable
class App:
def __init__(self, master: tk.Tk, epubsPathList: list[str] = None, convert_to_webp=False, ):
def __init__(self, master: tk.Toplevel, epubsPathList: list[str] = None, convert_to_webp=False, settings=None):
"""
If there are epubsPathList; start() must be called manually
Expand All @@ -28,10 +30,12 @@ def __init__(self, master: tk.Tk, epubsPathList: list[str] = None, convert_to_we
master = tk.Tk()
self.master = master
self.epubsPathList = epubsPathList
self.settings = settings
self._initialized_UI = False

if not epubsPathList:
self._initialized_UI = True
self.start_ui()
# self.start_ui()

def start(self):
if not self.epubsPathList:
Expand Down Expand Up @@ -113,10 +117,12 @@ def start(self):
logger.error(f"Error processing file '{epubPath}': {str(e)}",e)
processed_errors += 1
try:
# noinspection PyUnboundLocalVariable
os.remove(tmpname)
except UnboundLocalError: # we just want to make sure there are no leftover files
pass
if self._initialized_UI:
# noinspection PyUnboundLocalVariable
pb_root.update()
percentage = ((processed_counter + processed_errors) / total) * 100
style.configure('text.Horizontal.TProgressbar',
Expand Down Expand Up @@ -157,8 +163,9 @@ def _processFile(self, zipFilePath, tmpname):
def _select_files(self):

self.epubsPathList = list[str]()
files_IO = filedialog.askopenfiles(title="Select .epubs files to extract to .cbz",
filetypes=(("epub Files", ".epub"),))
files_IO = askopenfiles(parent=self.master, initialdir=self.settings.get("library_folder_path"),
title="Select .epubs files to extract to .cbz",
filetypes=(("epub Files", ".epub"),))
for file in files_IO:
self.epubsPathList.append(file.name)
displayed_file_path = f"...{file.name[-65:]}"
Expand All @@ -169,6 +176,7 @@ def _select_files(self):

def start_ui(self):
# build ui
self.master.title("Epub2Cbz Converter")
self.frame_1 = tk.Frame(self.master)

self.label_1 = tk.Label(self.frame_1)
Expand All @@ -192,9 +200,7 @@ def start_ui(self):
self.button_2.configure(text='Process')
self.button_2.grid(column='0', row='5')
self.button_2.configure(command=self.start)
self.frame_1.configure(height='200', padx='50', pady='50', width='200')
self.frame_1.grid(column='0', row='0')
self.frame_1.rowconfigure('2', pad='20')

self._progressbar_frame = tk.Frame(self.frame_1)
self._progressbar_frame.grid(column=0, row=6)
self.button_2 = tk.Button(self.frame_1)
Expand All @@ -205,10 +211,14 @@ def start_ui(self):
self.label_4.configure(text='Selected folder:\nfile_path/epub2cbz/')
self.label_4.grid(column='0', row=8)

self.frame_1.configure(height='200', padx='60', pady='60', width='200')
self.frame_1.pack(anchor='center', expand='true', fill='both', side='top')
self.frame_1.grid_anchor('center')

self._initialized_UI = True

def _change_out_folder(self):
self.output_folder = filedialog.askdirectory()
self.output_folder = askdirectory(parent=self.master, initialdir=self.settings.get("library_folder_path"))
self.label_4.configure(text="Selected folder:\n" + self.output_folder)

def run(self):
Expand Down
Loading

0 comments on commit 85b25f9

Please sign in to comment.