Skip to content

Commit

Permalink
fix: Special handling for anomalous emoji entities
Browse files Browse the repository at this point in the history
  • Loading branch information
uetchy committed Mar 4, 2022
1 parent c30abd0 commit b1d4d15
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
- `AddBannerAction.id` now refer to chat id
- Move cli tools (`tools/`) to [`masterchat-cli`](https://github.com/holodata/masterchat-cli)

### Fixes

- Special handling for anomalous emoji entities

## v0.13.0

### New
Expand Down
27 changes: 23 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,29 @@ export function textRunToPlainText(run: YTTextRun): string {

export function emojiRunToPlainText(run: YTEmojiRun): string {
const { emoji } = run;
const term = emoji.isCustomEmoji
? emoji.shortcuts[emoji.shortcuts.length - 1]
: emoji.emojiId;

/**
* Anomalous emoji pattern
* 1. Missing `isCustomEmoji` and `emojiId`
* {
emoji: {
emojiId: "",
shortcuts: [":smilisageReng_face_with_tear:"],
searchTerms: ["smiling", "face", "with", "tear"],
image: {
thumbnails: [
{
url: "https://www.youtube.com/s/gaming/emoji/828cb648/emoji_u1f972.svg",
},
],
accessibility: { accessibilityData: { label: "" } },
},
},
},
*/
const term =
emoji.isCustomEmoji || emoji.emojiId === ""
? emoji.shortcuts[emoji.shortcuts.length - 1]
: emoji.emojiId;
return term;
}

Expand Down

0 comments on commit b1d4d15

Please sign in to comment.