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

Implement custom activity text formatting #165

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

Conversation

hozarho
Copy link

@hozarho hozarho commented Nov 17, 2024

Solves #154

Changes

  • Add support for new display format for music and movies:

    // [...]
    "music": {
      "display": {
        "details_text": "{track}",
        "state_text": "{artists} {sep} {genres}",
        "image_text": "{album} ({year})"
      },
      "separator": "•"	    
    },
    "movies": {
      "display": {
        "details_text": "{title} ({year})",
        "state_text": "{genres} {sep} {critic-score} {sep} {community-score}",
        "image_text": "{title} ({year})"
      },
      "separator": "•"
    },
    // [...]

    Music:
    image
    Movie:
    image

    Just for fun, another example config, with emojis:

    // [...]
    "music": {
      "display": {
        "details_text": "🎧 {track}",
        "state_text": "👤 {artists} 🎭 {genres}",
        "image_text": "💿 {album} ({year})"
      },
      "separator": "•"	    
    },
    "movies": {
      "display": {
        "details_text": "🎬 {title} ({year})",
        "state_text": "🎭 {genres} {critic-score} {community-score}",
        "image_text": "🎬 {title} ({year})"
      },
      "separator": "•"
    },
    // [...]

    Music:
    image

    Movies:
    image

  • tested with old configuration:

    "music": {
      "display": ["album", "year", "genres"],
      "separator": "::"
    },
    "movies": {
      "display": "year, genres, critic-score, community-score",
      "separator": "-"
    },

    image
    image

  • briefly tested TV Episodes and they seem to work as they did before, haven't tested AudioBooks, Books or Live TV
    image

  • API change: new struct DisplayFormat

    • replaces Vec<String> as display type in DisplayOptions
    • options of type String or Vec<String> get converted to DisplayOptions for legacy configuration support
  • supported formatting items:

    • music:
      • {track} - track title
      • {album} - album title
      • {artists} - album artists, comma-separated
      • {genres} - genres, comma-separated
      • {year} - album release year
      • {version} - Jellyfin-RPC version, used for default image_text
      • {sep} - separator
    • movies:
      • {title} - movie title
      • {genres} - genres, comma-separated
      • {year} - movie release year
      • {critic-score} - RT critic score
      • {community-score} - RT community score
      • {version} - Jellyfin-RPC version, used for default image_text
      • {sep} - separator
  • display format texts are sanitized

    • unnecessary whitespaces are removed (e.g. whitespaces in the beginning, end and multiple space characters in a row)

    • duplicated or "dangling" separators are removed - this should take care of situations when some field is empty and separators can be placed one after another

      Example:

      • config: "state_text": "{genres} {sep} {critic-score} {sep} {community-score}"
      • currently played movie has no critic score
      • instead of {genres} {sep} {sep} {community-score} it should return {genres} {sep} {community-score}

Changed for consistency with default/unknown values.
We use the same version anyway.
This function is no longer used - it's replaced by `Client::get_details` for consistency with `Client::get_state` and `Client::get_image_text`. It also grants necessary access to display options format patterns that reside in `Client` struct.
Gets rid of dangling/duplicated separators and duplicated whitespaces.
@nyouness
Copy link

Thank you a lot for this amazing update i love it!

@wraithy
Copy link

wraithy commented Nov 27, 2024

This is dope, it would be nice to have on shows and audiobooks too so that everything matches but other than that it looks great :)

@hozarho
Copy link
Author

hozarho commented Nov 27, 2024

This is dope, it would be nice to have on shows and audiobooks too so that everything matches but other than that it looks great :)

This is what I aim to do eventually. Since their display format is implemented a bit differently (they don't use display value from the config in the same way music and movies do), I'd prefer to address this in a separate issue after all my current changes are accepted. However, I will start working on it in a separate branch.

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.

3 participants