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

Optimize Top 5 Movies #147

Open
DevMan01 opened this issue Sep 8, 2022 · 7 comments
Open

Optimize Top 5 Movies #147

DevMan01 opened this issue Sep 8, 2022 · 7 comments
Labels
1. Script request Request for new script 2. Level: Medium The request is of normal difficulty 3. Request accepted Request is accepted and will be realised

Comments

@DevMan01
Copy link

DevMan01 commented Sep 8, 2022

Hey there, I need help with a script that does the following:

  • Automatically optimize the top 5movies. I'd like this to be a rolling list, so, as something becomes the top 5, Plex will automatically queue that movie for optimization. Then likewise, if something falls off the top 5, the optimized version will be deleted.

  • I do use Plex Meta Manager, as well as Tautulli. So, its could be easy for me to use Plex Meta Manager to create a collection of the top 5 movies, using analytics from Tautulli.

  • A Python, or .sh framework would work.

@DevMan01 DevMan01 added the 1. Script request Request for new script label Sep 8, 2022
@Casvt Casvt added 3. Request accepted Request is accepted and will be realised 2. Level: Medium The request is of normal difficulty labels Sep 8, 2022
@splitsec2
Copy link

A slight variation on this would be to have the option to optimize things in the watchlist. Which in theory are likely to be watched,

@DevMan01
Copy link
Author

I like that. Perhaps the best solution would be to parameratize the script in such a way that it could receive any playlist, watchlist or collection, and optimize as needed.

I’ve also been wondering / brainstorming how the script could keep track of changes in the list/collection. That way when an item leaves the list, it will delete the optimized version.

@Casvt
Copy link
Owner

Casvt commented Sep 11, 2022

I’ve also been wondering / brainstorming how the script could keep track of changes in the list/collection. That way when an item leaves the list, it will delete the optimized version.

The script is constantly running in the background. It fetches the content of the list and compares it to the last time it fetched. Items that are in the list but aren't in the previous list are newly added and will be triggered to be optimized. Items that don't appear in the new list but do in the previous are removed and thus will have their optimized version removed.

@DevMan01
Copy link
Author

Agreed. The question in my mind is how we can do the diff between the two states (current versus previous). Do we write it in a state file of some kind? Perhaps a JSON list containing unique id’s per list? It is it all kept in memory?

@Casvt
Copy link
Owner

Casvt commented Sep 12, 2022

The script is constantly running, like a service. We store the previous fetch in a variable.

@splitsec2
Copy link

If there is no persistent storage what happens during a reboot? I guess the window is small for the race condition of the script grabbing the “current” and plex scanning the library and discovering a change or the user changing the watchlist

@Casvt
Copy link
Owner

Casvt commented Sep 12, 2022

The first time the script fetches, when there is no previous fetch available, the script goes through every media entry in the list and checks if it's already optimized.

From then on we don't have to do this everytime and can decide based on the current and previous fetch and the differences between them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. Script request Request for new script 2. Level: Medium The request is of normal difficulty 3. Request accepted Request is accepted and will be realised
Projects
None yet
Development

No branches or pull requests

3 participants