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

Emby notification : upgrade library_update to latests api endpoints #8736

Merged
merged 5 commits into from
Mar 18, 2024

Conversation

kyuuk
Copy link
Contributor

@kyuuk kyuuk commented Mar 11, 2024

use endpoint /media/updated with path param to refresh only needed show instead of full library scan

path is found by calling /items endpoint with indexerid (tvdbid in this case) and limiting results to only Series
if we don't have exactly one result we fallback to a full library scan, this might happen for a new show added to SC but still not known to Emby for example

  • PR is based on the DEVELOP branch
  • Don't send big changes all at once. Split up big PRs into multiple smaller PRs that are easier to manage and review
  • Read contribution guide

Summary by CodeRabbit

  • New Features
    • Enhanced Emby integration to support show-specific updates in the library.

Copy link
Contributor

coderabbitai bot commented Mar 11, 2024

Walkthrough

This update introduces a method to fetch the path of a show within the Emby library, enhancing the update_library function. Now, the library can be updated for specific shows, making the synchronization process between SickChill and Emby more efficient and targeted.

Changes

File Summary
.../notifiers/emby.py Added _get_show_path method; Modified update_library for show-specific updates.

🐇✨
In the digital fields where the data hops,
A clever rabbit tweaks and optimizes non-stops.
With a hop, skip, and a jump, updates are clear,
Emby's library syncs, bringing your shows near.
So here's to the code, may it run swift and bright,
Under the moon's soft glow and the stars' gentle light.
🌟📺

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 89a3f14 and 88f54a9.
Files selected for processing (1)
  • sickchill/oldbeard/notifiers/emby.py (2 hunks)
Additional comments: 1
sickchill/oldbeard/notifiers/emby.py (1)
  • 81-93: The modifications to the update_library method to support show-specific updates or fallback to a full library scan based on the show's path are well-implemented. However, there are a couple of points to consider:
  1. Error Handling: Similar to the _get_show_path method, consider catching more specific exceptions related to HTTP requests to avoid masking unrelated issues.
  2. Logging and Debugging: The method logs the HTTP status and response content in case of a successful update. This is good for debugging purposes. However, consider adding more detailed logging in case of an exception to help diagnose issues more effectively.

Overall, the changes align with the PR objectives and should enhance the efficiency of the Emby notification system by avoiding unnecessary full library scans.

sickchill/oldbeard/notifiers/emby.py Outdated Show resolved Hide resolved
@kyuuk kyuuk force-pushed the feature/emby_refresh_rework branch from 88f54a9 to 359d7a6 Compare March 12, 2024 00:12
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 89a3f14 and 359d7a6.
Files selected for processing (1)
  • sickchill/oldbeard/notifiers/emby.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • sickchill/oldbeard/notifiers/emby.py

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 359d7a6 and 0768a27.
Files selected for processing (1)
  • sickchill/oldbeard/notifiers/emby.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • sickchill/oldbeard/notifiers/emby.py

@BKSteve
Copy link
Collaborator

BKSteve commented Mar 12, 2024

Propose a different solution without getting folder from Emby and using show.location this simplifies code as path is already known so don't need to look for it.
Also change to line 58 for the json parameters to match that of swagger and it now triggers the folder update.

SC log string.

2024-03-12 17:00:57 DEBUG :: POSTPROCESSOR-AUTO :: EMBY: HTTP status: 204, b'', params {'Updates': [{'Path': '/home/Videos/Resident Alien'}]}

Emby log

2024-03-12 17:00:57.436 Info Server: http/1.1 Response 204 to ‌‍‍192.168.1.48‌. Time: 1ms. POST http://‌‍‍192.168.1.48‌:8096/emby/Library/Media/Updated
2024-03-12 17:01:57.436 Info LibraryMonitor: Resident Alien (/home/Videos/Resident Alien) will be refreshed.
2024-03-12 17:01:57.498 Info MediaProbeManager: ProcessRun 'ffprobe' Execute: /app/bin/ffprobe -i file:"/home/Videos/Resident Alien/Resident.Alien.S02E08.Alien.Dinner.Party.1080p.HDTV.x265.mkv" -threads 0 -v info -print_format json -show_streams -show_chapters -show_format -show_data
2024-03-12 17:01:57.510 Info MediaProbeManager: ProcessRun 'ffprobe' Process exited with code 0 - Succeeded

As you can see Emby uses ffprobe and logs new files.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0768a27 and c22b545.
Files selected for processing (1)
  • sickchill/oldbeard/notifiers/emby.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • sickchill/oldbeard/notifiers/emby.py

@BKSteve
Copy link
Collaborator

BKSteve commented Mar 12, 2024

part 2 simplification - still works.

2024-03-12 17:25:56 DEBUG :: POSTPROCESSOR-AUTO :: EMBY: HTTP status: 204, b'', params {'Updates': [{'Path': '/home/Videos/Resident Alien', 'UpdateType': 'Created'}]}
2024-03-12 17:25:56.879 Info Server: http/1.1 POST http://‌‍‍192.168.1.48‌:8096/emby/Library/Media/Updated. UserAgent: python-requests/2.31.0
2024-03-12 17:25:56.880 Info Server: http/1.1 Response 204 to ‌‍‍192.168.1.48‌. Time: 1ms. POST http://‌‍‍192.168.1.48‌:8096/emby/Library/Media/Updated
2024-03-12 17:26:56.879 Info LibraryMonitor: Resident Alien (/home/Videos/Resident Alien) will be refreshed.
2024-03-12 17:26:56.941 Info MediaProbeManager: ProcessRun 'ffprobe' Execute: /app/bin/ffprobe -i file:"/home/Videos/Resident Alien/Resident.Alien.S02E09.Autopsy.1080p.HDTV.x265.mkv" -threads 0 -v info -print_format json -show_streams -show_chapters -show_format -show_data
2024-03-12 17:26:56.954 Info MediaProbeManager: ProcessRun 'ffprobe' Process exited with code 0 - Succeeded

@kyuuk
Copy link
Contributor Author

kyuuk commented Mar 12, 2024

@BKSteve that works only if the path is the same for SC and emby, in my case for example SC is in a docker image so it won't work

we need things to work in all cases , for example if SC is on windows and Emby on a linux how will this work ?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c22b545 and 7aa09ec.
Files selected for processing (1)
  • sickchill/oldbeard/notifiers/emby.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • sickchill/oldbeard/notifiers/emby.py

@BKSteve
Copy link
Collaborator

BKSteve commented Mar 12, 2024

we need things to work in all cases , for example if SC is on windows and Emby on a linux how will this work ?

acknowledged.

@kyuuk kyuuk assigned kyuuk and miigotu and unassigned kyuuk Mar 12, 2024
@kyuuk kyuuk force-pushed the feature/emby_refresh_rework branch from 7aa09ec to d988bdf Compare March 12, 2024 20:35
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9ef2dca and d988bdf.
Files selected for processing (1)
  • sickchill/oldbeard/notifiers/emby.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • sickchill/oldbeard/notifiers/emby.py

@miigotu
Copy link
Contributor

miigotu commented Mar 18, 2024

Propose a different solution without getting folder from Emby and using show.location this simplifies code as path is already known so don't need to look for it. Also change to line 58 for the json parameters to match that of swagger and it now triggers the folder update.

SC log string.

2024-03-12 17:00:57 DEBUG :: POSTPROCESSOR-AUTO :: EMBY: HTTP status: 204, b'', params {'Updates': [{'Path': '/home/Videos/Resident Alien'}]}

Emby log

2024-03-12 17:00:57.436 Info Server: http/1.1 Response 204 to ‌‍‍192.168.1.48‌. Time: 1ms. POST http://‌‍‍192.168.1.48‌:8096/emby/Library/Media/Updated
2024-03-12 17:01:57.436 Info LibraryMonitor: Resident Alien (/home/Videos/Resident Alien) will be refreshed.
2024-03-12 17:01:57.498 Info MediaProbeManager: ProcessRun 'ffprobe' Execute: /app/bin/ffprobe -i file:"/home/Videos/Resident Alien/Resident.Alien.S02E08.Alien.Dinner.Party.1080p.HDTV.x265.mkv" -threads 0 -v info -print_format json -show_streams -show_chapters -show_format -show_data
2024-03-12 17:01:57.510 Info MediaProbeManager: ProcessRun 'ffprobe' Process exited with code 0 - Succeeded

As you can see Emby uses ffprobe and logs new files.

Using our location won't be universal, as the emby server might be on a different location than SC. For emby the mount could be different, we could be using a UNC path or share in SC or emby and not the other, the name of the mount could be different, etc.

@miigotu miigotu merged commit 3e2dcc3 into develop Mar 18, 2024
11 checks passed
@miigotu miigotu deleted the feature/emby_refresh_rework branch March 18, 2024 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants