ZeroQI / Absolute-Series-Scanner

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

Movie in a folder alongside a special gets identified as a special #356

Closed pathsny closed 3 years ago

pathsny commented 3 years ago

Platform

Operating system and version: Truenas-12.0-Stable (Freebsd 11.2-RELEASE-p9) Plex version: 1.22.3.4392

Expected Behavior

Correctly tag movie files as being in season 1

Current Behavior

When a movie folder includes a special, the movie gets identified as a special

Steps to Reproduce

  1. When I have

    Final Fantasy VII Advent Children
    |__ Final Fantasy VII Advent Children - Complete Movie [AonE].avi

    the file gets recognized as Season 1, Episode 1 (Complete Movie)

  2. When I have

    Final Fantasy VII Advent Children
    |__ Final Fantasy VII Advent Children - Complete Movie [AonE].avi
    |__ Final Fantasy VII Advent Children - On the Way to a Smile Episode Denzel - episode S5 [THORA].mkv

    the files get recognized as S00E05 and S00E01

As you can see, the addition of another file changes how the movie gets identified.

Additional information

Plex scan start: 2021-05-10 19:21:19,818325
=============================================================================================================================================================
Forced ID (source file) - source: "anidb", id: "1208"
-------------------------------------------------------------------------------------------------------------------------------------------------------------
misc_count: {'Complete': 1, 'Movie': 1, 'VII': 1, 'Advent': 1, 'Children': 1, 'Fantasy': 1, 'avi': 1, 'Final': 1}
misc_words: []
-------------------------------------------------------------------------------------------------------------------------------------------------------------
"Final Fantasy VII Advent Children [anidb-1208]" s01e001                         "Word Search" "" "Final Fantasy VII Advent Children - Complete Movie [AonE].avi"
=============================================================================================================================================================
Plex scan end: 2021-05-10 19:21:19,828280
=============================================================================================================================================================
Library: 'Anime', root: '/media/Anime/Movies', path: 'Final Fantasy VII Advent Children', files: '2', dirs: '0'
Plex scan start: 2021-05-10 21:59:26,117888
=============================================================================================================================================================
Forced ID (source file) - source: "anidb", id: "1208"
-------------------------------------------------------------------------------------------------------------------------------------------------------------
misc_count: {'a': 1, 'On': 1, 'Episode': 1, 'Complete': 1, 'to': 1, 'Movie': 1, 'VII': 2, 'Advent': 2, 'S5': 1, 'Children': 2, 'Fantasy': 2, 'episode': 1, 'Denzel': 1, 'avi': 1, 'Way': 1, 'Smile': 1, 'the': 1, 'Final': 2}
misc_words: []
-------------------------------------------------------------------------------------------------------------------------------------------------------------
"Final Fantasy VII Advent Children [anidb-1208]" s00e005                         "Word Search" "" "Final Fantasy VII Advent Children - On the Way to a Smile Episode Denzel - episode S5 [THORA].mkv"
"Final Fantasy VII Advent Children [anidb-1208]" s00e501                         "__" "Complete Movie" "Final Fantasy VII Advent Children - Complete Movie [AonE].avi"
=============================================================================================================================================================
Plex scan end: 2021-05-10 21:59:26,133944
ZeroQI commented 3 years ago

you can rename the movie s01e01 as a workaround

I permitted movies in series libraries as per the readme: "Movies in series libraries support (names same as folder or contain " - Complete Movie")", and while i did not consider specials for movies in libraries folder, "Final Fantasy VII Advent Children - Complete Movie [AonE].avi" should be seen as s01e01

THis line should give the episode 1 to the file, can't see where it goes wrong for now https://github.com/ZeroQI/Absolute-Series-Scanner/blob/master/Scanners/Series/Absolute%20Series%20Scanner.py#L988

pathsny commented 3 years ago

It works correctly when there is no other file. I wonder if the special being scanned first results in the entire folder being tagged as season 0 in some way.

pathsny commented 3 years ago

I'd like to try and debug this, but I'm unclear on how to make changes and actually see the effect. Whats the development process to make a change and actually see it reflected?

When I modify one of the log.info lines. I've tried deleting the .pyc file and restarting the plexmediaserver. But for some reason I still dont see my changes reflected.

ZeroQI commented 3 years ago

You need to do a Plex dance. If you don't change the folder content, scanner will not run again for that folder....

pathsny commented 3 years ago

Ah sorry. I meant to say, I also renamed one of the files. So I see the scanner run again and write new log entries. However none of the changes to the python file I've made seem to be executed. For instance I modified this line https://github.com/ZeroQI/Absolute-Series-Scanner/blob/master/Scanners/Series/Absolute%20Series%20Scanner.py#L169 to say

Log.info("Plex xyz scan start: {}".format(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S,%f"))) but the log entries continue to say Plex scan start: 2021-05-22 14:30:34,515010

ZeroQI commented 3 years ago

If it the indeed the same line, Plex need restarting to load the new code, maybe a my/pyc refresh issue, but never seen pyc generated before...

EndOfLine369 commented 3 years ago

@pathsny, Remove 'complete movie' from this line in WHACK and try a scan with both files in the folder.

https://github.com/ZeroQI/Absolute-Series-Scanner/blob/54c1ef279a21b2c5c5d962d8d5d67ca6d2bfc4b6/Scanners/Series/Absolute%20Series%20Scanner.py#L131

TO

                        'dsr', 'dsrip', 'hdtv', 'pdtv', 'ppv', 'stv', 'tvrip', "hiei", "metis", "norar",                                                            # Source: dtv, stv
pathsny commented 3 years ago

I removed "complete movie" and it didnt make a difference.

I also updated my scanner to the latest version and I'm running into an interesting experience with Logs now. The log file under Plug-in\ Support/Data/com.plexapp.agents.hama/DataItems/_Logs/Anime/<show name>.scanner.log does not get populated anymore. Now I only see updates in Plex Media Server/Logs/ASS Scanner Logs/<show name>.scanner.log. And this update does not include any timestamps. How do I get logs from Log.info to show up?

ZeroQI commented 3 years ago

that's where it should be. did you check in "Plex Media Scanner.log" to see if it crashed, and modified the folder content so the scanner run again (otherwise it use cached results making scanner development a pain) ?

pathsny commented 3 years ago

that's where it should be. did you check in "Plex Media Scanner.log" to see if it crashed, and modified the folder content so the scanner run again (otherwise it use cached results making scanner development a pain) ?

Not quite sure I follow. What I mean is after I updated to the latest version. Everytime I change the folder content and rescan. Plex Media Server/Logs/ASS Scanner Logs/<show name>.scanner.log gets updated, which seems to indicate that it did not crash. In addition I dont see anything in Plex Media Scanner.log indicating a crash. So I dont believe its crashing. The logs look like this

=============================================================================================================================================================
Call: "Plex", path: "Final Fantasy VII Advent Children", folder_show: "Final Fantasy VII Advent Children", dirs (0), files (2)
=============================================================================================================================================================
Unknown extension File: 'Final Fantasy VII Advent Children/anidb.id'
Unknown extension File: 'Final Fantasy VII Advent Children/tvshow.nfo'
=============================================================================================================================================================
Forced ID (source file) - source: "anidb", id: "1208"
"Final Fantasy VII Advent Children [anidb-1208]" s00e         5                         "Word Search" "On the Way to a Smile Episode Denzel - lug" "Final Fantasy VII Advent Children - episode S5 - On the Way to a Smile Episode Denzel [THORA] - lug.mkv"
"Final Fantasy VII Advent Children [anidb-1208]" s00e       501                         "__" "Complete Movie" "Final Fantasy VII Advent Children - Complete Movie [AonE].avi"
=============================================================================================================================================================

But the logs in Plug-in\ Support/Data/com.plexapp.agents.hama/DataItems/_Logs/Anime/<show name>.scanner.log have not been updated at all.

I don't know if this is normal. The logs in Plex Media Server/Logs/ASS Scanner Logs/<show name>.scanner.log are not as rich as the logs in Plug-in\ Support/Data/com.plexapp.agents.hama/DataItems/_Logs/Anime/<show name>.scanner.log used to be. For instance its missing the timestamp when the scanning should have started.

ZeroQI commented 3 years ago

Plug-in\ Support/Data/com.plexapp.agents.hama/DataItems/_Logs/Anime/.scanner.log

ZeroQI commented 3 years ago

Line 305-306 Logs folder used is in Hama agent data folder if HAMA is the primary agent otherwise it's in Plex logs.

Logs format amended to have limited instances or duration logged to avoid appending you infinitely.

pathsny commented 3 years ago

Ah I see, interestingly I've started seeing this error after I updated to the latest version. Exception: ''PLEXTOKEN'', library_xml could not be loaded. X-Plex-Token file created?

The X-Plex-Token.id file is still present inside the "Plex Media Server" folder and the token inside still works (testing it from the command line). I'm not clear why the the exception keeps occurring. https://github.com/ZeroQI/Absolute-Series-Scanner/blob/master/Scanners/Series/Absolute%20Series%20Scanner.py#L176

I printed out os.environ and I dont see a key named 'PLEXTOKEN' but I do see 'X_PLEX_TOKEN' which interestingly is not the value from the attached id file but is the value associated with a device named "plex" from devices.xml

ZeroQI commented 3 years ago

os.environ['PLEXTOKEN'] is a workaround somebody implemented for some OS... This should fix library_xml = etree.fromstring(read_url(Request(PLEX_LIBRARY_URL, headers={"X-Plex-Token": read_file(os.path.join(PLEX_ROOT, "X-Plex-Token.id")).strip() if os.path.isfile(os.path.join(PLEX_ROOT, "X-Plex-Token.id")) else Dict(os.environ, 'PLEXTOKEN')})))

pathsny commented 3 years ago

So I did some digging and found where the issue is.

This line matches the ep against the string - Complete Movie https://github.com/ZeroQI/Absolute-Series-Scanner/blob/21e57b0d957b4fa29acbee1418c878411762db15/Scanners/Series/Absolute%20Series%20Scanner.py#L992

However, the call to clean_string here https://github.com/ZeroQI/Absolute-Series-Scanner/blob/21e57b0d957b4fa29acbee1418c878411762db15/Scanners/Series/Absolute%20Series%20Scanner.py#L986 has the prefix and the leading dash. So the string ep is now Complete Movie and not - Complete Movie

When the special file is removed from the folder, the reason the match is correct is because of the next rule here https://github.com/ZeroQI/Absolute-Series-Scanner/blob/21e57b0d957b4fa29acbee1418c878411762db15/Scanners/Series/Absolute%20Series%20Scanner.py#L993 which applies in situations where there is only one file in the folder.

If I were to change the check to match against Complete Movie instead of - Complete Movie the file is recognized correctly. Do you think it's reasonable to make this change?

ZeroQI commented 3 years ago

We could test lines 992-994 after line 981, but ultimately, this change is the easiest and still scrub the filename Thanks for the detective work, couldn't see where it was going wrong