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

Milestone message parsing error! #16

Open
HitomaruKonpaku opened this issue Dec 10, 2022 · 1 comment
Open

Milestone message parsing error! #16

HitomaruKonpaku opened this issue Dec 10, 2022 · 1 comment

Comments

@HitomaruKonpaku
Copy link

Incorrect durationText parsing lead to error while running durationToSeconds

Seem to caused by the .slice(1)


Code:

const message = renderer.message ? renderer.message.runs : null;
const durationText = renderer
.headerPrimaryText!.runs.slice(1)
.map((r) => r.text)
.join("");


Example payload from https://www.youtube.com/watch?v=oSGkmRhur0Y

{
  "id": "Ci8KLUNNV2F4WVA5cF9zQ0ZTSXZzd0FkQ3JvSF93LUxveU1lc0lELTMzNDEzOTU3Ng%3D%3D",
  "timestampUsec": "1670697881347497",
  "authorExternalChannelId": "UCQRNmDmpBneN3fKlcuMLHZQ",
  "headerPrimaryText": {
    "runs": [
      {
        "text": "Member for 1 month"
      }
    ]
  },
  "headerSubtext": {
    "simpleText": "Bachelor"
  },
  "message": {
    "runs": [
      {
        "text": "WE MISSED YOU TOO VESPER! We understand what you need to do!"
      }
    ]
  },
  "authorName": {
    "simpleText": "Chelsea Rose"
  },
  "authorPhoto": {
    "thumbnails": [
      {
        "url": "https://yt4.ggpht.com/P9mNI29I_xVBKxDmtjUjPecjV94zpQ4K4lsfyHse6XY1Kb1bexrgR5Dp8UKFmbUF0AbTrLMImA=s32-c-k-c0x00ffffff-no-rj",
        "width": 32,
        "height": 32
      },
      {
        "url": "https://yt4.ggpht.com/P9mNI29I_xVBKxDmtjUjPecjV94zpQ4K4lsfyHse6XY1Kb1bexrgR5Dp8UKFmbUF0AbTrLMImA=s64-c-k-c0x00ffffff-no-rj",
        "width": 64,
        "height": 64
      }
    ]
  },
  "authorBadges": [
    {
      "liveChatAuthorBadgeRenderer": {
        "customThumbnail": {
          "thumbnails": [
            {
              "url": "https://yt3.ggpht.com/N2Cpdqu4kPhdc6jS1KLQMOzhk24cBRyj2-S71GEGwrIzJRDxbDWPMlqXBKasCCVzqyctv2lY=s16-c-k",
              "width": 16,
              "height": 16
            },
            {
              "url": "https://yt3.ggpht.com/N2Cpdqu4kPhdc6jS1KLQMOzhk24cBRyj2-S71GEGwrIzJRDxbDWPMlqXBKasCCVzqyctv2lY=s32-c-k",
              "width": 32,
              "height": 32
            }
          ]
        },
        "tooltip": "Member (1 month)",
        "accessibility": {
          "accessibilityData": {
            "label": "Member (1 month)"
          }
        }
      }
    }
  ],
  "contextMenuEndpoint": {
    "clickTrackingParams": "CAYQ4f0GIhMIwef3ztrv-wIVT_A4Bh1fXgMP",
    "commandMetadata": {
      "webCommandMetadata": {
        "ignoreNavigation": true
      }
    },
    "liveChatItemContextMenuEndpoint": {
      "params": "Q2pFS0x3b3RRMDFYWVhoWlVEbHdYM05EUmxOSmRuTjNRV1JEY205SVgzY3RURzk1VFdWelNVUXRNek0wTVRNNU5UYzJHaWtxSndvWVZVTkVVbGRUVHpJNE1XSkpTRmxXYVMxUFZqTnBSbGxCRWd0dlUwZHJiVkpvZFhJd1dTQUJLQUV5R2dvWVZVTlJVazV0Ukcxd1FtNWxUak5tUzJ4amRVMU1TRnBST0FKSUFGQVg="
    }
  },
  "contextMenuAccessibility": {
    "accessibilityData": {
      "label": "Chat actions"
    }
  },
  "trackingParams": "CAYQ4f0GIhMIwef3ztrv-wIVT_A4Bh1fXgMP"
}
@HitomaruKonpaku
Copy link
Author

Payload that seem to work

{
  "id": "Ci8KLUNPTE0yWXZqN2ZzQ0ZZM0FjZ2tkVHhBSURBLUxveU1lc0lELTMzNDEzOTg5OQ%3D%3D",
  "timestampUsec": "1670699496787472",
  "authorExternalChannelId": "UCAs6FfRH8uMYHKQS8w8Z0LQ",
  "headerPrimaryText": {
    "runs": [
      {
        "text": "Member for "
      },
      {
        "text": "3"
      },
      {
        "text": " months"
      }
    ]
  },
  "headerSubtext": {
    "simpleText": "Bachelor"
  },
  "message": {
    "runs": [
      {
        "text": "Grandpaaaaaaaa"
      }
    ]
  },
  "authorName": {
    "simpleText": "Andres Villagra"
  },
  "authorPhoto": {
    "thumbnails": [
      {
        "url": "https://yt4.ggpht.com/ytc/AMLnZu8SuGnqc782QmF3W6zP5Zl2JEpgIIKE1oCXuNf_ig=s32-c-k-c0x00ffffff-no-rj",
        "width": 32,
        "height": 32
      },
      {
        "url": "https://yt4.ggpht.com/ytc/AMLnZu8SuGnqc782QmF3W6zP5Zl2JEpgIIKE1oCXuNf_ig=s64-c-k-c0x00ffffff-no-rj",
        "width": 64,
        "height": 64
      }
    ]
  },
  "authorBadges": [
    {
      "liveChatAuthorBadgeRenderer": {
        "customThumbnail": {
          "thumbnails": [
            {
              "url": "https://yt3.ggpht.com/aO4NckxSeB2uFqBkxaAkVSvl64HdxBvmzLvZ6sZ8rCI2xJTEnWpx4ew0uT8msqp1M6nJ3pyydA=s16-c-k",
              "width": 16,
              "height": 16
            },
            {
              "url": "https://yt3.ggpht.com/aO4NckxSeB2uFqBkxaAkVSvl64HdxBvmzLvZ6sZ8rCI2xJTEnWpx4ew0uT8msqp1M6nJ3pyydA=s32-c-k",
              "width": 32,
              "height": 32
            }
          ]
        },
        "tooltip": "Member (2 months)",
        "accessibility": {
          "accessibilityData": {
            "label": "Member (2 months)"
          }
        }
      }
    }
  ],
  "contextMenuEndpoint": {
    "clickTrackingParams": "CFEQ4f0GIhMI5e6n-uDv-wIV_s44Bh3j9Qbu",
    "commandMetadata": {
      "webCommandMetadata": {
        "ignoreNavigation": true
      }
    },
    "liveChatItemContextMenuEndpoint": {
      "params": "Q2pFS0x3b3RRMDlNVFRKWmRtbzNabk5EUmxrelFXTm5hMlJVZUVGSlJFRXRURzk1VFdWelNVUXRNek0wTVRNNU9EazVHaWtxSndvWVZVTkVVbGRUVHpJNE1XSkpTRmxXYVMxUFZqTnBSbGxCRWd0dlUwZHJiVkpvZFhJd1dTQUJLQUV5R2dvWVZVTkJjelpHWmxKSU9IVk5XVWhMVVZNNGR6aGFNRXhST0FKSUFGQVg="
    }
  },
  "contextMenuAccessibility": {
    "accessibilityData": {
      "label": "Chat actions"
    }
  },
  "trackingParams": "CFEQ4f0GIhMI5e6n-uDv-wIV_s44Bh3j9Qbu",
  "footerButton": {
    "buttonRenderer": {
      "style": "STYLE_DARK_ON_WHITE",
      "size": "SIZE_DEFAULT",
      "isDisabled": false,
      "text": {
        "simpleText": "Buy membership"
      },
      "icon": {
        "iconType": "MEMBERSHIPS"
      },
      "accessibility": {
        "label": "Buy membership"
      },
      "trackingParams": "CFIQz8UIIhMI5e6n-uDv-wIV_s44Bh3j9Qbu",
      "accessibilityData": {
        "accessibilityData": {
          "label": "Buy membership"
        }
      },
      "command": {
        "clickTrackingParams": "CFIQz8UIIhMI5e6n-uDv-wIV_s44Bh3j9Qbu",
        "commandMetadata": {
          "webCommandMetadata": {
            "sendPost": true,
            "apiUrl": "/youtubei/v1/ypc/get_offers"
          }
        },
        "ypcGetOffersEndpoint": {
          "params": "ChwIAxIYVUNEUldTTzI4MWJJSFlWaS1PVjNpRllBGAMqHgoLb1NHa21SaHVyMFkYASoNCgtvU0drbVJodXIwWQ%3D%3D"
        }
      }
    }
  }
}

HitomaruKonpaku added a commit to HitomaruKonpaku/masterchat that referenced this issue Dec 10, 2022
HitomaruKonpaku added a commit to HitomaruKonpaku/masterchat that referenced this issue Dec 10, 2022
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

No branches or pull requests

1 participant