Skip to content

Commit

Permalink
- Workaround for "Video Not Available" issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
trizen committed Aug 9, 2022
1 parent 08a7a37 commit e48bc9d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/WWW/PipeViewer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,10 @@ sub get_streaming_urls {

my @caption_urls;

if ($self->get_debug and $json->{videoDetails}{videoId} ne $videoID) {
say STDERR ":: Different video ID detected: $json->{videoDetails}{videoId}";
}

if (not defined $json->{streamingData}) {
say STDERR ":: Trying to bypass age-restricted gate..." if $self->get_debug;

Expand Down Expand Up @@ -1381,7 +1385,8 @@ sub get_streaming_urls {
# Try again with youtube-dl / invidious
if ( !@streaming_urls
or (($json->{playabilityStatus}{status} // '') =~ /fail|error|unavailable|not available/i)
or $self->get_force_fallback) {
or $self->get_force_fallback
or $json->{videoDetails}{videoId} ne $videoID) {

@streaming_urls = $self->_fallback_extract_urls($videoID);

Expand Down
15 changes: 14 additions & 1 deletion lib/WWW/PipeViewer/Videos.pm
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ sub _fallback_video_details {
title => $info->{fulltitle} // $info->{title},
videoId => $id,

#<<<
videoThumbnails => [
map {
scalar {
Expand All @@ -192,6 +193,7 @@ sub _fallback_video_details {
}
} @{$info->{thumbnails}}
],
#>>>

liveNow => ($info->{is_live} ? 1 : 0),
description => $info->{description},
Expand Down Expand Up @@ -235,7 +237,16 @@ sub video_details {
my $microformat = {};

if (exists $video->{videoDetails}) {

$videoDetails = $video->{videoDetails};

# Workaround for "Video Not Available" issue
if ($videoDetails->{videoId} ne $id) {
if ($self->get_debug) {
say STDERR ":: Different video ID detected: $videoDetails->{videoId}";
}
return $self->_fallback_video_details($id, $fields);
}
}
else {
return $self->_fallback_video_details($id, $fields);
Expand All @@ -249,6 +260,7 @@ sub video_details {
title => eval { $microformat->{title}{simpleText} } // $videoDetails->{title},
videoId => $videoDetails->{videoId},

#<<<
videoThumbnails => [
map {
scalar {
Expand All @@ -259,6 +271,7 @@ sub video_details {
}
} @{$videoDetails->{thumbnail}{thumbnails}}
],
#>>>

liveNow => ($videoDetails->{isLiveContent} || (($videoDetails->{lengthSeconds} || 0) == 0)),
description => eval { $microformat->{description}{simpleText} } // $videoDetails->{shortDescription},
Expand All @@ -273,7 +286,7 @@ sub video_details {
author => $videoDetails->{author} // $microformat->{ownerChannelName},
authorId => $videoDetails->{channelId} // $microformat->{externalChannelId},
rating => $videoDetails->{averageRating},
);
);

if (defined($extra_info) and ref($extra_info) eq 'HASH') {

Expand Down

0 comments on commit e48bc9d

Please sign in to comment.