Skip to content

Commit

Permalink
Added support for 7z by upgrading rarfile dependency
Browse files Browse the repository at this point in the history
- Bump rarfile.py from 4.0 to 4.1
- Add support for 7zip for archive extractions, since unar is a steaming pile
  of C# and unrar is non-free, having some easy-to-package software to
  handle archive makes it easier to run Bazarr on Linux distributions.
  • Loading branch information
jvoisin authored Dec 2, 2023
1 parent c97a98d commit 4b7cdbc
Show file tree
Hide file tree
Showing 3 changed files with 232 additions and 77 deletions.
20 changes: 16 additions & 4 deletions bazarr/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,28 @@ def init_binaries():
exe = get_binary("unar")
rarfile.UNAR_TOOL = exe
rarfile.UNRAR_TOOL = None
rarfile.tool_setup(unrar=False, unar=True, bsdtar=False, force=True)
rarfile.SEVENZIP_TOOL = None
rarfile.tool_setup(unrar=False, unar=True, bsdtar=False, sevenzip=False, force=True)
except (BinaryNotFound, rarfile.RarCannotExec):
try:
exe = get_binary("unrar")
rarfile.UNRAR_TOOL = exe
rarfile.UNAR_TOOL = None
rarfile.tool_setup(unrar=True, unar=False, bsdtar=False, force=True)
rarfile.SEVENZIP_TOOL = None
rarfile.tool_setup(unrar=True, unar=False, bsdtar=False, sevenzip=False, force=True)
except (BinaryNotFound, rarfile.RarCannotExec):
logging.exception("BAZARR requires a rar archive extraction utilities (unrar, unar) and it can't be found.")
raise BinaryNotFound
try:
exe = get_binary("7z")
rarfile.UNRAR_TOOL = None
rarfile.UNAR_TOOL = None
rarfile.SEVENZIP_TOOL = "7z"
rarfile.tool_setup(unrar=False, unar=False, bsdtar=False, sevenzip=True, force=True)
except (BinaryNotFound, rarfile.RarCannotExec):
logging.exception("BAZARR requires a rar archive extraction utilities (unrar, unar, 7zip) and it can't be found.")
raise BinaryNotFound
else:
logging.debug("Using 7zip from: %s", exe)
return exe
else:
logging.debug("Using UnRAR from: %s", exe)
return exe
Expand Down
Loading

0 comments on commit 4b7cdbc

Please sign in to comment.