mirror of
https://github.com/thegeneralist01/archivr
synced 2026-07-21 18:55:36 +02:00
fix(frontend): tighten isPlaylistSource to mirror backend routing exactly
Previous fix excluded /watch but still returned true for any youtube.com
URL with a ?list= param (e.g. /shorts/xxx?list=yyy). Backend determine_source
only routes to YouTubePlaylist on /playlist?list=... and to YouTubeChannel on
/@handle, /channel/, /c/, /user/ paths — everything else is a single item.
Rewrite the HTTP block to match:
- youtube.com: pathname==='/playlist' && list param → playlist
: /@, /channel/, /c/, /user/ → channel
: anything else (incl. /watch&list=, /shorts?list=) → false
- music.youtube.com: pathname==='/playlist' && list param → YTM playlist
: /watch → single track (falls through to false)
This commit is contained in:
parent
6717fa48cf
commit
6eef53ee3a
3 changed files with 9 additions and 9 deletions
File diff suppressed because one or more lines are too long
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Archivr</title>
|
||||
<script type="module" crossorigin src="/assets/index-BGQ5_lWF.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-C35zoxdh.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-vCRGeW0A.css">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -87,17 +87,17 @@ function isPlaylistSource(locator) {
|
|||
const url = new URL(l)
|
||||
const host = url.hostname
|
||||
if (host === 'youtube.com' || host === 'www.youtube.com' || host === 'm.youtube.com') {
|
||||
// /watch?v=...&list=... is a single video — backend routes it to YouTubeVideo,
|
||||
// not YouTubePlaylist, regardless of the list param.
|
||||
if (url.pathname === '/watch') return false
|
||||
if (url.searchParams.has('list')) return true
|
||||
// Mirror determine_source exactly:
|
||||
// - /playlist?list=... → YouTubePlaylist
|
||||
// - /@handle, /channel/, /c/, /user/ → YouTubeChannel
|
||||
// - everything else (incl. /watch&list=, /shorts?list=) → NOT a playlist
|
||||
if (url.pathname === '/playlist' && url.searchParams.has('list')) return true
|
||||
if (url.pathname.startsWith('/@') || url.pathname.startsWith('/channel/') ||
|
||||
url.pathname.startsWith('/c/') || url.pathname.startsWith('/user/')) return true
|
||||
}
|
||||
if (host === 'music.youtube.com') {
|
||||
// /watch is a single track even if it has a list param
|
||||
if (url.pathname === '/watch') return false
|
||||
if (url.pathname.startsWith('/playlist') || url.searchParams.has('list')) return true
|
||||
// /watch is a single YTM track; only /playlist?list=... is a YTM playlist
|
||||
if (url.pathname === '/playlist' && url.searchParams.has('list')) return true
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue