Skip to content

Commit

Permalink
feat(Parser): Parse YpcTrailer in VideoInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkyProgrammer committed Dec 13, 2024
1 parent 3ec1609 commit af4bea7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/parser/youtube/VideoInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import VideoPrimaryInfo from '../classes/VideoPrimaryInfo.js';
import VideoSecondaryInfo from '../classes/VideoSecondaryInfo.js';
import NavigationEndpoint from '../classes/NavigationEndpoint.js';
import PlayerLegacyDesktopYpcTrailer from '../classes/PlayerLegacyDesktopYpcTrailer.js';
import YpcTrailer from '../classes/YpcTrailer.js';
import StructuredDescriptionContent from '../classes/StructuredDescriptionContent.js';
import VideoDescriptionMusicSection from '../classes/VideoDescriptionMusicSection.js';
import LiveChatWrap from './LiveChat.js';
Expand Down Expand Up @@ -335,7 +336,13 @@ export default class VideoInfo extends MediaInfo {
*/
getTrailerInfo(): VideoInfo | null {
if (this.has_trailer && this.playability_status) {
const player_response = this.playability_status.error_screen?.as(PlayerLegacyDesktopYpcTrailer).trailer?.player_response;
let player_response;
if (this.playability_status?.error_screen?.is(PlayerLegacyDesktopYpcTrailer)) {
player_response = this.playability_status.error_screen?.as(PlayerLegacyDesktopYpcTrailer).trailer?.player_response;
} else if (this.playability_status?.error_screen?.is(YpcTrailer)) {
player_response = this.playability_status.error_screen?.as(YpcTrailer).player_response;
}

if (player_response) {
return new VideoInfo([ { data: player_response } as ApiResponse ], this.actions, this.cpn);
}
Expand Down Expand Up @@ -368,7 +375,7 @@ export default class VideoInfo extends MediaInfo {
* Checks if trailer is available.
*/
get has_trailer(): boolean {
return !!this.playability_status?.error_screen?.is(PlayerLegacyDesktopYpcTrailer);
return !!this.playability_status?.error_screen?.is(PlayerLegacyDesktopYpcTrailer, YpcTrailer);
}

/**
Expand Down

0 comments on commit af4bea7

Please sign in to comment.