ZeroQI / Absolute-Series-Scanner

Seasons, absolute mode, Subfolders...
1.01k stars 155 forks source link

Scanner crash on Shield Android TV #313

Closed remygrandin closed 3 years ago

remygrandin commented 3 years ago

Platform

Operating system and version: Shield Andoid TV, Android TV Ver 8.2.1 Plex version: 4.43.4

Expected Behavior

I expect the plugin to scan my media folder.

Current Behavior

The scan return no media The scanner seem to crash according to the log (Plex Media Scanner.log) :

Nov 17, 2020 22:03:59.334 [10285] DEBUG - HTTP requesting PUT http://127.0.0.1:32400/activities/96c1e816-0636-4475-b8d3-9be111fc54fb?percentComplete=%2B16%2E5&subtitle=One%20Punch%20Man%20%282019%29
Nov 17, 2020 22:03:59.337 [10285] DEBUG - HTTP 200 response from PUT http://127.0.0.1:32400/activities/96c1e816-0636-4475-b8d3-9be111fc54fb?percentComplete=%2B16%2E5&subtitle=One%20Punch%20Man%20%282019%29
Nov 17, 2020 22:03:59.338 [10285] ERROR - We got an error scanning in /storage/TITANE/Public/Plex/Anime
Nov 17, 2020 22:03:59.338 [10285] DEBUG - Scanner: Processing directory /storage/TITANE/Public/Plex/Anime/One Punch Man (parent: yes)
Nov 17, 2020 22:03:59.338 [10285] VERBOSE -     * Noting that 'One Punch Man' was updated at 2020-04-07 22:47:16
Nov 17, 2020 22:03:59.338 [10285] VERBOSE -     * Taking directory 'One Punch Man' (447) out of the map (0 left)
Nov 17, 2020 22:03:59.350 [10285] VERBOSE - Adding file for scanner: "/storage/TITANE/Public/Plex/Anime/One Punch Man/One Punch Man - 01 - The Strongest Man.mkv"
Nov 17, 2020 22:03:59.350 [10285] VERBOSE - Adding file for scanner: "/storage/TITANE/Public/Plex/Anime/One Punch Man/One Punch Man - 02 - The Lone Cyborg.mkv"
Nov 17, 2020 22:03:59.350 [10285] VERBOSE - Adding file for scanner: "/storage/TITANE/Public/Plex/Anime/One Punch Man/One Punch Man - 03 - The Obsessive Scientist.mkv"
Nov 17, 2020 22:03:59.350 [10285] VERBOSE - Adding file for scanner: "/storage/TITANE/Public/Plex/Anime/One Punch Man/One Punch Man - 04 - The Modern Ninja.mkv"
Nov 17, 2020 22:03:59.350 [10285] VERBOSE - Adding file for scanner: "/storage/TITANE/Public/Plex/Anime/One Punch Man/One Punch Man - 05 - The Ultimate Master.mkv"
Nov 17, 2020 22:03:59.350 [10285] VERBOSE - Adding file for scanner: "/storage/TITANE/Public/Plex/Anime/One Punch Man/One Punch Man - 06 - The Terrifying City.mkv"
Nov 17, 2020 22:03:59.350 [10285] VERBOSE - Adding file for scanner: "/storage/TITANE/Public/Plex/Anime/One Punch Man/One Punch Man - 07 - The Ultimate Disciple.mkv"
Nov 17, 2020 22:03:59.350 [10285] VERBOSE - Adding file for scanner: "/storage/TITANE/Public/Plex/Anime/One Punch Man/One Punch Man - 08 - The Deep Sea King.mkv"
Nov 17, 2020 22:03:59.350 [10285] VERBOSE - Adding file for scanner: "/storage/TITANE/Public/Plex/Anime/One Punch Man/One Punch Man - 09 - Unyielding Justice.mkv"
Nov 17, 2020 22:03:59.350 [10285] VERBOSE - Adding file for scanner: "/storage/TITANE/Public/Plex/Anime/One Punch Man/One Punch Man - 10 - Unparalleled Peril.mkv"
Nov 17, 2020 22:03:59.350 [10285] VERBOSE - Adding file for scanner: "/storage/TITANE/Public/Plex/Anime/One Punch Man/One Punch Man - 11 - The Dominator of the Universe.mkv"
Nov 17, 2020 22:03:59.350 [10285] VERBOSE - Adding file for scanner: "/storage/TITANE/Public/Plex/Anime/One Punch Man/One Punch Man - 12 - The Strongest Hero.mkv"
Nov 17, 2020 22:03:59.360 [10285] DEBUG - Directory had 12 files, database had 0 files, can't skip.
Nov 17, 2020 22:03:59.390 [10285] ERROR - No module in Absolute Series Scanner
Nov 17, 2020 22:03:59.390 [10285] ERROR - Error in Python: Looking up module:
Traceback (most recent call last):
  File "/data/user/0/com.plexapp.mediaserver.smb/Plex Media Server/Scanners/Series/Absolute Series Scanner.py", line 125, in <module>
    set_logging("Root", LOG_FILE_LIBRARY)
  File "/data/user/0/com.plexapp.mediaserver.smb/Plex Media Server/Scanners/Series/Absolute Series Scanner.py", line 108, in set_logging
    handler = logging.handlers.RotatingFileHandler(os.path.join(LOG_PATH, filename), maxBytes=10*1024*1024, backupCount=backup_count)    #handler = logging.FileHandler(os.path.join(LOG_PATH, filename), mode)
  File "/data/user/0/com.plexapp.mediaserver.smb/Resources/Python/lib/python2.7/logging/handlers.py", line 117, in __init__
    BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
  File "/data/user/0/com.plexapp.mediaserver.smb/Resources/Python/lib/python2.7/logging/handlers.py", line 64, in __init__
    logging.FileHandler.__init__(self, filename, mode, encoding, delay)
  File "/data/user/0/com.plexapp.mediaserver.smb/Resources/Python/lib/python2.7/logging/__init__.py", line 920, in __init__
    StreamHandler.__init__(self, self._open())
  File "/data/user/0/com.plexapp.mediaserver.smb/Resources/Python/lib/python2.7/logging/__init__.py", line 950, in _open
    stream = open(self.baseFilename, self.mode)
IOError: (2, 'No such file or directory', '/data/user/0/com.plexapp.mediaserver.smb/Plex Media Server/Logs/Plex Media Scanner (custom ASS).log')
Nov 17, 2020 22:03:59.391 [10285] DEBUG - HTTP requesting PUT http://127.0.0.1:32400/activities/96c1e816-0636-4475-b8d3-9be111fc54fb?percentComplete=%2B16%2E5&subtitle=One%20Punch%20Man
Nov 17, 2020 22:03:59.394 [10285] DEBUG - HTTP 200 response from PUT http://127.0.0.1:32400/activities/96c1e816-0636-4475-b8d3-9be111fc54fb?percentComplete=%2B16%2E5&subtitle=One%20Punch%20Man
Nov 17, 2020 22:03:59.395 [10285] ERROR - We got an error scanning in /storage/TITANE/Public/Plex/Anime
Nov 17, 2020 22:03:59.395 [10285] WARN - Scanning the location /storage/TITANE/Public/Plex/Anime did not complete

Steps to Reproduce

  1. Install the plugin on shield TV
  2. Scan Library
  3. After the scan end, no media at all in the library

Additional information

It's my first plex install on my shield TV

ZeroQI commented 3 years ago

It seems the rights to write in this folder are lacking: '/data/user/0/com.plexapp.mediaserver.smb/Plex Media Server/Logs/Plex Media Scanner (custom ASS).log'... You do not have a standard plex platform, so I do not know if you can edit rights OR give me a path with write rights to solve the issue...

remygrandin commented 3 years ago

Is there an option to not output log at all or to output them into the main scanner log directly ?

What is weider is that this folder pointed by the stacktrace don't correspond to one I can easily see.

In the plex server android app it allow me to chose between 2 storage location. This give me for exemple for the logs either :

(I've tried bothe with no luck, exact sasme error)

I've looked but my file browser don't show me a /data on the FS root and I don't see a folder Resources in the com.plexapp.mediaserver.smb I have in the data directory

I suspect /data/user/0/com.plexapp.mediaserver.smb/ to be either a fake path to the plex apk files which would be read only or to be some kind of layered FS with both the apk file and any saved extra file, in wich case it would definitly be a permission issue.

I will try to fins an android tv compatible terminal app to see if I can chmod the log folder.

ZeroQI commented 3 years ago

the folder seen in the error message looks off but cannot tell if a real folder or not... I cannot change much, apart giving it a known folder with the correct rights if that solves ('/storage/emulated/0/Plex Media Server/Logs' ?)

https://github.com/ZeroQI/Absolute-Series-Scanner/blob/master/Scanners/Series/Absolute%20Series%20Scanner.py line 165 replace with the below (do a backup beforehands) PLEX_ROOT = '/storage/emulated/0/Plex Media Server/Logs'

if that works i can code a workaround... Otherwise, giving write rights to the folder works normally...

remygrandin commented 3 years ago

Ok, so weird thing here, I don't know why put the plex server was not willing to use the updated script I made with your suggested modification. Even weirder, it was telling me the scanner was stil thenre even if I removed the file completly (with a full shield reboot between each try)...

In the end I resetted the whole plex and added the "patched" version diretly and low and behold, it works !

Now I have to try to update it with PLEX_ROOT = '/storage/emulated/0/Plex Media Server'

(without the log at the end, because it created a log folder in the log folder ..p :p, not a major probleme for sure but I would rather try to fix it now than later)

I still have to find why this andoird version has a plugin cache of some sort and how to force it to refresh.

Anyway this fix is the right thing to do on this plateform.

ZeroQI commented 3 years ago

https://github.com/ZeroQI/Absolute-Series-Scanner/blob/master/Scanners/Series/Absolute%20Series%20Scanner.py lines 165-169

  PLEX_ROOT = os.path.abspath(os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), "..", ".."))
  if not os.path.isdir(PLEX_ROOT):
    path_location = { 'Windows': '%LOCALAPPDATA%\\Plex Media Server',
                      'MacOSX':  '$HOME/Library/Application Support/Plex Media Server',
                      'Linux':   '$PLEX_HOME/Library/Application Support/Plex Media Server',
                      'Android':   '/storage/emulated/0/Plex Media Server' }

This is the patch i should have advised to run, but based on your feedback on the previous one, it solves the issue Added to master the fix