Skip to content
Permalink
Browse files

Add related videos to youtube-dl fallback

  • Loading branch information...
PrestonN committed Oct 15, 2019
1 parent 35fc43c commit ce0576e1b0977575df479b5054dfb742e43bc6b7
Showing with 33 additions and 0 deletions.
  1. +33 −0 src/js/player.js
@@ -220,6 +220,39 @@ function playVideo(videoId, playlistId = '') {

playerView.recommendedVideoList = [];

data.related_videos.forEach((video) => {
let data = {};

let time = video.length_seconds;
let hours = 0;

if (time >= 3600) {
hours = Math.floor(time / 3600);
time = time - hours * 3600;
}

let minutes = Math.floor(time / 60);
let seconds = time - minutes * 60;

if (seconds < 10) {
seconds = '0' + seconds;
}

if (hours > 0) {
data.duration = hours + ":" + minutes + ":" + seconds;
} else {
data.duration = minutes + ":" + seconds;
}

data.id = video.id;
data.title = video.title;
data.channelName = video.author;
data.thumbnail = video.video_thumbnail;
data.viewCount = video.short_view_count_text + " views";

playerView.recommendedVideoList = playerView.recommendedVideoList.concat(data);
});

invidiousFinished = true;
}

0 comments on commit ce0576e

Please sign in to comment.
You can’t perform that action at this time.