Skip to content

Commit

Permalink
chore(parser): Simplify VideoInfo#getTrailerInfo (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue authored Jan 11, 2025
1 parent f3c777b commit 66cbee2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/parser/youtube/VideoInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,12 @@ export default class VideoInfo extends MediaInfo {
* @returns `VideoInfo` for the trailer, or `null` if none.
*/
getTrailerInfo(): VideoInfo | null {
if (this.has_trailer && this.playability_status) {
if (this.has_trailer && this.playability_status?.error_screen) {
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 (this.playability_status.error_screen.is(PlayerLegacyDesktopYpcTrailer)) {
player_response = this.playability_status.error_screen.trailer?.player_response;
} else if (this.playability_status.error_screen.is(YpcTrailer)) {
player_response = this.playability_status.error_screen.player_response;
}

if (player_response) {
Expand Down

0 comments on commit 66cbee2

Please sign in to comment.