KBlixt / subcleaner

removes ads from subtitle files cleanly.
284 stars 12 forks source link

Can'r run it through bazarr #56

Closed miguelpruivo closed 5 months ago

miguelpruivo commented 5 months ago

Hi, I've followed all the instructions but somehow I can't get it work under bazarr, I always seem to get this:

BAZARR Post-processing result for file /mnt/data/shows/Constellation (2024) [imdb-tt19395018]/Season 01/Constellation (2024) [imdb-tt19395018] - S01E07 - Through The Looking Glass [ATVP WEBDL-2160p][DV][EAC3 Atmos 5.1][h265]-FLUX.mkv: Traceback (most recent call last): File "/opt/subcleaner/subcleaner.py", line 10, in <module> from libs.subcleaner import main File "/opt/subcleaner/libs/subcleaner/main.py", line 4, in <module> from .subtitle import Subtitle, ParsingException, FileContentException File "/opt/subcleaner/libs/subcleaner/subtitle.py", line 6, in <module> from .settings import args, config File "/opt/subcleaner/libs/subcleaner/settings/__init__.py", line 3, in <module> from . import log_config File "/opt/subcleaner/libs/subcleaner/settings/log_config.py", line 15, in <module> file_handler = logging.handlers.RotatingFileHandler(config.log_file, maxBytes=10_000_000, backupCount=10, encoding='utf8') File "/usr/lib/python3.9/logging/handlers.py", line 153, in __init__ BaseRotatingHandler.__init__(self, filename, mode, encoding=encoding, File "/usr/lib/python3.9/logging/handlers.py", line 58, in __init__ logging.FileHandler.__init__(self, filename, mode=mode, File "/usr/lib/python3.9/logging/__init__.py", line 1142, in __init__ StreamHandler.__init__(self, self._open()) File "/usr/lib/python3.9/logging/__init__.py", line 1171, in _open return open(self.baseFilename, self.mode, encoding=self.encoding, OSError: [Errno 30] Read-only file system: '/opt/subcleaner/logs/subcleaner.log'

Looks like it never can't open the logs. I already tried assigning the user of subcleaner to bazarr without success. It still doesn't work. Running directly in the CLI works perfectly tho.

KBlixt commented 5 months ago

This is a permission issue as you've concluded.

Im not sure how much I can help here. I'd suggest reading up on the subject but if you post the ls -la command for the log directory as well as subcleaner directory and make sure that the /opt directory can be at least read by all users.

I'll also need to know the gid and uid of the user running the container and/or the groups of the user running the bazarr process.

If I had to guess it's an issue with the log file that it was created by the user you run with manually and the bazarr user don't have read access to your group. Add it or make the log directory stickied to a group that both you and the bazarr user have access to.

miguelpruivo commented 5 months ago

I gave full permissions to the logs folder and still I get the same thing:

drwxrwsr-x 8 bazarr dietpi 4096 Mar 26 12:34 .git
-rw-rwSr-- 1 bazarr dietpi 5047 Mar 26 12:34 .gitignore
-rw-rwSr-- 1 bazarr dietpi 2919 Mar 26 12:34 README.md
drwxrwsr-x 2 bazarr dietpi 4096 Mar 26 12:34 default_config
drwxrwsr-x 5 bazarr dietpi 4096 Mar 26 12:34 libs
drwxrwsrwx 2 bazarr dietpi 4096 Mar 26 14:04 logs
drwxrwsr-x 3 bazarr dietpi 4096 Mar 26 12:34 regex_profiles
-rw-rwSr-- 1 bazarr dietpi 1404 Mar 26 14:03 subcleaner.conf
-rw-rwSr-- 1 bazarr dietpi  799 Mar 26 12:34 subcleaner.py

I even changed the owner just to make sure to be bazarr.

Again, when I run through the CLI it works, just not only from bazarr which is running natively.

miguelpruivo commented 5 months ago

Now the error is a bit different:

BAZARR Post-processing result for file /mnt/data/shows/Constellation (2024) [imdb-tt19395018]/Season 01/Constellation (2024) [imdb-tt19395018] - S01E07 - Through The Looking Glass [ATVP WEBDL-2160p][DV][EAC3 Atmos 5.1][h265]-FLUX.mkv: Traceback (most recent call last): File "/opt/subcleaner/subcleaner.py", line 10, in <module> from libs.subcleaner import main File "/opt/subcleaner/libs/subcleaner/main.py", line 4, in <module> from .subtitle import Subtitle, ParsingException, FileContentException File "/opt/subcleaner/libs/subcleaner/subtitle.py", line 6, in <module> from .settings import args, config File "/opt/subcleaner/libs/subcleaner/settings/__init__.py", line 3, in <module> from . import log_config File "/opt/subcleaner/libs/subcleaner/settings/log_config.py", line 15, in <module> file_handler = logging.handlers.RotatingFileHandler(config.log_file, maxBytes=10_000_000, backupCount=10, encoding='utf8') File "/usr/lib/python3.9/logging/handlers.py", line 153, in __init__ BaseRotatingHandler.__init__(self, filename, mode, encoding=encoding, File "/usr/lib/python3.9/logging/handlers.py", line 58, in __init__ logging.FileHandler.__init__(self, filename, mode=mode, File "/usr/lib/python3.9/logging/__init__.py", line 1142, in __init__ StreamHandler.__init__(self, self._open()) File "/usr/lib/python3.9/logging/__init__.py", line 1171, in _open return open(self.baseFilename, self.mode, encoding=self.encoding, OSError: [Errno 30] Read-only file system: '/opt/subcleaner/logs/subcleaner.log'
miguelpruivo commented 5 months ago

Commenting this block fixes it:

# file handler
# if not args.no_log:
#     file_handler = logging.handlers.RotatingFileHandler(config.log_file, maxBytes=10_000_000, backupCount=10, encoding='utf8')
#     file_handler.setFormatter(time_formatter)
#     file_handler.setLevel(logging.INFO)
#     if args.errors_only:
#         file_handler.setLevel(logging.ERROR)
#     base_logger.addHandler(file_handler)
KBlixt commented 5 months ago

As I mentioned in my reply I think it's the log file that is the issue. Not the log directory. What does the log file have for permissions?

miguelpruivo commented 5 months ago

I gave to everything actually.

miguelpruivo commented 5 months ago

@KBlixt sorry I replied with my phone on the previous post, it was a short answer, but basically I gave permissions to all (chmod 777) to that directory. Yet, it still persists.

It’s working now because I’ve commented the logs code but I’d really like to understand what’s the cause.

KBlixt commented 5 months ago

Run:

ls -l /opt/subcleaner/logs

miguelpruivo commented 5 months ago

Run:

ls -l /opt/subcleaner/logs

-rwxrwxrwx 1 bazarr dietpi 0 Mar 26 14:04 subcleaner.log
KBlixt commented 5 months ago

Hm, strange. Are you able to write to the file with the bazarr user?

sudo -u bazarr nano /opt/subcleaner/logs/subcleaner.log

Edit something and try to save it.

If that works. Mh, very strange.

You could try to move the log directory somewhere else perhaps? And see if that works. You can do that in the config file.

Is /opt or /opt/subcleaner in some kind of network drive/share?