bearlikelion / popularplex

Generate dynamic collections of popular media for Plex using Tautulli
15 stars 2 forks source link

Multiple Movie/Show Libraries #5

Closed meisnate12 closed 4 years ago

meisnate12 commented 4 years ago

So I have a separate library for TV Shows vs Anime but Tautulli puts both of these together for Top/Popular Shows. Is there any way to specify which library you're using when you call the Tautulli API?

Looking at the API command you're using there isn't an option for specifying a library, so I realize you probably have no control over this I was just hoping you maybe had an insight I didn't.

I've thought of two workarounds

  1. Just increase the order above what the user wants and only add as many movies as they specify. (There's a lot of ways this could go wrong so I don't know that I would do this.)
  2. The only other way I can think of is to use the Tautulli API command sql, but that has to be specially enabled in Tautulli's config and I have no idea what the Tables or Fields in their database would be (This might be just a google search away but I've done zero research on Tautulli SQL structure).
bearlikelion commented 4 years ago

I cannot specify a library for the Tautulli API lookup, but when fetching TV items there is _show.librarySectionID which can be compared to only add items for the specified libraries in the config.ini. This would require another API call looking up library names -> id (I already do this in clear_collections()) and eliminate any Anime TV Shows from appearing in the 'Popular TV Shows' collection. It would result in less items in the collection overall (ex. 10 items on Tautulli 4 of which are anime = 6 tv shows total).

Additionally we could also add support for an optional Anime category to create dynamic collections based on a 3rd category name/id.

meisnate12 commented 4 years ago

thats why i suggested in option 2 asking for more movies/shows then you actually need and just adding up to the right amount. So if the count is 10 then say we have a buffer option that is also 10 well then the program could grab 20 movies but only add 10 to the list

bearlikelion commented 4 years ago

While I like this idea, there's no Tautulli API to lookup media play counts, I haven't looked into their SQL DB to see if they store plays.

How many results do you get returned for popular TV?

Example: http://plexpy/api/v2?apikey=APIKEY&cmd=get_home_stats&time_range=7

meisnate12 commented 4 years ago

just do this to specify how many you want to be returned http://plexpy/api/v2?apikey=APIKEY&cmd=get_home_stats&time_range=7&count=NUMBER_TO_RETURN so if the user wants a 10 movie list but has multiple libraries they can set a "buffer" of lets say 10 and then you add them together and throw 20 in as NUMBER_TO_RETURN and then check each one while adding to the library to make sure its in the right section and only add up to their original desired amount in this case 10

bearlikelion commented 4 years ago

I have made a change to the master branch which should solve some of these issues.

You can configure the stat_count for the API request in the config file to a number (say 20). It will now only add media if the library matches the library IDs configured in the config.ini, so it should exclude your anime from the TV Shows collection.

Test the functionality and let me know what you think, we could also add a 'Limit' config option to stop adding to collections if there's 10 items already since currently it will add all 20 items from Movies to the Movies collection.

bearlikelion commented 4 years ago

I have added the functionality to limit the number of items in a collection Config.ini example

bearlikelion commented 4 years ago

I am assuming this issue has been resolved with the latest changes, if it still occurs please open a new issue.

meisnate12 commented 4 years ago

Yea that's fine seems like the best option for now unless the api changes to allow for specific section tops