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

feat(Parser): Parse YpcTrailer in VideoInfo #842

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading