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

Generic JSON metadata #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

MateusToyama
Copy link

This PR implements metadata handling and adds a new json_metadata feature to allow the use of a generic serde_json::Value to represent the metadata. This feature enables using metadata when the application has non-standard metadata.

@azasypkin
Copy link
Owner

Hey @MateusToyama,

Thanks a lot for the PR, and sorry for the delayed reply! I don't have access to my usual development Chromecast device to test the changes at the moment (I happen to have Chromecast with Google TV (HD) but unlike older Chromecasts, it doesn't seem to work without a proper HDMI output device). However, I'll get back to my devices in mid-February and review/merge the PR.

Having said that, the PR looks good to me, I just need to test the changes on a real device before pushing a new release.

@azasypkin
Copy link
Owner

I'm finally back and starting to review pending PRs, sorry for the delay again. @MateusToyama, do you happen to have an example of using non-standard metadata? What value do we get in metadata_type from Chromecast when non-standard metadata is used? I'm wondering if we can just tweak deserialization a bit and instead of returning a Metadata struct, return a Metadata enum with a Custom(JSONValue)-like member if deserialization fails or if metadata_type indicates that the metadata has a custom shape (if possible).

@MateusToyama
Copy link
Author

Hello @azasypkin, here is one simplified example from Crunchyroll:

{
  "images": [
    {
      "height": 1080,
      "url": "https://www.crunchyroll.com/imgsrv/display/thumbnail/1920x1080/catalog/crunchyroll/423f2880b4e586b8e8c018df3ecc7ceb.jpe",
      "width": 1920
    }
  ],
  "media_class": "episode",
  "media_href": "/content/v2/cms/objects/G6X0MP75Y",
  "media_json": "{}",
  "media_resource_key": "cms:/episodes/G6X0MP75Y",
  "metadataType": 0,
  "posterUrl": "https://www.crunchyroll.com/imgsrv/display/thumbnail/1600x900/catalog/crunchyroll/a249096c7812deb8c3c2c907173f3774.jpe",
  "subtitle": "One Piece",
  "subtitles": "{}"
}

The metadata_type value is METADATA_GENERIC, so I don't think we can use it to know if the metadata has a custom shape.

It still has the standard fields, so the deserialization doesn't fail, but we lose the custom fields.

@g2p
Copy link
Contributor

g2p commented Mar 4, 2024

There's probably a way to use serde(flatten) to stuff unrecognised fields into a json::Value field while keeping the standard fields.

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.

None yet

3 participants