Merge pull request 'master' (#18) from master into f0ckv2
Reviewed-on: #18
This commit is contained in:
@@ -1898,7 +1898,7 @@ body.layout-modern .global-sidebar-right {
|
|||||||
|
|
||||||
body.layout-legacy .item-layout-container .item-main-content .metadata {
|
body.layout-legacy .item-layout-container .item-main-content .metadata {
|
||||||
align-self: center;
|
align-self: center;
|
||||||
width: 700px;
|
width: 600px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1909,7 +1909,7 @@ body.layout-modern .global-sidebar-right {
|
|||||||
}
|
}
|
||||||
|
|
||||||
body.layout-legacy .item-layout-container #comments-container {
|
body.layout-legacy .item-layout-container #comments-container {
|
||||||
width: 700px;
|
width: 600px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
flex: 0 0 auto !important;
|
flex: 0 0 auto !important;
|
||||||
@@ -4946,7 +4946,7 @@ html[data-dpr="dpr-130"] body.layout-legacy.sidebar-right-hidden .embed-responsi
|
|||||||
|
|
||||||
/* ~139–154% zoom (the 150% tier) */
|
/* ~139–154% zoom (the 150% tier) */
|
||||||
html[data-dpr="dpr-150"] body.layout-legacy .embed-responsive-16by9::before {
|
html[data-dpr="dpr-150"] body.layout-legacy .embed-responsive-16by9::before {
|
||||||
padding-top: 45.25%;
|
padding-top: 52.25%;
|
||||||
}
|
}
|
||||||
html[data-dpr="dpr-150"] body.layout-legacy.sidebar-right-hidden .embed-responsive-16by9::before {
|
html[data-dpr="dpr-150"] body.layout-legacy.sidebar-right-hidden .embed-responsive-16by9::before {
|
||||||
padding-top: 52.25%;
|
padding-top: 52.25%;
|
||||||
|
|||||||
@@ -80,8 +80,40 @@
|
|||||||
meta = await ytOembedPending.get(videoId);
|
meta = await ytOembedPending.get(videoId);
|
||||||
} else {
|
} else {
|
||||||
const promise = (async () => {
|
const promise = (async () => {
|
||||||
|
const ytUrl = `https://www.youtube.com/watch?v=${encodeURIComponent(videoId)}`;
|
||||||
|
// 1. Try client-side oEmbed first (avoids Tor/proxy consent walls)
|
||||||
|
try {
|
||||||
|
const oembedUrl = `https://www.youtube.com/oembed?url=${encodeURIComponent(ytUrl)}&format=json`;
|
||||||
|
const clientResp = await fetch(oembedUrl);
|
||||||
|
if (clientResp.ok) {
|
||||||
|
const clientData = await clientResp.json();
|
||||||
|
if (clientData.title) {
|
||||||
|
const metaObj = {
|
||||||
|
title: clientData.title,
|
||||||
|
site_name: 'youtube.com',
|
||||||
|
author: clientData.author_name || 'Unknown'
|
||||||
|
};
|
||||||
|
// Cache client-side
|
||||||
|
ytOembedCache.set(videoId, metaObj);
|
||||||
|
// Push to server cache so other clients/server benefit
|
||||||
|
try {
|
||||||
|
const csrf = window.f0ckSession?.csrf_token;
|
||||||
|
fetch('/api/v2/meta/cache', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...(csrf ? { 'X-CSRF-Token': csrf } : {})
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ url: ytUrl, meta: metaObj })
|
||||||
|
}).catch(() => {});
|
||||||
|
} catch (_) {}
|
||||||
|
return metaObj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) { }
|
||||||
|
|
||||||
|
// 2. Fall back to backend meta fetch
|
||||||
try {
|
try {
|
||||||
const ytUrl = `https://www.youtube.com/watch?v=${encodeURIComponent(videoId)}`;
|
|
||||||
const r = await fetch(`/api/v2/meta/fetch?url=${encodeURIComponent(ytUrl)}`);
|
const r = await fetch(`/api/v2/meta/fetch?url=${encodeURIComponent(ytUrl)}`);
|
||||||
if (r.ok) {
|
if (r.ok) {
|
||||||
const data = await r.json();
|
const data = await r.json();
|
||||||
|
|||||||
Reference in New Issue
Block a user