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

[Enhancement] Retrieve updated episodes the same way as added episodes. #77

Open
buthed010203 opened this issue Apr 14, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@buthed010203
Copy link
Contributor

buthed010203 commented Apr 14, 2023

Rebuilding the entire library cache every time an episode is updated is slow, I looked into it and it appears that updated episodes can be fetched the same way as added episodes by changing the addedAt to updatedAt here:

recent = section.searchEpisodes(sort="addedAt:desc", filters={"addedAt>>": f"{minutes}m"})

Not sure if you knew this was possible, it seems to work fine but I haven't done any real testing.

Not sure what else the cache is actually used for but it seems that it is pretty much useless now? Would be worth removing to save some small amount of memory.

The newly_added and newly_updated lists could also be made irrelevant by caching the time of the latest added/updated item and only processing items added/updated after then.

@RemiRigal
Copy link
Owner

Thank you for the suggestion @buthed010203, during early development I came to the same conclusion but the reason why the updatedAt timestamp isn't used is that it's only relevant for changes to the episode object itself (title, poster, date... etc). If you add/remove/update the files of an episode (when upgrading quality for example) the updatedAt timestamp will not be changed.

As far as I know, the only way to catch those changes (and therefore be able to tell if the available streams have been updated for an episode) is to scan the whole library. For larger libraries, you can set the refresh_library_on_scan setting to false in order to prevent the complete scan from being called every time.

@buthed010203
Copy link
Contributor Author

Ah I see, was aware of the setting but would rather keep it on. Perhaps having a thread just for library updates would help make this less of an issue

@RemiRigal
Copy link
Owner

The scans are already done in a separate thread but if other events occur, they are being queued during the scan and waiting for it to finish. As you suggested, all the library updates could happen in a dedicate thread instead. The only drawback I see with this approach is the fact that the scans sometimes lead to timeout errors due to the large amount of network traffic generated by the library update.

@buthed010203
Copy link
Contributor Author

buthed010203 commented Apr 23, 2023 via email

@RemiRigal RemiRigal added the enhancement New feature or request label Apr 23, 2023
@buthed010203
Copy link
Contributor Author

buthed010203 commented May 3, 2023

@RemiRigal This could actually be mitigated if autoscan support (plexautolanguages as an autoscan target, would require implementation on autoscan's side as well) was implemented as you would only need to fetch the relevant episode in that case. I'm sure a lot of people with large libraries already use autoscan so they wouldn't need to swap over to it to gain the benefits. What are your thoughts on this?

On another note, it would make sense to only refresh the cache for the relevant tv show library instead of fetching it all again though I don't know how to access the librarySectionID context attribute to be able to tell what library was just scanned Perhaps we could store the libraries that are currently queued by parsing the message sent when a scan starts? Seems pretty hacky though.

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

No branches or pull requests

2 participants