terrelsa13 / MUMC

Multi-User Media Cleaner aka MUMC (pronounced Mew-Mick) will go through movies, tv episodes, audio tracks, and audiobooks in your Emby/Jellyfin libraries deleting media items you no longer want.
GNU General Public License v3.0
92 stars 6 forks source link

Blacktag ignores minimum_number_episodes and not scanning older seasons. #29

Closed trinsic closed 2 years ago

trinsic commented 2 years ago

I have my config set to delete blacktagged watched items and everything else remain whitelisted.

Played age is 1, Libraries are whitelisted, select shows are blacktagged and minimum_number_episodes is set to 5 however during a dry run it still wants to delete S02E01 with the latest episode being S02E03

Secondly it doesn't want to delete anything from Season 1 that are marked as watched.

TVShow --> Season 1 --> E01 Watched E02 Watched E03 Watched E04 Watched E05 Watched E06 Watched Season 2 --> E01 Watched E02 Unwatched E03 Unwatched

Output:

:*[DELETE] - Episode - X - s02.e01 - X - Hulu - Played 6 days ago - Created 8 days ago - Favorite: False - WhiteTag: False - BlackTag: True - Whitelisted: True - EpisodeID: 68b5eaabc054bf87657dd57fe92e6402

terrelsa13 commented 2 years ago

Original

Hey @trinsic

Output: :*[DELETE] - Episode - X - s02.e01 - X - Hulu - Played 6 days ago - Created 8 days ago - Favorite: False - WhiteTag: False - BlackTag: True - Whitelisted: True - EpisodeID: 68b5eaabc054bf87657dd57fe92e6402

This appears to be the output for a specific user at the time of processing the episodes and not the summary of deleted media at the end.

The script has to first collect all of the episode data. During that time the output is printed to the screen that best matches the anticipated action (keep or delete). After all of the data from each user is collected, minimum_number_episodes=5 is processed.

Using your example above; the script should keep s02.e03, s02.e02, s02.e01, s01.e06, and s01.e05. But delete s01.e01, s01.e02, s01.e03, and s01.e04. In the summary of deleted media showing at the end s01.e01, s01.e02, s01.e03, and s01.e04 should be the only episodes for this show that are deleted. (Assuming no other configuration option are set that may result in keeping these episodes.)

Please upload the entire output of the script to a pastebin and send the link. Please do the same with your configuration file as well.

Edit

I have recreated this scenario for both v2 and v3. It worked correctly on my setup.

The "live output" is a best guess. But nothing is deleted until the very end; after post processing is completed and right before printing each line in the Summary Of Deleted Media.

If this is still not working for you there may be some other option(s) you have set that I will need to see a copy of your configuration file in order to fix the issue.

trinsic commented 2 years ago

Hey terrelsa13 thanks! I didn't consider the minimum_number_episodes to run after the output of a dry run. I set remove_files to true and the script still didn't work as expected. After turning on debug I found it crashing on comparing libid for the whitelisted library.

Comparing the below two items
'blacktag':''
Comparing the below two items
'a656b907eb3a73532e40e44b968d0225':'a656b907eb3a73532e40e44b968d0225'
Traceback (most recent call last):
  File "/opt/MUMC/media_cleaner.py", line 6487, in <module>
    deleteItems=get_media_items()
  File "/opt/MUMC/media_cleaner.py", line 4134, in get_media_items
    itemIsWhiteListed_Local,itemIsWhiteListed_Remote=get_isItemWhitelisted(LibraryID_WhtLst,LibraryNetPath_WhtLst,LibraryPath_WhtLst,currentPosition,
  File "/opt/MUMC/media_cleaner.py", line 2030, in get_isItemWhitelisted
    print('Item is whitelisted for this user: ' + itemIsWhiteListed_Local)
TypeError: can only concatenate str (not "bool") to str

a656b907eb3a73532e40e44b968d0225 is the libid for whitelisted tvshows library using blacktags. I tried changing library_matching_behavior to byPath but it throws the same error.

Here is the script output: https://pastebin.com/UKWKW1G6

And my config: https://pastebin.com/VGSbd7sP

terrelsa13 commented 2 years ago

Yep. Looks like I didn't convert the boolean into a string. So it is throwing an error when debug line #2030 of is run. With DEBUG=False the line would never run and there is no error thrown. Either way, I have fixed this with v2.1.7. Update to this version and make the change I mention below.

I think I found the other option that is causing this not to work for you. Try setting multiuser_whitelist_episode=0. This should tell the script it is ok to delete an item in the whitelist.

When there are multiple users being monitored this option is used to allow controlling if an item will be deleted even if another user has the library whitelisted. When only a single user is being monitored it basically ignores the post processing that happens to check if the item is whitelisted for another user. Setting it to zero should fix your issue.

Let me know if it does not.

trinsic commented 2 years ago

Script running and deleting content now! This will be a great little timesaver for me so thanks a lot.

Not important but some of my older content is returning funny dates (Played 19182 days ago, Created 16 days ago) and this was stopping it from deleting older seasons. I moved to Jellyfin recently and marked my older content as played via the Trakt plugin.

To fix it I had to set the older content as unplayed and played again to get Jellyfin to reset the played date and have it deleted.

terrelsa13 commented 2 years ago

Glad the script is working for you now! FYI - If MUMCv2 is working for you, there is no reason to update until you want/need to. But, MUMCv3 will be released in the next few weeks (this is the link to the beta branch). When that happens I will stop troubleshooting issues with v2 and require updating to v3.

Yeah I have seen this before on my setup. It appears there are times Emby/Jellyfin are unable to determine played or created dates for some media items. The default must be to set it to the beginning of epoch time (1970 January 01st 00:00:00hrs) when that happens. The script is using the date provided by Emby/Jellyfin, for each media item, to determine the number of days to show.