-
Notifications
You must be signed in to change notification settings - Fork 58
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
Enhance post-webhook metadata handling #33
Conversation
Added metadata refresh capability immediately after subtitle generation when handling Plex webhooks. If subtitle generation is successful, the Plex item's metadata is attempted to be refreshed to ensure that the updates are reflected. The change includes robust error handling to log failures in refreshing metadata and alerts the user if the webhook is misconfigured. This enhancement improves the overall user experience by ensuring the media library is up-to-date after any subtitle changes.
Neat idea. I've never run into the problem though. I have "Update my library automatically" (See: https://support.plex.tv/articles/200289306-scanning-vs-refreshing-a-library/) enabled in Plex. Any directory file changes on my system seem to get updated near immediately. item_id isn't defined anywhere. Did you mean to use You would potentially have to drop it at https://github.com/McCloudS/subgen/blob/113e0a203c41c2603626a63447b278cfbc492442/subgen/subgen.py#L303C18-L303C18 but gen_subtitles doesn't track which webhook it came from. |
sorry about the item_id, my internet sucks atm so i didn´t really test this. |
Adjusted indentation in the webhook receiver to correctly fall back to a warning message when receiving a misconfigured webhook. Also, updated metadata refresh function to construct the request URL dynamically, allowing for more robust handling of server addresses, including those served over HTTPS. These changes ensure better user feedback and improve compatibility with secure Plex server configurations.
it appears to work, and the separate threading you mentioned doesn't seem to be an issue
feel free to let me know if you don't like something about it. |
Looks good, thanks for the effort! I also modified it to add the refresh for Jellyfin. (Untested, as I don't have my Jellyfin running right now, but the end point is right per: https://api.jellyfin.org/openapi/jellyfin-openapi-stable.json) |
tried adding a simple function to update the metadata on titles once the subtitles are generated.
Enhanced Post-subtitle Generation Workflow:
After subtitles are generated (when the
gen_subtitles
function is called), there is now an additional step to refresh the metadata of the corresponding Plex library item. This ensures that any updates related to subtitles are immediately reflected in the Plex media library.Error Handling for Metadata Refresh:
A
try-except
block has been added to catch and log any exceptions that occur during the metadata refresh process. This robust error handling is critical because it provides clear feedback in the event of a failure, ensuring that the user is informed about issues with refreshing metadata. The log message specifies theitem_id
affected and includes the error message for easier troubleshooting.New Function
refresh_plex_metadata
:A dedicated function has been added to encapsulate the logic for refreshing metadata. Its purpose is to send a PUT request to the Plex API for a specific item in order to trigger a metadata refresh. The function includes error handling to raise an exception if the refresh is not initiated successfully, which would be caught by the aforementioned error handling in the webhook processing block.
Handling Misconfigured Webhooks:
The message for misconfigured Plex webhooks has been shifted. This message now appears in the
else
block of thetry-except
statement, which informs the user if the webhook configuration isn't proper. While this might seem like a minor change, it ensures that the message is clearly associated with webhook configuration errors and not with other operations such as subtitle generation or metadata refreshing.You can ignore this one if you feel like it changes too much of the original functionality but the other one about the dockerfile im pretty confident was an issue.
feel free to hit me up on discord "rikiar" if you want to discuss this i really like having this as a backup for my subtitles, so i'd gladly for a bit on it.