Skip to content

Commit 4d63698

Browse files
committed
youtube: detect age-restrictions for YouTube shorts as well
1 parent c6bd724 commit 4d63698

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

config.local.js.SAMPLE

+1-2
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ export default {
256256
youtube: {
257257
// api_key: "INSERT YOUR VALUE",
258258
// parts: [ "snippet", "player" ], // list of fields you want to use in the request, in most cases you only need those two
259-
get_params: "?rel=0&showinfo=1", // https://developers.google.com/youtube/player_parameters,
260-
fix_shorts_in_eu: true // Avoid consent redirect for EU servers
259+
get_params: "?rel=0&showinfo=1", // https://developers.google.com/youtube/player_parameters
261260
},
262261
vimeo: {
263262
get_params: "?byline=0&badge=0" // https://developer.vimeo.com/player/embedding
+7-17
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
11
/**
2-
* This is an alternative fix for https://github.com/itteco/iframely/issues/543.
3-
* If your servers are in EU, this avoids a redirect to cookie consents,
4-
* Activate it by addong
2+
* This was an alternative fix for https://github.com/itteco/iframely/issues/543.
3+
* YT Shorts are now covered by main plugin to detect age-restricted players that do not work.
4+
* Here, we only need a bigger og-image
55
*/
66

77
export default {
88

99
re: /^https?:\/\/www\.youtube\.com\/shorts\/([a-zA-Z0-9_-]+)/i,
1010

1111
mixins: [
12-
"domain-icon",
13-
"oembed-title",
14-
"oembed-site",
15-
"oembed-author",
16-
"oembed-thumbnail",
17-
"oembed-video", // "allow" attributes will be merged from there
18-
"oembed-iframe"
12+
"og-image",
13+
"oembed-thumbnail" // smaller image is backup for EU where they may get a redirect to consent page
1914
],
2015

21-
getLink: function(iframe) {
22-
return {
23-
href: iframe.src,
24-
type: CONFIG.T.text_html,
25-
rel: CONFIG.R.player,
26-
"aspect-ratio": 9/16,
27-
}
16+
getData: function(options) {
17+
options.followHTTPRedirect = true;
2818
}
2919
};

plugins/domains/youtube.com/youtube.video.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export default {
1111
/^https?:\/\/www\.youtube\.com\/live\/([a-zA-Z0-9_-]+)/i,
1212
/^https?:\/\/www\.youtube\.com\/v\/([a-zA-Z0-9_-]+)/i,
1313
/^https?:\/\/www\.youtube\.com\/user\/[a-zA-Z0-9_-]+\/?\?v=([a-zA-Z0-9_-]+)/i,
14-
/^https?:\/\/www\.youtube-nocookie\.com\/(?:v|embed)\/([a-zA-Z0-9_-]+)/i
14+
/^https?:\/\/www\.youtube-nocookie\.com\/(?:v|embed)\/([a-zA-Z0-9_-]+)/i,
15+
/^https?:\/\/www\.youtube\.com\/shorts\/([a-zA-Z0-9_-]+)/i
1516
],
1617

1718
mixins: ["domain-icon"],
@@ -104,7 +105,8 @@ export default {
104105
embeddable: entry.status ? entry.status.embeddable : true,
105106
uploadStatus: entry.status?.uploadStatus,
106107
status: entry.status,
107-
ytRating: entry.contentDetails?.contentRating?.ytRating
108+
ytRating: entry.contentDetails?.contentRating?.ytRating,
109+
isShort: /\/shorts\//i.test(urlMatch[0])
108110
};
109111

110112
if (entry.snippet?.thumbnails) {
@@ -266,7 +268,7 @@ export default {
266268
// End of widescreen & allow check
267269

268270
var links = [];
269-
var aspect = widescreen ? 16 / 9 : 4 / 3;
271+
var aspect = youtube_video_gdata.isShort ? 9 / 16 : (widescreen ? 16 / 9 : 4 / 3);
270272

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

0 commit comments

Comments
 (0)