From 1c9eeee52df8a6b6b18e9d2a40c3577b0692af9b Mon Sep 17 00:00:00 2001 From: darodi <4682830+darodi@users.noreply.github.com> Date: Wed, 8 Feb 2023 19:00:40 +0100 Subject: [PATCH 1/3] use unrar for fedora only --- kindlecomicconverter/comicarchive.py | 11 +++++++---- requirements.txt | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/kindlecomicconverter/comicarchive.py b/kindlecomicconverter/comicarchive.py index dcaec36..697577e 100644 --- a/kindlecomicconverter/comicarchive.py +++ b/kindlecomicconverter/comicarchive.py @@ -19,6 +19,7 @@ # import os +import distro from psutil import Popen from shutil import move from subprocess import STDOUT, PIPE @@ -38,15 +39,17 @@ class ComicArchive: self.type = line.rstrip().decode().split(' = ')[1].upper() break process.communicate() - if process.returncode != 0: + if process.returncode != 0 and distro.id() == 'fedora': process = Popen('unrar l -y -p1 "' + self.filepath + '"', stderr=STDOUT, stdout=PIPE, stdin=PIPE, shell=True) for line in process.stdout: if b'Details: ' in line: self.type = line.rstrip().decode().split(' ')[1].upper() - print(self.type) break - if(self.type != 'RAR'): + process.communicate() + if process.returncode != 0: raise OSError('Archive is corrupted or encrypted.') + elif self.type not in ['7Z', 'RAR', 'RAR5', 'ZIP']: + raise OSError('Unsupported archive format.') elif self.type not in ['7Z', 'RAR', 'RAR5', 'ZIP']: raise OSError('Unsupported archive format.') @@ -56,7 +59,7 @@ class ComicArchive: process = Popen('7z x -y -xr!__MACOSX -xr!.DS_Store -xr!thumbs.db -xr!Thumbs.db -o"' + targetdir + '" "' + self.filepath + '"', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True) process.communicate() - if process.returncode != 0: + if process.returncode != 0 and distro.id() == 'fedora': process = Popen('unrar x -y -x__MACOSX -x.DS_Store -xthumbs.db -xThumbs.db "' + self.filepath + '" "' + targetdir + '"', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True) process.communicate() diff --git a/requirements.txt b/requirements.txt index 026f92d..156b842 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ psutil>=5.0.0 python-slugify>=1.2.1 raven>=6.0.0 # PyQt5-tools -mozjpeg-lossless-optimization>=1.1.2 \ No newline at end of file +mozjpeg-lossless-optimization>=1.1.2 +distro \ No newline at end of file From dd5fd621db21ccf9d051ba027eee25d07e257f53 Mon Sep 17 00:00:00 2001 From: cookie99999 <77994115+cookie99999@users.noreply.github.com> Date: Fri, 12 May 2023 15:15:57 -0400 Subject: [PATCH 2/3] Update README.md Recommend to install p7zip-rar on Debian based systems, as it is needed to properly decompress rar files (As explained under "supported formats" on https://packages.debian.org/sid/p7zip-full). (cherry picked from commit f3ee9b770b6316e69d4750f0334bd2f57ea13cd5) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c1ed5a3..83c72ed 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ On Debian based distributions these two commands should install all needed depen ```bash -$ sudo apt-get install -y python3 python3-dev libpng-dev libjpeg-dev p7zip-full unrar-free libgl1 python3-pyqt5 && \ +$ sudo apt-get install -y python3 python3-dev libpng-dev libjpeg-dev p7zip-full p7zip-rar unrar-free libgl1 python3-pyqt5 && \ python -m pip install --upgrade pip && \ python -m pip install --upgrade -r requirements.txt ``` From dba927c351e22dace3aaeb5735b98fc991dfb548 Mon Sep 17 00:00:00 2001 From: darodi <4682830+darodi@users.noreply.github.com> Date: Sat, 13 May 2023 18:24:18 +0200 Subject: [PATCH 3/3] use unrar for fedora only --- kindlecomicconverter/comicarchive.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kindlecomicconverter/comicarchive.py b/kindlecomicconverter/comicarchive.py index 697577e..f0d968e 100644 --- a/kindlecomicconverter/comicarchive.py +++ b/kindlecomicconverter/comicarchive.py @@ -65,6 +65,8 @@ class ComicArchive: process.communicate() if process.returncode != 0: raise OSError('Failed to extract archive.') + elif process.returncode != 0: + raise OSError('Failed to extract archive. Check if p7zip-rar is installed.') tdir = os.listdir(targetdir) if 'ComicInfo.xml' in tdir: tdir.remove('ComicInfo.xml')