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

[chore] Add Tautulli v2.15.0 support #54

Merged
merged 6 commits into from
Nov 25, 2024
Merged

[chore] Add Tautulli v2.15.0 support #54

merged 6 commits into from
Nov 25, 2024

Conversation

nwithan8
Copy link
Owner

@nwithan8 nwithan8 commented Nov 25, 2024

  • Add logo_level parameter for export_metadata
  • Add slug, parent_slug and grandparent_slug to Metadata model
  • Add Tautulli 2.15.0 to compatible API list
  • Drop Tautulli 2.14.0 and 2.14.1 support

Summary by CodeRabbit

  • New Features

    • Added support for a new API version "2.15.0."
    • Introduced a new logo_level parameter in the metadata export functionality, allowing users to specify the level of logo images to export.
    • Enhanced the MetadataModel with new properties for more detailed media categorization and URL generation for Plex content.
  • Bug Fixes

    • Updated method documentation to reflect changes in parameters.
  • Documentation

    • Improved docstrings for clarity on new parameters and functionality.

@nwithan8 nwithan8 changed the title [chore] Add logo_level parameter for export_metadata [chore] Add Tautulli v2.15.0 support Nov 25, 2024
Copy link

coderabbitai bot commented Nov 25, 2024

📝 Walkthrough
## Walkthrough
The pull request introduces several changes across multiple files. The `API_VERSIONS.json` file is updated to include a new API version "2.15.0." The `export_metadata` method in the `RawAPI` class is modified to accept an additional parameter, `logo_level`. The `DatumModel` class gains a new optional attribute `logo_level`. Additionally, the `MetadataModel` class is expanded with new attributes and properties, including a new `MarkerModel` class, enhancing the media categorization and URL generation capabilities.

## Changes

| File Path                         | Change Summary                                                                                                                                                                                                                   |
|-----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| tautulli/API_VERSIONS.json        | - Added new version: `"2.15.0"` <br> - Removed versions: `"2.14.0-beta"`, `"2.14.0"`, `"2.14.1-beta"`, `"2.14.1"` <br> - Retained version: `"2.14.6"`                                                                             |
| tautulli/api/json_api.py          | - Updated method signature of `export_metadata` in `RawAPI` to include `logo_level: int = 0`. <br> - Adjusted `params` dictionary to include `logo_level`.                                                                 |
| tautulli/models/exports_table.py   | - Added new optional attribute: `logo_level: Optional[int] = None` in `DatumModel`.                                                                                                                                           |
| tautulli/models/metadata.py       | - Added new class: `MarkerModel` with optional attributes. <br> - Expanded `MetadataModel` with new optional attributes: `slug`, `parent_slug`, `grandparent_slug`. <br> - Added multiple properties for media type categorization. <br> - Added properties for URL generation. |

## Possibly related PRs
- #53: The changes in this PR also involve an update to the `tautulli/API_VERSIONS.json` file, specifically adding the version "2.14.6", which is directly related to the versioning updates in the main PR that added "2.15.0".

Warning

Rate limit exceeded

@nwithan8 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 27 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 4adff6f and b382081.


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>, please review it.
    • Generate unit testing code 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
tautulli/models/metadata.py (2)

Line range hint 86-94: Consider adding validation rules for time offsets

The MarkerModel looks good, but consider adding validation rules to ensure:

  • start_time_offset is non-negative
  • end_time_offset is greater than start_time_offset
 class MarkerModel(BaseModel):
     id: Optional[int] = None
     type: Optional[str] = None
-    start_time_offset: Optional[int] = None
-    end_time_offset: Optional[int] = None
+    start_time_offset: Optional[conint(ge=0)] = None  # type: ignore
+    end_time_offset: Optional[conint(ge=0)] = None  # type: ignore
     first: Optional[bool] = None
     final: Optional[bool] = None
+
+    @validator('end_time_offset')
+    def end_time_must_be_after_start(cls, v, values):
+        if v is not None and values.get('start_time_offset') is not None:
+            if v <= values['start_time_offset']:
+                raise ValueError('end_time_offset must be greater than start_time_offset')
+        return v

151-153: Add validation for slug format

The new slug fields should follow a consistent format. Consider adding validation to ensure slugs follow URL-safe patterns.

+from pydantic import constr

 class MetadataModel(BaseModel):
-    slug: Optional[str] = None
-    parent_slug: Optional[str] = None
-    grandparent_slug: Optional[str] = None
+    slug: Optional[constr(regex=r'^[a-z0-9-]+$')] = None  # type: ignore
+    parent_slug: Optional[constr(regex=r'^[a-z0-9-]+$')] = None  # type: ignore
+    grandparent_slug: Optional[constr(regex=r'^[a-z0-9-]+$')] = None  # type: ignore
tautulli/api/json_api.py (1)

Update object_api.py to maintain API consistency

The verification revealed that object_api.py also implements the export_metadata method but lacks the new logo_level parameter. This needs to be synchronized with json_api.py to maintain API consistency across both implementations.

  • tautulli/api/object_api.py: Add the logo_level parameter with default value of 0 to match the implementation in json_api.py
🔗 Analysis chain

Line range hint 641-686: Verify existing usage of export_metadata

While the changes look good and maintain backward compatibility due to the default value, let's verify any existing usage of this method in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for existing calls to export_metadata to ensure they won't be affected

# Search for direct method calls
echo "Checking for direct method calls to export_metadata:"
rg "export_metadata\(" --type python

# Search for method references
echo "Checking for method references:"
rg "export_metadata" --type python

Length of output: 323


Script:

#!/bin/bash
# Search for direct method calls without file type restriction
echo "Checking for direct method calls to export_metadata:"
rg "export_metadata\("

# Search for method references
echo "Checking for method references:"
rg "export_metadata"

Length of output: 1073


Script:

#!/bin/bash
# Check the test files to see how export_metadata is being used
echo "Content of test_json_api.py test:"
rg -A 10 "test_export_metadata" tests/test_json_api.py

echo "Content of test_object_api.py test:"
rg -A 10 "test_export_metadata" tests/test_object_api.py

# Check the object_api implementation to compare parameters
echo "Content of object_api.py export_metadata method signature:"
rg -A 5 "def export_metadata" tautulli/api/object_api.py

Length of output: 1333

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4369f30 and 516e420.

📒 Files selected for processing (4)
  • tautulli/API_VERSIONS.json (1 hunks)
  • tautulli/api/json_api.py (3 hunks)
  • tautulli/models/exports_table.py (1 hunks)
  • tautulli/models/metadata.py (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tautulli/API_VERSIONS.json
🔇 Additional comments (5)
tautulli/models/exports_table.py (1)

24-24: LGTM! The new field follows the established pattern.

The addition of logo_level as an optional integer field aligns well with the existing level parameters like art_level, thumb_level, and metadata_level.

Let's verify the schema generation setup:

✅ Verification successful

The logo_level field is properly integrated and used consistently

The verification shows that:

  • The field is correctly added to the exports table model
  • It's properly used in the API implementation (json_api.py) with matching type hints and documentation
  • The parameter is correctly passed through to the export functionality
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for schema generation configuration and related files
# Expected: Find the source JSON schema and generation config

# Look for datamodel-codegen configuration
fd -t f "datamodel.*\.toml|pyproject\.toml"

# Find the source JSON schema file
fd "data\.json" -t f

# Check if there are other generated model files that might need the same update
fd ".*_table\.py$" -t f

Length of output: 265


Script:

#!/bin/bash
# Let's check if logo_level is consistently used across table models
# and look for any schema/generation files in the root directories

# Check for logo_level usage in other table models
rg "logo_level" --type py

# Look for schema files in common locations
fd -t f "schema.*\.json"

# Check root level directories for any generation related files
ls -la

Length of output: 1809

tautulli/models/metadata.py (1)

155-185: LGTM! Well-structured media type properties

The media type properties are well-implemented with clear, consistent checks.

tautulli/api/json_api.py (3)

641-641: LGTM: Parameter addition follows existing pattern

The addition of the logo_level parameter with a default value of 0 follows the existing pattern of optional parameters in the method signature.


667-668: LGTM: Well-documented parameter

The docstring for the new parameter clearly describes its purpose and type, maintaining consistency with the existing documentation style.


686-686: LGTM: Proper parameter handling

The logo_level parameter is correctly added to the optional parameters dictionary using the existing build_optional_params helper function.

tautulli/models/metadata.py Outdated Show resolved Hide resolved
Copy link

@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.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
tautulli/models/metadata.py (2)

Line range hint 86-93: Consider adding validation rules for time offsets

The MarkerModel looks good, but consider adding validation to ensure:

  • start_time_offset is non-negative
  • end_time_offset is greater than start_time_offset
class MarkerModel(BaseModel):
    id: Optional[int] = None
    type: Optional[str] = None
-   start_time_offset: Optional[int] = None
-   end_time_offset: Optional[int] = None
+   start_time_offset: Optional[conint(ge=0)] = None  # type: ignore
+   end_time_offset: Optional[conint(ge=0)] = None    # type: ignore
    first: Optional[bool] = None
    final: Optional[bool] = None
+
+   @validator('end_time_offset')
+   def end_time_must_be_after_start(cls, v, values):
+       if v is not None and values.get('start_time_offset') is not None:
+           if v <= values['start_time_offset']:
+               raise ValueError('end_time_offset must be greater than start_time_offset')
+       return v

155-185: Use an enum for media types

Consider using an enum for media_type to ensure type safety and prevent typos. This would also make it easier to maintain the list of valid media types.

+from enum import Enum
+
+class MediaType(str, Enum):
+    MOVIE = "movie"
+    SHOW = "show"
+    SEASON = "season"
+    EPISODE = "episode"
+    ARTIST = "artist"
+    ALBUM = "album"
+    TRACK = "track"
+    CLIP = "clip"

class MetadataModel(BaseModel):
-    media_type: Optional[str] = None
+    media_type: Optional[MediaType] = None

    @property
    def is_movie(self) -> bool:
-        return self.media_type == "movie"
+        return self.media_type == MediaType.MOVIE

    # Update other properties similarly
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4adff6f and b382081.

📒 Files selected for processing (2)
  • tautulli/api/object_api.py (2 hunks)
  • tautulli/models/metadata.py (3 hunks)
🔇 Additional comments (1)
tautulli/api/object_api.py (1)

452-452: LGTM! The logo_level parameter is well-implemented.

The addition of the logo_level parameter is consistent with the existing level parameters and properly documented.

Also applies to: 478-479

tautulli/models/metadata.py Show resolved Hide resolved
tautulli/models/metadata.py Show resolved Hide resolved
@nwithan8 nwithan8 merged commit ef990cb into master Nov 25, 2024
32 of 38 checks passed
@nwithan8 nwithan8 deleted the 2.15.0_compat branch November 25, 2024 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant