diff --git a/bazarr/init.py b/bazarr/init.py index e399dd89c..7d798e890 100644 --- a/bazarr/init.py +++ b/bazarr/init.py @@ -4,6 +4,8 @@ import os import sqlite3 import logging import time +import platform +import rarfile from cork import Cork try: @@ -147,3 +149,41 @@ if not os.path.exists(os.path.normpath(os.path.join(args.config_dir, 'config', ' 'creation_date': tstamp } cork._store.save_users() + + +def init_binaries(): + binaries_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'bin')) + + unrar_exe = None + exe = None + if platform.system() == "Windows": # Windows + unrar_exe = os.path.abspath(os.path.join(binaries_dir, "Windows", "i386", "UnRAR", "UnRAR.exe")) + + elif platform.system() == "Darwin": # MacOSX + unrar_exe = os.path.abspath(os.path.join(binaries_dir, "MacOSX", "i386", "UnRAR", "unrar")) + + elif platform.system() == "Linux": # Linux + unrar_exe = os.path.abspath(os.path.join(binaries_dir, "Linux", platform.machine(), "UnRAR", "unrar")) + + else: + unrar_exe = "unrar" + + if unrar_exe and os.path.isfile(unrar_exe): + exe = unrar_exe + + rarfile.UNRAR_TOOL = exe + rarfile.ORIG_UNRAR_TOOL = exe + try: + rarfile.custom_check([rarfile.UNRAR_TOOL], True) + except: + logging.debug("custom check failed for: %s", exe) + + rarfile.OPEN_ARGS = rarfile.ORIG_OPEN_ARGS + rarfile.EXTRACT_ARGS = rarfile.ORIG_EXTRACT_ARGS + rarfile.TEST_ARGS = rarfile.ORIG_TEST_ARGS + logging.info("Using UnRAR from: %s", exe) + unrar = exe + + return unrar + +init_binaries() \ No newline at end of file diff --git a/bin/Linux/aarch64/UnRAR/unrar b/bin/Linux/aarch64/UnRAR/unrar new file mode 100644 index 000000000..c5e244bda Binary files /dev/null and b/bin/Linux/aarch64/UnRAR/unrar differ diff --git a/bin/Linux/armv5tel/UnRAR/unrar b/bin/Linux/armv5tel/UnRAR/unrar new file mode 100644 index 000000000..c5e244bda Binary files /dev/null and b/bin/Linux/armv5tel/UnRAR/unrar differ diff --git a/bin/Linux/i386/UnRAR/unrar b/bin/Linux/i386/UnRAR/unrar new file mode 100644 index 000000000..b40268992 Binary files /dev/null and b/bin/Linux/i386/UnRAR/unrar differ diff --git a/bin/Linux/x86_64/UnRAR/unrar b/bin/Linux/x86_64/UnRAR/unrar new file mode 100644 index 000000000..b40268992 Binary files /dev/null and b/bin/Linux/x86_64/UnRAR/unrar differ diff --git a/bin/MacOSX/i386/UnRAR/unrar b/bin/MacOSX/i386/UnRAR/unrar new file mode 100644 index 000000000..f32104fbc Binary files /dev/null and b/bin/MacOSX/i386/UnRAR/unrar differ diff --git a/bin/Windows/i386/UnRAR/UnRAR.exe b/bin/Windows/i386/UnRAR/UnRAR.exe new file mode 100644 index 000000000..1adb5f50c Binary files /dev/null and b/bin/Windows/i386/UnRAR/UnRAR.exe differ diff --git a/bin/Windows/i386/UnRAR/license.txt b/bin/Windows/i386/UnRAR/license.txt new file mode 100644 index 000000000..2c21c446e --- /dev/null +++ b/bin/Windows/i386/UnRAR/license.txt @@ -0,0 +1,34 @@ + ****** ***** ****** UnRAR - free utility for RAR archives + ** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ****** ******* ****** License for use and distribution of + ** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ** ** ** ** ** ** FREEWARE version + ~~~~~~~~~~~~~~~~ + + The UnRAR utility is freeware. This means: + + 1. All copyrights to RAR and the utility UnRAR are exclusively + owned by the author - Alexander Roshal. + + 2. The UnRAR utility may be freely distributed. It is allowed + to distribute UnRAR inside of other software packages. + + 3. THE RAR ARCHIVER AND THE UnRAR UTILITY ARE DISTRIBUTED "AS IS". + NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED. YOU USE AT + YOUR OWN RISK. THE AUTHOR WILL NOT BE LIABLE FOR DATA LOSS, + DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING + OR MISUSING THIS SOFTWARE. + + 4. Neither RAR binary code, WinRAR binary code, UnRAR source or UnRAR + binary code may be used or reverse engineered to re-create the RAR + compression algorithm, which is proprietary, without written + permission of the author. + + 5. If you don't agree with terms of the license you must remove + UnRAR files from your storage devices and cease to use the + utility. + + Thank you for your interest in RAR and UnRAR. + + + Alexander L. Roshal \ No newline at end of file