revert: put back code that I accidentally removed

This commit is contained in:
LuanRT
2021-10-05 18:49:58 -03:00
parent f3c1df74a6
commit f0bb46f2ee

View File

@@ -92,9 +92,10 @@ const stream_headers = (range) => {
};
const formatVideoData = (data, context, desktop) => {
if (desktop) {
let metadata = {};
let video_details = {};
let metadata = {};
if (desktop) {
metadata.embed = data.microformat.playerMicroformatRenderer.embed;
metadata.view_count = parseInt(data.videoDetails.viewCount);
metadata.average_rating = data.videoDetails.averageRating;
@@ -113,15 +114,11 @@ const formatVideoData = (data, context, desktop) => {
metadata.upload_date = data.microformat.playerMicroformatRenderer.uploadDate || 'N/A';
metadata.keywords = data.videoDetails.keywords || [];
let video_details = {};
video_details.title = data.videoDetails.title;
video_details.description = data.videoDetails.shortDescription;
video_details.thumbnail = data.videoDetails.thumbnail.thumbnails.slice(-1)[0];
video_details.metadata = metadata;
return video_details;
} else {
let metadata = {};
metadata.embed = data[2].playerResponse.microformat.playerMicroformatRenderer.embed;
metadata.likes = parseInt(data[3].response.contents.singleColumnWatchNextResults.results.results.contents[1].slimVideoMetadataSectionRenderer.contents[1].slimVideoActionBarRenderer.buttons[0].slimMetadataToggleButtonRenderer.button.toggleButtonRenderer.defaultText.accessibility.accessibilityData.label.replace(/\D/g, ''));
metadata.dislikes = parseInt(data[3].response.contents.singleColumnWatchNextResults.results.results.contents[1].slimVideoMetadataSectionRenderer.contents[1].slimVideoActionBarRenderer.buttons[1].slimMetadataToggleButtonRenderer.button.toggleButtonRenderer.defaultText.accessibility.accessibilityData.label.replace(/\D/g, ''));
@@ -142,13 +139,10 @@ const formatVideoData = (data, context, desktop) => {
metadata.upload_date = data[2].playerResponse.microformat.playerMicroformatRenderer.uploadDate;
metadata.keywords = data[2].playerResponse.videoDetails.keywords;
const id = data[2].playerResponse.videoDetails.videoId;
let video_details = {};
video_details.title = data[2].playerResponse.videoDetails.title;
video_details.description = data[2].playerResponse.videoDetails.shortDescription;
video_details.thumbnail = data[2].playerResponse.videoDetails.thumbnail.thumbnails.slice(-1)[0];
// actions
video_details.like = like => {};
video_details.dislike = dislike => {};
@@ -156,11 +150,11 @@ const formatVideoData = (data, context, desktop) => {
video_details.subscribe = subscribe => {};
video_details.unsubscribe = unsubscribe => {};
video_details.comment = comment => {};
// additional metadata
video_details.metadata = metadata;
return video_details;
}
return video_details;
};
const filters = (order) => {