mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-30 09:55:18 +00:00
feat(parser): allow parser to find renderers by name
Now we can organize renderers in individual folders and fix the mess that `../contents/classes` is!
This commit is contained in:
@@ -10,17 +10,23 @@ class Poll {
|
||||
constructor(data) {
|
||||
this.choices = data.choices.map((choice) => ({
|
||||
text: new Text(choice.text).toString(),
|
||||
select_endpoint: new NavigationEndpoint(choice.selectServiceEndpoint),
|
||||
deselect_endpoint: new NavigationEndpoint(choice.deselectServiceEndpoint),
|
||||
vote_ratio_if_selected: choice.voteRatioIfSelected,
|
||||
select_endpoint: choice.selectServiceEndpoint ? new NavigationEndpoint(choice.selectServiceEndpoint) : null,
|
||||
deselect_endpoint: choice.deselectServiceEndpoint ? new NavigationEndpoint(choice.deselectServiceEndpoint) : null,
|
||||
vote_ratio_if_selected: choice?.voteRatioIfSelected || null,
|
||||
vote_percentage_if_selected: new Text(choice.votePercentageIfSelected),
|
||||
vote_ratio_if_not_selected: choice.voteRatioIfSelected,
|
||||
vote_ratio_if_not_selected: choice?.voteRatioIfSelected || null,
|
||||
vote_percentage_if_not_selected: new Text(choice.votePercentageIfSelected),
|
||||
image: Thumbnail.fromResponse(choice.image)
|
||||
image: choice.image ? Thumbnail.fromResponse(choice.image) : null
|
||||
}));
|
||||
|
||||
this.total_votes = new Text(data.totalVotes);
|
||||
this.poll_type = data.type;
|
||||
|
||||
if (poll.type)
|
||||
this.poll_type = data.type;
|
||||
|
||||
if (data.totalVotes)
|
||||
this.total_votes = new Text(data.totalVotes);
|
||||
|
||||
if (data.liveChatPollId)
|
||||
this.live_chat_poll_id = data.liveChatPollId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ const Parser = require('../..');
|
||||
|
||||
class AddBannerToLiveChatCommand {
|
||||
constructor(data) {
|
||||
return Parser.parse(data.bannerRenderer, 'livechat/items');
|
||||
return Parser.parse(data.bannerRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class AddChatItemAction {
|
||||
type = 'AddChatItemAction';
|
||||
|
||||
constructor(data) {
|
||||
this.item = Parser.parse(data.item, 'livechat/items');
|
||||
this.item = Parser.parse(data.item);
|
||||
this.client_id = data.clientId || null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ class AddLiveChatTickerItemAction {
|
||||
type = 'AddLiveChatTickerItemAction';
|
||||
|
||||
constructor(data) {
|
||||
this.item = Parser.parse(data.item, 'livechat/items');
|
||||
this.item = Parser.parse(data.item);
|
||||
this.duration_sec = data.durationSec;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class LiveChatActionPanel {
|
||||
|
||||
constructor(data) {
|
||||
this.id = data.id;
|
||||
this.contents = Parser.parse(data.contents, 'livechat/items');
|
||||
this.contents = Parser.parse(data.contents);
|
||||
this.target_id = data.targetId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ const Parser = require('../..');
|
||||
class ReplaceChatItemAction {
|
||||
constructor(data) {
|
||||
this.target_item_id = data.targetItemId;
|
||||
this.replacement_item = Parser.parse(data.replacementItem, 'livechat/items');
|
||||
this.replacement_item = Parser.parse(data.replacementItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class ReplayChatItemAction {
|
||||
this.actions = Parser.parse(data.actions?.map((action) => {
|
||||
delete action.clickTrackingParams;
|
||||
return action;
|
||||
}), 'livechat') || [];
|
||||
})) || [];
|
||||
|
||||
this.video_offset_time_msec = data.videoOffsetTimeMsec;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ class ShowLiveChatActionPanelAction {
|
||||
type = 'ShowLiveChatActionPanelAction';
|
||||
|
||||
constructor(data) {
|
||||
this.panel_to_show = Parser.parse(data.panelToShow, 'livechat');
|
||||
this.panel_to_show = Parser.parse(data.panelToShow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class UpdateLiveChatPollAction {
|
||||
type = 'UpdateLiveChatPollAction';
|
||||
|
||||
constructor(data) {
|
||||
this.poll_to_update = Parser.parse(data.pollToUpdate, 'livechat/items');
|
||||
this.poll_to_update = Parser.parse(data.pollToUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const Parser = require('../../..');
|
||||
const Text = require('../../Text');
|
||||
const NavigationEndpoint = require('../../NavigationEndpoint');
|
||||
|
||||
class Poll {
|
||||
type = 'Poll';
|
||||
|
||||
constructor(data) {
|
||||
this.header = Parser.parse(data.header, 'livechat/items');
|
||||
|
||||
this.choices = data.choices.map((choice) => ({
|
||||
text: new Text(choice.text).toString(),
|
||||
selected: choice.selected,
|
||||
vote_ratio: choice.voteRatio,
|
||||
vote_percentage: new Text(choice.votePercentage).toString(),
|
||||
select_endpoint: new NavigationEndpoint(choice.selectServiceEndpoint)
|
||||
}));
|
||||
|
||||
this.live_chat_poll_id = data.liveChatPollId;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Poll;
|
||||
Reference in New Issue
Block a user