Add YouTube OAuth callback URL configuration and enhance token handling
This commit is contained in:
parent
3a2edb1e30
commit
e1da7c43e7
@ -768,20 +768,34 @@ const STREAM_SERVICE_BASE = _runtimeCfg.YTDLP_URL
|
||||
|
||||
const extractYouTubeVideoId = (url) => {
|
||||
if (!url) return '';
|
||||
// Handles: youtu.be/ID, ?v=ID, /embed/ID, /shorts/ID
|
||||
const trimmed = url.trim();
|
||||
// Formatos soportados:
|
||||
// https://www.youtube.com/watch?v=ID
|
||||
// https://www.youtube.com/watch?v=ID&t=123
|
||||
// https://www.youtube.com/live/ID
|
||||
// https://www.youtube.com/live/ID?si=TOKEN
|
||||
// https://youtu.be/ID
|
||||
// https://youtu.be/ID?si=TOKEN
|
||||
// https://www.youtube.com/embed/ID
|
||||
// https://www.youtube.com/shorts/ID
|
||||
// https://www.youtube.com/v/ID
|
||||
// https://m.youtube.com/... (versión móvil)
|
||||
// https://www.youtube-nocookie.com/embed/ID
|
||||
// ID (11 chars directamente)
|
||||
const patterns = [
|
||||
/[?&]v=([a-zA-Z0-9_-]{11})/,
|
||||
/youtu\.be\/([a-zA-Z0-9_-]{11})/,
|
||||
/\/embed\/([a-zA-Z0-9_-]{11})/,
|
||||
/\/shorts\/([a-zA-Z0-9_-]{11})/,
|
||||
/\/v\/([a-zA-Z0-9_-]{11})/,
|
||||
// ?v=ID o &v=ID
|
||||
/[?&]v=([a-zA-Z0-9_-]{11})(?:[&?/]|$)/,
|
||||
// youtu.be/ID — seguido de ?, &, / o fin
|
||||
/youtu\.be\/([a-zA-Z0-9_-]{11})(?:[?&/]|$)/,
|
||||
// /live/ID, /embed/ID, /shorts/ID, /v/ID — seguido de ?, &, / o fin
|
||||
/\/(?:live|embed|shorts|v)\/([a-zA-Z0-9_-]{11})(?:[?&/]|$)/,
|
||||
];
|
||||
for (const pattern of patterns) {
|
||||
const match = url.match(pattern);
|
||||
const match = trimmed.match(pattern);
|
||||
if (match) return match[1];
|
||||
}
|
||||
// If it's already just an ID (11 chars alphanumeric)
|
||||
if (/^[a-zA-Z0-9_-]{11}$/.test(url.trim())) return url.trim();
|
||||
// Si ya es solo un ID de 11 caracteres alfanuméricos
|
||||
if (/^[a-zA-Z0-9_-]{11}$/.test(trimmed)) return trimmed;
|
||||
return '';
|
||||
};
|
||||
|
||||
|
||||
@ -36,18 +36,17 @@ const STREAM_SERVICE_BASE = _runtimeCfg.YTDLP_URL
|
||||
|
||||
const extractYouTubeVideoId = (url) => {
|
||||
if (!url) return '';
|
||||
const trimmed = url.trim();
|
||||
const patterns = [
|
||||
/[?&]v=([a-zA-Z0-9_-]{11})/,
|
||||
/youtu\.be\/([a-zA-Z0-9_-]{11})/,
|
||||
/\/embed\/([a-zA-Z0-9_-]{11})/,
|
||||
/\/shorts\/([a-zA-Z0-9_-]{11})/,
|
||||
/\/v\/([a-zA-Z0-9_-]{11})/,
|
||||
/[?&]v=([a-zA-Z0-9_-]{11})(?:[&?/]|$)/,
|
||||
/youtu\.be\/([a-zA-Z0-9_-]{11})(?:[?&/]|$)/,
|
||||
/\/(?:live|embed|shorts|v)\/([a-zA-Z0-9_-]{11})(?:[?&/]|$)/,
|
||||
];
|
||||
for (const pattern of patterns) {
|
||||
const match = url.match(pattern);
|
||||
const match = trimmed.match(pattern);
|
||||
if (match) return match[1];
|
||||
}
|
||||
if (/^[a-zA-Z0-9_-]{11}$/.test(url.trim())) return url.trim();
|
||||
if (/^[a-zA-Z0-9_-]{11}$/.test(trimmed)) return trimmed;
|
||||
return '';
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user