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

fix: Add additional titles and indexes to item metadata #69

Merged
merged 5 commits into from
Nov 18, 2024

Conversation

dstaley
Copy link
Contributor

@dstaley dstaley commented Nov 17, 2024

This PR adds support for the grandparentTitle, parentTitle, originalTitle, index, and parentIndex item metadata fields. The example is from a non-hierarchical library, so adding example values wouldn't match the existing example data.

Example:

{
  "MediaContainer": {
    "size": 1,
    "allowSync": true,
    "identifier": "com.plexapp.plugins.library",
    "librarySectionID": 4,
    "librarySectionTitle": "Music",
    "librarySectionUUID": "3c088ca3-5a22-4ab0-a5f6-96172580433e",
    "mediaTagPrefix": "/system/bundle/media/flags/",
    "mediaTagVersion": 1730230381,
    "Metadata": [
      {
        "ratingKey": "3013",
        "key": "/library/metadata/3013",
        "parentRatingKey": "3008",
        "grandparentRatingKey": "3007",
        "guid": "plex://track/5d0802d7403c640290f88cb3",
        "parentGuid": "plex://album/5d07cbed403c640290e32974",
        "grandparentGuid": "plex://artist/5d07bcb4403c64029053da80",
        "parentStudio": "Atlantic",
        "type": "track",
        "title": "Screwed",
        "grandparentKey": "/library/metadata/3007",
        "parentKey": "/library/metadata/3008",
        "librarySectionTitle": "Music",
        "librarySectionID": 4,
        "librarySectionKey": "/library/sections/4",
+       "grandparentTitle": "Janelle Monáe",
+       "parentTitle": "Dirty Computer",
+       "originalTitle": "Janelle Monáe ft. Zoë Kravitz",
        "summary": "",
+       "index": 5,
+       "parentIndex": 1,
        "ratingCount": 8623,
        "viewCount": 33,
        "lastViewedAt": 1702820467,
        "parentYear": 2018,
        "thumb": "/library/metadata/3008/thumb/1717555188",
        "art": "/library/metadata/3007/art/1731300415",
        "parentThumb": "/library/metadata/3008/thumb/1717555188",
        "grandparentThumb": "/library/metadata/3007/thumb/1731300415",
        "grandparentArt": "/library/metadata/3007/art/1731300415",
        "duration": 302491,
        "addedAt": 1525097811,
        "updatedAt": 1731300416,
        "musicAnalysisVersion": "1",
        "Media": [
          {
            "id": 5019,
            "duration": 302491,
            "bitrate": 1650,
            "audioChannels": 2,
            "audioCodec": "flac",
            "container": "flac",
            "hasVoiceActivity": false,
            "Part": [
              {
                "accessible": true,
                "exists": true,
                "id": 8862,
                "key": "/library/parts/8862/1641607904/file.flac",
                "duration": 302491,
                "file": "/media/Music/Janelle Monáe/Dirty Computer/05. Screwed.flac",
                "size": 62930454,
                "container": "flac",
                "hasThumbnail": "1",
                "Stream": [
                  {
                    "id": 17528,
                    "streamType": 2,
                    "selected": true,
                    "codec": "flac",
                    "index": 0,
                    "channels": 2,
                    "bitrate": 1650,
                    "albumGain": "-9.13",
                    "albumPeak": "1.000000",
                    "albumRange": "8.868684",
                    "audioChannelLayout": "stereo",
                    "bitDepth": 24,
                    "gain": "-9.13",
                    "loudness": "-8.87",
                    "lra": "5.80",
                    "peak": "0.993688",
                    "samplingRate": 44100,
                    "displayTitle": "FLAC (Stereo)",
                    "extendedDisplayTitle": "FLAC (Stereo)"
                  },
                  {
                    "id": 71824,
                    "key": "/library/streams/71824",
                    "streamType": 4,
                    "codec": "lrc",
                    "format": "lrc",
                    "minLines": "3",
                    "provider": "com.plexapp.agents.lyricfind",
                    "timed": "1",
                    "displayTitle": "LRC",
                    "extendedDisplayTitle": "LRC (External)"
                  }
                ]
              }
            ]
          }
        ],
        "Image": [
          {
            "alt": "Screwed",
            "type": "coverPoster",
            "url": "/library/metadata/3008/thumb/1717555188"
          },
          {
            "alt": "Screwed",
            "type": "background",
            "url": "/library/metadata/3007/art/1731300415"
          }
        ],
        "Genre": [
          {
            "id": 24810,
            "filter": "genre=24810",
            "tag": "R&b"
          }
        ],
        "Guid": [
          {
            "id": "mbid://f1f18c39-135b-42f9-a019-29663f5e1e4c"
          }
        ]
      }
    ]
  }
}

Summary by CodeRabbit

  • New Features
    • Enhanced metadata for library items with new properties: grandparentTitle, parentTitle, originalTitle, index, and parentIndex, providing more contextual information about hierarchical relationships and item organization.

Copy link

coderabbitai bot commented Nov 17, 2024

Caution

Review failed

The pull request is closed.

📝 Walkthrough
📝 Walkthrough

Walkthrough

The recent modifications pertain to the OpenAPI specification for the get-meta-data-by-rating-key endpoint. Notably, five new properties—grandparentTitle, parentTitle, originalTitle, index, and parentIndex—have been added to the Metadata object in the response schema. Each of these properties is defined as either string or integer types, thereby enriching the metadata provided for library items without altering the existing structure or definitions.

Changes

File Path Change Summary
src/paths/library/metadata/[ratingKey]/get-meta-data-by-rating-key.yaml Added properties: grandparentTitle: string, parentTitle: string, originalTitle: string, index: integer, and parentIndex: integer to the response schema for get-meta-data-by-rating-key.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API
    participant MetadataService

    Client->>API: Request metadata by rating key
    API->>MetadataService: Fetch metadata
    MetadataService-->>API: Return metadata (with new titles)
    API-->>Client: Send metadata response (includes grandparentTitle, parentTitle, originalTitle, index, parentIndex)
Loading

🎩 In the library's grand hall, metadata does swell,
With titles of lineage, it tells quite the tale.
Grandparent, parent, and original too,
A richer response, now splendid and true!
So raise a toast to the data we glean,
For knowledge and context, a most noble scene! 🍷


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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between d3b9c61 and 34cecb0.

📒 Files selected for processing (1)
  • src/paths/library/metadata/[ratingKey]/get-meta-data-by-rating-key.yaml (1 hunks)

Comment on lines 87 to 92
grandparentTitle:
type: string
parentTitle:
type: string
originalTitle:
type: string
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

I say, most splendid additions to the metadata schema, if I may be so bold!

Most certainly, the new title fields are properly positioned within the schema, good sir. However, might I humbly suggest the addition of proper descriptions for these distinguished new properties? It would be most helpful for our esteemed API consumers.

If you would be so kind as to consider this modest enhancement:

 grandparentTitle:
   type: string
+  description: The title of the topmost item in the hierarchy (e.g., TV Show title, Artist name)
 parentTitle:
   type: string
+  description: The title of the intermediate item in the hierarchy (e.g., Season title, Album name)
 originalTitle:
   type: string
+  description: The original title of the item, if different from the primary title

I must commend your judicious decision to omit example values, as they would indeed be rather peculiar in a non-hierarchical context, as noted in your most eloquent PR description.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
grandparentTitle:
type: string
parentTitle:
type: string
originalTitle:
type: string
grandparentTitle:
type: string
description: The title of the topmost item in the hierarchy (e.g., TV Show title, Artist name)
parentTitle:
type: string
description: The title of the intermediate item in the hierarchy (e.g., Season title, Album name)
originalTitle:
type: string
description: The original title of the item, if different from the primary title

@dstaley dstaley changed the title fix: Add additional titles to item metadata fix: Add additional titles and indexes to item metadata Nov 18, 2024
slight description corrections
@JasonLandbridge
Copy link
Collaborator

Thank you for the contribution!

@JasonLandbridge JasonLandbridge merged commit bd2c317 into LukeHagar:main Nov 18, 2024
3 checks passed
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.

2 participants