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

[Feature Request] Interesting interaction with hide_unflagged #4

Closed
4841penoyer opened this issue Oct 6, 2020 · 10 comments
Closed

Comments

@4841penoyer
Copy link

In upcoming-media-card when I set hide_unflagged to false the 5 most recent movies are displayed, when I set it to true nothing is displayed. I played so more with it and set the max to 15 then 2 movies showed up.

It looks like when it queries it grabs the first 5 (max) records and then selects the ones without flags.

I would like the behavior to be grab records until it finds the 5 (max) most recent un-flagged.

@boralyl
Copy link
Owner

boralyl commented Oct 6, 2020

I agree this behaviour is unexpected. This component just provides the data and doesn't handle displaying or limiting results. I would open an issue with the card here: https://github.com/custom-cards/upcoming-media-card/issues

@boralyl boralyl closed this as completed Oct 6, 2020
@4841penoyer
Copy link
Author

Actually I did open the case over there first, and they said it was on your end

custom-cards/upcoming-media-card#57

@boralyl
Copy link
Owner

boralyl commented Oct 6, 2020

Thanks for pointing this out, the issue there provides more context into what the actual problem is.

@boralyl boralyl reopened this Oct 6, 2020
@boralyl
Copy link
Owner

boralyl commented Oct 7, 2020

This was added in the latest release: https://github.com/boralyl/kodi-recently-added/releases/tag/v1.1.0

@pimp1310
Copy link

@boralyl

i know its not your work, but can you perhaps look over the custom-components/sensor.plex_recently_added#53 and add there the option to only show the unwatched?

@boralyl
Copy link
Owner

boralyl commented May 18, 2022

I don't have plex to test and assist with this. From the docs I don't see a watched attribute, but it appears there is a viewCount in the response that could indicate it was watched. It's just a counter from what I can tell so I don't think it will tell you if you've actually watched the entire movie or tv show, only how many times you've played it.

@pimp1310
Copy link

pimp1310 commented May 19, 2022

@boralyl

it gives the watched or unwatched flag in the recently added Plex Entitys, what is missing is the Option to sort the results from plex by this.

for example here are two movies from the sensor in >HA, one is watched, one is unwatched.
thats mean the script do the job, but its missing a option for only get the results that are unwatched.

flag: true
is unwachted

- airdate: '2022-05-17T18:56:22Z' aired: '2022-02-04' release: $day, $date $time flag: true title: Moonfall episode: '' runtime: 130 studio: Centropolis Entertainment genres: Action, Adventure rating: ★ 3.7 poster: >- /local/upcoming-media-card-images/plex/Plex_Recently_Added_Movies/p10335.jpg fanart: >- /local/upcoming-media-card-images/plex/Plex_Recently_Added_Movies/f10335.jpg

flag: false
is watched

- airdate: '2022-05-13T06:20:10Z' aired: '2022-04-22' release: $day, $date $time flag: false title: Die Gangster Gang episode: '' runtime: 100 studio: DreamWorks Animation genres: Animation, Adventure rating: ★ 8.7 poster: >- /local/upcoming-media-card-images/plex/Plex_Recently_Added_Movies/p10283.jpg fanart: >- /local/upcoming-media-card-images/plex/Plex_Recently_Added_Movies/f10283.jpg

i dont know what i must change in the script to only get the results with "flag: true"

@boralyl
Copy link
Owner

boralyl commented May 19, 2022

@pimp1310 Oh, I see what you mean. I had only read the title and not the full description. So the reason this works with kodi is kodi supports requesting watched/unwatched at the api level so it will do the filtering on it's side and return the exact number of results.

It looks like there isn't a way to filter these out in plex. So if you request 10 results, the filtering happens in the component which means if you have 5 watched and 5 unwatched, the component will end up showing only 5 results.

The component would have to request more than max results since the filtering is done in the component. It looks like it's already requesting double the max, so you could try just removing the list slicing here: https://github.com/custom-components/sensor.plex_recently_added/blob/master/custom_components/plex_recently_added/sensor.py#L274-L275 e.g.

self.api_json = sorted(self.api_json, key=lambda i: i['addedAt'],
                               reverse=True)

Obviously if your max is 10, and it fetches 20, but all of them are watched and you only want unwatched the card will end up showing 0 results since they are all watched. I only took a glance at this, so there might be a better way, but it's not quite as easy to do as what I did with the kodi component.

@pimp1310
Copy link

pimp1310 commented May 19, 2022

@boralyl

yeah the api doesnt have this function i think.
that is no problem for me, when no unwatched is there than its empty.

BUT perhaps i missunderstand you,

here is my code in the configuration,yaml for the sensor in HA, you see the MAX is definied.

  • platform: plex_recently_added
    name: Plex Recently Added Movies
    token: XXXXXXXXXXXXXXXX
    host: 192.168.0.53
    port: 32400
    section_types:
    - movie
    max: 30

when i remove the "[:self.max_items]" then he doesnt shows only the unwatched or missunderstand you?

@pimp1310
Copy link

@boralyl

okay i get it to work with a workaround

custom-components/sensor.plex_recently_added#53

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