Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
nleush committed Nov 1, 2024
2 parents 1e007ca + f93d596 commit 2353929
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
2 changes: 1 addition & 1 deletion plugins/domains/dribbble.com.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default {
links.push({
href: twitter.player.value,
type: CONFIG.T.text_html,
rel: [CONFIG.R.player, CONFIG.R.gifv],
rel: CONFIG.R.player,
'aspect-ratio': twitter.player.width / twitter.player.height,
})
}
Expand Down
3 changes: 0 additions & 3 deletions plugins/domains/facebook.com/facebook.thumbnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export default {
'facebook.video'
],

mixins: ['facebook.meta-fallback'],

getLink: function(url, __allowFBThumbnail, options, meta) {

var thumbnail = meta.twitter?.image
Expand Down Expand Up @@ -77,6 +75,5 @@ export default {
tests: [{
noFeeds: true,
skipMethods: ['getData', 'getLink'],
skipMixins: ['facebook.meta-fallback']
}]
};
56 changes: 36 additions & 20 deletions plugins/domains/youtube.com/youtube.video.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ export default {
return cb(error);
}

if (data && data.items && data.items.length > 0) {

if (data?.items?.length > 0) {
var entry = data.items[0];

var duration = 0;
var durationStr = entry.contentDetails && entry.contentDetails.duration;
var durationStr = entry.contentDetails?.duration;
if (durationStr) {
var m = durationStr.match(/(\d+)S/);
if (m) {
Expand All @@ -91,22 +90,24 @@ export default {

var gdata = {
id: urlMatch[1],
title: entry.snippet && entry.snippet.title,
uploaded: entry.snippet && entry.snippet.publishedAt,
uploader: entry.snippet && entry.snippet.channelTitle,
channelId: entry.snippet && entry.snippet.channelId,
description: entry.snippet && entry.snippet.description,
likeCount: entry.statistics && entry.statistics.likeCount,
dislikeCount: entry.statistics && entry.statistics.dislikeCount,
viewCount: entry.statistics && entry.statistics.viewCount,

hd: entry.contentDetails && entry.contentDetails.definition === "hd",
playerHtml: entry.player && entry.player.embedHtml,
title: entry.snippet?.title,
uploaded: entry.snippet?.publishedAt,
uploader: entry.snippet?.channelTitle,
channelId: entry.snippet?.channelId,
description: entry.snippet?.description,
likeCount: entry.statistics?.likeCount,
dislikeCount: entry.statistics?.dislikeCount,
viewCount: entry.statistics?.viewCount,

hd: entry.contentDetails?.definition === "hd",
playerHtml: entry.player?.embedHtml,
embeddable: entry.status ? entry.status.embeddable : true,
uploadStatus: entry.status && entry.status.uploadStatus
uploadStatus: entry.status?.uploadStatus,
status: entry.status,
ytRating: entry.contentDetails?.contentRating?.ytRating
};

if (entry.snippet && entry.snippet.thumbnails) {
if (entry.snippet?.thumbnails) {
gdata.thumbnails = entry.snippet.thumbnails;
}

Expand All @@ -117,7 +118,7 @@ export default {
if (gdata.uploadStatus === "rejected") {
cb({
responseStatusCode: 410,
message: "The video has been removed. Reason: " + (entry.status && entry.status.rejectionReason || 'not given')
message: "The video has been removed. Reason: " + (entry.status?.rejectionReason || 'not given')
});
} else {
cb(null, {
Expand Down Expand Up @@ -146,6 +147,7 @@ export default {
likes: youtube_video_gdata.likeCount,
dislikes: youtube_video_gdata.dislikeCount,
views: youtube_video_gdata.viewCount,
warning: youtube_video_gdata.ytRating === 'ytAgeRestricted' ? 'age': null,
site: "YouTube",
canonical: "https://www.youtube.com/watch?v=" + youtube_video_gdata.id,
author_url: "https://www.youtube.com/" + (youtube_video_gdata.channelId ? "channel/" + youtube_video_gdata.channelId : "user/" + youtube_video_gdata.uploader)
Expand Down Expand Up @@ -202,19 +204,31 @@ export default {
// https://developers.google.com/youtube/player_parameters#cc_load_policy
var cc_load_policy = options.getRequestOptions('youtube.cc_load_policy', params.cc_load_policy);
if (cc_load_policy) {
params.cc_load_policy = '1';
params.cc_load_policy = 1;
} else if (params.cc_load_policy) {
delete params.cc_load_policy;
}

// https://developers.google.com/youtube/player_parameters#controls
var controls = options.getRequestOptions('youtube.controls', params.controls);
if (controls == 0) {
params.controls = '0';
params.controls = 0;
} else if (params.controls) {
delete params.controls;
}

// https://developers.google.com/youtube/player_parameters#loop
var loop = options.getRequestOptions('youtube.loop', params.loop);
if (loop) {
params.loop = 1;
// 'To loop a single video, set the loop parameter value to 1 and set the playlist parameter value to the same video ID'
if (!params.playlist) {
params.playlist = youtube_video_gdata.id;
}
} else if (params.loop) {
delete params.loop;
}

// Support for direct links to YouTube clip embeds
if (/\/embed\/[^\?]+\?.*clip=.+clipt=.+/i.test(url)) {
var uri = url;
Expand Down Expand Up @@ -254,7 +268,7 @@ export default {
var links = [];
var aspect = widescreen ? 16 / 9 : 4 / 3;

if (youtube_video_gdata.embeddable) {
if (youtube_video_gdata.embeddable && youtube_video_gdata.ytRating !== 'ytAgeRestricted') {

var qs = querystring.stringify(params);
if (qs !== '') {qs = '?' + qs}
Expand Down Expand Up @@ -284,6 +298,8 @@ export default {
}
}
});
} else if (youtube_video_gdata.ytRating === 'ytAgeRestricted') {
links.push({message: "This video is age-restricted and only available on YouTube"});
} else {
links.push({message: (youtube_video_gdata.uploader || "Uploader of this video") + " disabled embedding on other sites."});
}
Expand Down

0 comments on commit 2353929

Please sign in to comment.