Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue - mediamanager.py 'unwatched' not working as expected #392

Open
wales opened this issue Aug 16, 2023 · 2 comments
Open

Issue - mediamanager.py 'unwatched' not working as expected #392

wales opened this issue Aug 16, 2023 · 2 comments

Comments

@wales
Copy link

wales commented Aug 16, 2023

Describe the bug

media_manager.py behaving inconsistently when using the unwatched flag.

Initially, running against Film library appeared to work, e.g running..

python3 media_manager.py --libraries Films --select unwatched --date 30 --action show

..would list an output, however running it against TV would report no Series to remove, despite there being entries in Tautilli

And now, bizarrely, running the command against either Films or TV produces nothing to remove:

python3 media_manager.py --libraries Films --select unwatched --date 30 --action show
Checking library: 'Films' watch statuses...
0 item(s) have been found.

Screenshot of items in Films:

image

Using the lastPlayed flag works as intended, but obviously doesn't pick up the unwatched items.

@blacktwin
Copy link
Owner

I'm not able to reproduce any issue with Shows or Movies 🤷. You might need to walk through the code to see where the error is happening. Set some debug points where the is filtering through the library.

@dama-de
Copy link

dama-de commented Jan 21, 2024

There is a problem that the unwatched_work function aborts as soon as one page had no unwatched items. To prevent that, I pulled the filtering out of get_library_media_info like this:

diff --git a/utility/media_manager.py b/utility/media_manager.py
--- a/utility/media_manager.py	(revision e097a07ca55bbb9f60d726f550dfa3ac2358ba56)
+++ b/utility/media_manager.py	(date 1705844138305)
@@ -384,16 +384,16 @@
     while True:
     
         # Getting all watched history for userFrom
-        tt_history = tautulli_server.get_library_media_info(section_id=sectionID,
-                                                     start=start, length=count, unwatched=True, date=date)
+        tt_history = tautulli_server.get_library_media_info(section_id=sectionID, start=start, length=count)
     
         if all([tt_history]):
             start += count
             for item in tt_history:
-                _meta = tautulli_server.get_metadata(item['rating_key'])
-                if _meta:  # rating_key that no longer exists on the Plex server will return blank metadata
-                    metadata = Metadata(_meta)
-                    unwatched_lst.append(metadata)
+                if item['play_count'] is None and float(item['added_at']) < date: 
+                    _meta = tautulli_server.get_metadata(item['rating_key'])
+                    if _meta:  # rating_key that no longer exists on the Plex server will return blank metadata
+                        metadata = Metadata(_meta)
+                        unwatched_lst.append(metadata)
             continue
         elif not all([tt_history]):
             break

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants