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

feat(parser): Update LiveChatTextMessage #864

Merged
merged 1 commit into from
Jan 11, 2025

Conversation

jonz94
Copy link
Contributor

@jonz94 jonz94 commented Jan 5, 2025

Update LiveChatTextMessage to extend YTNode rather than LiveChatMessageBase to better align with the latest data provided by Innertube.

  • Add timestamp_usec property
  • Add timestamp_text property
  • Add context_menu_accessibility_label property
  • Add before_content_buttons property

Example response data 1:

{
  "liveChatTextMessageRenderer": {
    "message": {
      "runs": [
        {
          "text": ""
        }
      ]
    },
    "authorName": {
      "simpleText": "ùwú"
    },
    "authorPhoto": {
      "thumbnails": [
        {
          "url": "https://yt4.ggpht.com/ytc/AIdro_k1IuACuxzZhNjtZ2wv7NVcvzDTOy60pZM3jMnX2S3rRRQ=s32-c-k-c0x00ffffff-no-rj",
          "width": 32,
          "height": 32
        },
        {
          "url": "https://yt4.ggpht.com/ytc/AIdro_k1IuACuxzZhNjtZ2wv7NVcvzDTOy60pZM3jMnX2S3rRRQ=s64-c-k-c0x00ffffff-no-rj",
          "width": 64,
          "height": 64
        }
      ]
    },
    "contextMenuEndpoint": {
      "clickTrackingParams": "CAEQl98BIhMIpaqtp-qfigMVXfJMAh31xQ1m",
      "commandMetadata": {
        "webCommandMetadata": {
          "ignoreNavigation": true
        }
      },
      "liveChatItemContextMenuEndpoint": {
        "params": "Q2g0S0hBb2FRMHd6Vkc1UVExTnpXV2RFUm1SZlFuZG5VV1JGUlRCWVpFRWFLU29uQ2hoVlF6SmFWMmRuYjI0eFRrOVVNbFJIWVZaVlRYcFpOMEVTQ3pWT1RuZHdXVU14WjBwRklBRW9CRElhQ2hoVlExOUxXR2N4TUVKeFEyUTBTbEJ4UkRWSmRIWmlabEU0QWtnQlVBRSUzRA=="
      }
    },
    "id": "ChwKGkNMM1RuUENTc1lnREZkX0J3Z1FkRUUwWGRB",
    "timestampUsec": "1725722926731120",
    "authorBadges": [
      {
        "liveChatAuthorBadgeRenderer": {
          "customThumbnail": {
            "thumbnails": [
              {
                "url": "https://yt3.ggpht.com/X9RkCDxc0D7OtVbbJAxZGXbV4-PZw0cg2h_Vg1C6ahIVaYrcTubP1WF3313-LjKz9PRHgY_fVw=s16-c-k",
                "width": 16,
                "height": 16
              },
              {
                "url": "https://yt3.ggpht.com/X9RkCDxc0D7OtVbbJAxZGXbV4-PZw0cg2h_Vg1C6ahIVaYrcTubP1WF3313-LjKz9PRHgY_fVw=s32-c-k",
                "width": 32,
                "height": 32
              }
            ]
          },
          "tooltip": "Member (6 months)",
          "accessibility": {
            "accessibilityData": {
              "label": "Member (6 months)"
            }
          }
        }
      }
    ],
    "authorExternalChannelId": "UC_KXg10BqCd4JPqD5ItvbfQ",
    "contextMenuAccessibility": {
      "accessibilityData": {
        "label": "Chat actions"
      }
    },
    "timestampText": {
      "simpleText": "1:25:40"
    },
    "trackingParams": "CAEQl98BIhMIpaqtp-qfigMVXfJMAh31xQ1m"
  }
}

Example response data 2:

{
  "liveChatTextMessageRenderer": {
    "message": {
      "runs": [
        {
          "text": "請勿提及其他主播或與直播內容無關之話題 初犯300 次犯永BAN"
        }
      ]
    },
    "authorName": {
      "simpleText": "StreamElements"
    },
    "authorPhoto": {
      "thumbnails": [
        {
          "url": "https://yt4.ggpht.com/Kvz6Nw3WLI7dZ0thrEia5CAdN_Ni4EMWJ00VGICdjlmasyokS2lk5dYDndzRM4XQZr1DVLRfQds=s32-c-k-c0x00ffffff-no-rj",
          "width": 32,
          "height": 32
        },
        {
          "url": "https://yt4.ggpht.com/Kvz6Nw3WLI7dZ0thrEia5CAdN_Ni4EMWJ00VGICdjlmasyokS2lk5dYDndzRM4XQZr1DVLRfQds=s64-c-k-c0x00ffffff-no-rj",
          "width": 64,
          "height": 64
        }
      ]
    },
    "contextMenuEndpoint": {
      "clickTrackingParams": "CAEQl98BIhMI8uq9pfGrigMVC_JMAh2wowpP",
      "commandMetadata": {
        "webCommandMetadata": {
          "ignoreNavigation": true
        }
      },
      "liveChatItemContextMenuEndpoint": {
        "params": "Q2g0S0hBb2FRMDFoTFRKWk0zZHhORzlFUm1OWU5teEJhMlF6VjBsMlNrRWFLU29uQ2hoVlEyOU9TME56V0RsMFUzaHBkV2c1YW5wdVdYaFlabmNTQ3poT2NVVjRURUYyUTI0d0lBRW9CRElhQ2hoVlEycGxjbXhEU1dKTVVGRjNVMjVaYkVOc2EycEVXR2M0QWtnQVVBRSUzRA=="
      }
    },
    "id": "ChwKGkNNYS0yWTN3cTRvREZjWDZsQWtkM1dJdkpB",
    "timestampUsec": "1734337887631457",
    "authorBadges": [
      {
        "liveChatAuthorBadgeRenderer": {
          "icon": {
            "iconType": "VERIFIED"
          },
          "tooltip": "Verified",
          "accessibility": {
            "accessibilityData": {
              "label": "Verified"
            }
          }
        }
      },
      {
        "liveChatAuthorBadgeRenderer": {
          "icon": {
            "iconType": "MODERATOR"
          },
          "tooltip": "Moderator",
          "accessibility": {
            "accessibilityData": {
              "label": "Moderator"
            }
          }
        }
      }
    ],
    "authorExternalChannelId": "UCjerlCIbLPQwSnYlClkjDXg",
    "contextMenuAccessibility": {
      "accessibilityData": {
        "label": "Chat actions"
      }
    },
    "trackingParams": "CAEQl98BIhMI8uq9pfGrigMVC_JMAh2wowpP"
  }
}

Example response data 3:

{
  "liveChatTextMessageRenderer": {
    "message": {
      "runs": [
        {
          "text": "寶可夢奇怪的分類"
        }
      ]
    },
    "authorName": {
      "simpleText": "devil_555"
    },
    "authorPhoto": {
      "thumbnails": [
        {
          "url": "https://yt4.ggpht.com/omT8fLnKXKa8AmhsvXe3gzbL1ke-iRx0RoZnsNe6i94fV8ox129Vy5jiR8Q6cH7ziJPbRxfNiQ=s32-c-k-c0x00ffffff-no-rj",
          "width": 32,
          "height": 32
        },
        {
          "url": "https://yt4.ggpht.com/omT8fLnKXKa8AmhsvXe3gzbL1ke-iRx0RoZnsNe6i94fV8ox129Vy5jiR8Q6cH7ziJPbRxfNiQ=s64-c-k-c0x00ffffff-no-rj",
          "width": 64,
          "height": 64
        }
      ]
    },
    "contextMenuEndpoint": {
      "clickTrackingParams": "CAEQl98BIhMI9f3y05OuigMVZ_JMAh3gHQ88",
      "commandMetadata": {
        "webCommandMetadata": {
          "ignoreNavigation": true
        }
      },
      "liveChatItemContextMenuEndpoint": {
        "params": "Q2g0S0hBb2FRMHhQUnpaYUxYZG9TVzlFUm1KcVVIZG5VV1J2ZEZGcWVIY2FLU29uQ2hoVlF6SmFWMmRuYjI0eFRrOVVNbFJIWVZaVlRYcFpOMEVTQzJWc04zRnhNRmhqYmpCTklBRW9CRElhQ2hoVlExOU5NR0pKZEZKcFgzQklURXRVVERKU1NsTm5WVUU0QWtnQlVBRSUzRA=="
      }
    },
    "id": "ChwKGkNMT0c2Wi13aElvREZialB3Z1Fkb3RRanh3",
    "timestampUsec": "1732980716050051",
    "authorBadges": [
      {
        "liveChatAuthorBadgeRenderer": {
          "customThumbnail": {
            "thumbnails": [
              {
                "url": "https://yt3.ggpht.com/ECY6ss6mnC-Ay4w1GfhDc7HiKBd9T8pSsdCIIW3DKEuWLODyt4slsjimjpp-Tdls3WQw7RwDRA=s16-c-k",
                "width": 16,
                "height": 16
              },
              {
                "url": "https://yt3.ggpht.com/ECY6ss6mnC-Ay4w1GfhDc7HiKBd9T8pSsdCIIW3DKEuWLODyt4slsjimjpp-Tdls3WQw7RwDRA=s32-c-k",
                "width": 32,
                "height": 32
              }
            ]
          },
          "tooltip": "New member",
          "accessibility": {
            "accessibilityData": {
              "label": "New member"
            }
          }
        }
      }
    ],
    "authorExternalChannelId": "UC_M0bItRi_pHLKTL2RJSgUA",
    "contextMenuAccessibility": {
      "accessibilityData": {
        "label": "Chat actions"
      }
    },
    "timestampText": {
      "simpleText": "1:29:26"
    },
    "trackingParams": "CAEQl98BIhMI9f3y05OuigMVZ_JMAh3gHQ88",
    "beforeContentButtons": [
      {
        "buttonViewModel": {
          "iconName": "MESSAGE",
          "title": "睡白鼠",
          "onTap": {
            "innertubeCommand": {
              "clickTrackingParams": "CAIQ8FsYcSITCPX98tOTrooDFWfyTAId4B0PPA==",
              "showEngagementPanelEndpoint": {
                "identifier": {
                  "surface": "ENGAGEMENT_PANEL_SURFACE_LIVE_CHAT",
                  "tag": "PAreply_thread"
                },
                "globalConfiguration": {
                  "params": "ggm2AQojVWd6ZUZfeEFyOHZUcWl6V19HTjRBYUFCRHFnQjktdnBpUUkSVgopKicKGFVDMlpXZ2dvbjFOT1QyVEdhVlVNelk3QRILZWw3cXEwWGNuME0QARgEIAE6I1VnemVGX3hBcjh2VHFpeldfR040QWFBQkRxZ0I5LXZwaVFJGgggALABAPgBACIpKicKGFVDMlpXZ2dvbjFOT1QyVEdhVlVNelk3QRILZWw3cXEwWGNuME0oATAB"
                },
                "engagementPanelPresentationConfigs": {
                  "engagementPanelPopupPresentationConfig": {
                    "popupType": "PANEL_POPUP_TYPE_DIALOG"
                  }
                }
              }
            }
          },
          "trackingParams": "CAIQ8FsYcSITCPX98tOTrooDFWfyTAId4B0PPA==",
          "type": "BUTTON_VIEW_MODEL_TYPE_TONAL",
          "buttonSize": "BUTTON_VIEW_MODEL_SIZE_XSMALL",
          "iconTrailing": true,
          "customBackgroundColor": 4293271831,
          "customFontColor": 4294967295
        }
      }
    ]
  }
}

Update `LiveChatTextMessage` to extend `YTNode` rather than
`LiveChatMessageBase` to better align with the latest data
provided by Innertube.

- Add `timestamp_usec` property
- Add `timestamp_text` property
- Add `context_menu_accessibility_label` property
- Add `before_content_buttons` property
@LuanRT LuanRT merged commit 9025122 into LuanRT:main Jan 11, 2025
4 checks passed
@jonz94 jonz94 deleted the update-LiveChatTextMessage branch January 12, 2025 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants