diff --git a/src/parser/classes/SubscribeButton.ts b/src/parser/classes/SubscribeButton.ts index 2f45ea544..990de8002 100644 --- a/src/parser/classes/SubscribeButton.ts +++ b/src/parser/classes/SubscribeButton.ts @@ -7,20 +7,26 @@ import Text from './misc/Text.js'; export default class SubscribeButton extends YTNode { static type = 'SubscribeButton'; - title: Text; - subscribed: boolean; - enabled: boolean; - item_type: string; - channel_id: string; - show_preferences: boolean; - subscribed_text: Text; - unsubscribed_text: Text; - notification_preference_button: SubscriptionNotificationToggleButton | null; - endpoint: NavigationEndpoint; + public button_text: Text; + public subscribed: boolean; + public enabled: boolean; + public item_type: string; + public channel_id: string; + public show_preferences: boolean; + public subscribed_text: Text; + public unsubscribed_text: Text; + public notification_preference_button: SubscriptionNotificationToggleButton | null; + public service_endpoints?: NavigationEndpoint[]; + public on_subscribe_endpoints?: NavigationEndpoint[]; + public on_unsubscribe_endpoints?: NavigationEndpoint[]; + public subscribed_entity_key?: string; + public target_id?: string; + public subscribe_accessibility_label?: string; + public unsubscribe_accessibility_label?: string; constructor(data: RawNode) { super(); - this.title = new Text(data.buttonText); + this.button_text = new Text(data.buttonText); this.subscribed = data.subscribed; this.enabled = data.enabled; this.item_type = data.type; @@ -29,6 +35,26 @@ export default class SubscribeButton extends YTNode { this.subscribed_text = new Text(data.subscribedButtonText); this.unsubscribed_text = new Text(data.unsubscribedButtonText); this.notification_preference_button = Parser.parseItem(data.notificationPreferenceButton, SubscriptionNotificationToggleButton); - this.endpoint = new NavigationEndpoint(data.serviceEndpoints?.[0] || data.onSubscribeEndpoints?.[0]); + + if (Reflect.has(data, 'serviceEndpoints')) + this.service_endpoints = data.serviceEndpoints.map((endpoint: RawNode) => Parser.parseItem(endpoint, NavigationEndpoint)); + + if (Reflect.has(data, 'onSubscribeEndpoints')) + this.on_subscribe_endpoints = data.onSubscribeEndpoints.map((endpoint: RawNode) => Parser.parseItem(endpoint, NavigationEndpoint)); + + if (Reflect.has(data, 'onUnsubscribeEndpoints')) + this.on_unsubscribe_endpoints = data.onUnsubscribeEndpoints.map((endpoint: RawNode) => Parser.parseItem(endpoint, NavigationEndpoint)); + + if (Reflect.has(data, 'subscribedEntityKey')) + this.subscribed_entity_key = data.subscribedEntityKey; + + if (Reflect.has(data, 'targetId')) + this.target_id = data.targetId; + + if (Reflect.has(data, 'subscribeAccessibility')) + this.subscribe_accessibility_label = data.subscribeAccessibility.accessibilityData?.label; + + if (Reflect.has(data, 'unsubscribeAccessibility')) + this.unsubscribe_accessibility_label = data.unsubscribeAccessibility.accessibilityData?.label; } } \ No newline at end of file