Skip to content

Conversation

@evilhamsterman
Copy link
Contributor

@evilhamsterman evilhamsterman commented Apr 21, 2025

Fixes #220

Reduce the amount of boilerplate code and make it easier to work with responses by breaking the various objects out.

Example original format

{
  "0dc845e291374610b86d0d3ff62eedf8": {
    "info": {
      "name": "Receiver",
      "ip_address": "192.168.1.232",
      "locale": "en-US",
      "mac_address": "00:09:B0:3A:78:73",
      "ssid": "",
      "timezone": "America/Los_Angeles",
      "uptime": 2653424.930453,
      "ssdp_udn": "0dc845e2-9137-4610-b86d-0d3ff62eedf8"
    },
    "app_id": "2DB7CC49",
    "display_name": "YouTube Music",
    "is_idle_screen": false,
    "status_text": "YouTube Music",
    "player_state": "PLAYING",
    "current_time": 24.241,
    "idle_reason": "",
    "current_item_id": 0,
    "loading_item_id": 0,
    "content_id": "p4lN2Jvl9RM",
    "content_type": "x-youtube/video",
    "stream_type": "BUFFERED",
    "duration": 212.861,
    "artist": "No Resolve",
    "title": "Surface Pressure",
    "subtitle": "",
    "volume_level": 0.48,
    "volume_muted": false,
    "media_volume_level": 0.48,
    "media_volume_muted": false,
    "session_id": "f8c0390f-f46a-4c08-895d-d15e93ab635b",
    "transport_id": "f8c0390f-f46a-4c08-895d-d15e93ab635b",
    "media_session_id": 1414705539,
    "player_state_id": 1
  }
}

New output

{
  "0dc845e291374610b86d0d3ff62eedf8": {
    "info": {
      "name": "Receiver",
      "ip_address": "192.168.1.232",
      "locale": "en-US",
      "mac_address": "00:09:B0:3A:78:73",
      "ssid": "",
      "timezone": "America/Los_Angeles",
      "uptime": 2654169.557301,
      "ssdp_udn": "0dc845e2-9137-4610-b86d-0d3ff62eedf8"
    },
    "app": {
      "appId": "2DB7CC49",
      "displayName": "YouTube Music",
      "isIdleScreen": false,
      "sessionId": "f8c0390f-f46a-4c08-895d-d15e93ab635b",
      "statusText": "YouTube Music",
      "transportId": "f8c0390f-f46a-4c08-895d-d15e93ab635b"
    },
    "media": {
      "mediaSessionId": 1414705539,
      "playerState": "PLAYING",
      "currentTime": 97.643,
      "idleReason": "",
      "volume": {
        "level": 0.48,
        "muted": false
      },
      "currentItemId": 0,
      "loadingItemId": 0,
      "customData": {
        "playerState": 1
      },
      "media": {
        "contentId": "_E2V0OGEArU",
        "contentType": "x-youtube/video",
        "streamType": "BUFFERED",
        "duration": 210.701,
        "metadata": {
          "metadataType": 3,
          "artist": "Lauren Babic",
          "title": "Chandelier",
          "subtitle": "",
          "images": [
            {
              "url": "https://lh3.googleusercontent.com/jfp2Z_W8p_hnjij4JmEDn2VkCiacneTK3fUvBWfk54ntywd9sR5SGzvfqPTIDA8bJWxR3Dw4nPB1_Ei9=w544-h544-l90-rj",
              "height": 544,
              "width": 544
            },
            {
              "url": "https://lh3.googleusercontent.com/jfp2Z_W8p_hnjij4JmEDn2VkCiacneTK3fUvBWfk54ntywd9sR5SGzvfqPTIDA8bJWxR3Dw4nPB1_Ei9=w302-h302-l90-rj",
              "height": 302,
              "width": 302
            },
            {
              "url": "https://lh3.googleusercontent.com/jfp2Z_W8p_hnjij4JmEDn2VkCiacneTK3fUvBWfk54ntywd9sR5SGzvfqPTIDA8bJWxR3Dw4nPB1_Ei9=w180-h180-l90-rj",
              "height": 180,
              "width": 180
            },
            {
              "url": "https://lh3.googleusercontent.com/jfp2Z_W8p_hnjij4JmEDn2VkCiacneTK3fUvBWfk54ntywd9sR5SGzvfqPTIDA8bJWxR3Dw4nPB1_Ei9=w120-h120-l90-rj",
              "height": 120,
              "width": 120
            },
            {
              "url": "https://lh3.googleusercontent.com/jfp2Z_W8p_hnjij4JmEDn2VkCiacneTK3fUvBWfk54ntywd9sR5SGzvfqPTIDA8bJWxR3Dw4nPB1_Ei9=w60-h60-l90-rj",
              "height": 60,
              "width": 60
            }
          ],
          "releaseDate": ""
        }
      }
    },
    "volume": {
      "level": 0.48,
      "muted": false
    }
  }
}

@vishen
Copy link
Owner

vishen commented Apr 21, 2025

Thanks for this. @evilhamsterman do you mind rebasing off master?

@evilhamsterman
Copy link
Contributor Author

Done

@vishen vishen merged commit 0532dd1 into vishen:master Apr 21, 2025
16 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.

Unpack HTTP status response

2 participants