Fix casting mixes, add "Open in YouTube" button

This commit is contained in:
Brahim Hadriche committed 2025-09-10 15:08:25 -04:00
1 parent 1047a7882a
commit 6ac29a5bbb
11 files changed
+77 -12

No files matched your search

@@ -36,6 +36,11 @@
let url = `${invidiousInstanceForRedirect}/channel/${authorId}`;
window.open(url);
}
function openYouTube() {
let url = `https://www.youtube.com/channel/${authorId}`;
window.open(url);
}
</script>
<dialog bind:this={modal} class="modal">
@@ -56,6 +61,9 @@
<button class="btn join-item hover:btn-accent" on:click={openInvidious}>
{$translate("Open in Invidious")}
</button>
<button class="btn join-item hover:btn-accent" on:click={openYouTube}>
{$translate("Open in YouTube")}
</button>
<button class="btn join-item hover:btn-accent"
>{$translate("Cancel")}</button
>
@@ -9,6 +9,8 @@
export let videoCountText: string | undefined = undefined;
export let playlistThumbnail: string | undefined = undefined;
export let videos: any[] | undefined = undefined;
// videoId is Mix continuation (playlistId starts with "RD")
export let videoId: string | undefined = undefined;
export function show() {
modal.showModal();
@@ -42,11 +44,28 @@
}
async function openOnTv() {
await PlayletApi.openPlaylist(playlistId);
const continuationVideoId =
playlistId.startsWith("RD") && videoId ? videoId : undefined;
await PlayletApi.openPlaylist(playlistId, continuationVideoId);
}
function openInvidious() {
let url = `${invidiousInstanceForRedirect}/playlist?list=${playlistId}`;
const continuationVideoId =
playlistId.startsWith("RD") && videoId ? videoId : undefined;
let url = `${invidiousInstanceForRedirect}/mix?list=${playlistId}`;
if (continuationVideoId) {
url += `&continuation=${continuationVideoId}`;
}
window.open(url);
}
function openYouTube() {
let url = "https://www.youtube.com";
if (videoId && playlistId.startsWith("RD")) {
url += `/watch?v=${videoId}&list=${playlistId}`;
} else {
url += `/playlist?list=${playlistId}`;
}
window.open(url);
}
@@ -59,6 +78,7 @@
videoCount,
videoCountText,
videos,
videoId,
};
}
@@ -119,6 +139,9 @@
<button class="btn join-item hover:btn-accent" on:click={openInvidious}>
{$translate("Open in Invidious")}
</button>
<button class="btn join-item hover:btn-accent" on:click={openYouTube}>
{$translate("Open in YouTube")}
</button>
<button class="btn join-item hover:btn-accent"
>{$translate("Cancel")}</button
>
@@ -12,6 +12,8 @@
export let videoCountText: string | undefined = undefined;
export let videos: any[] | undefined = undefined;
export let updated: number | undefined = undefined;
// videoId is Mix continuation (playlistId starts with "RD")
export let videoId: string | undefined = undefined;
export let lines: string[] | undefined = undefined;
// svelte-ignore unused-export-let
@@ -112,4 +114,5 @@
bind:videoCount
bind:videoCountText
bind:videos
bind:videoId
/>
@@ -81,6 +81,14 @@
window.open(url);
}
function openYouTube() {
let url = `https://www.youtube.com/watch?v=${videoId}`;
if (videoStartAtChecked && videoStartAtTimestamp) {
url += `&t=${videoStartAtTimestamp}`;
}
window.open(url);
}
function getVideoInfo() {
const timestamp = videoStartAtChecked ? videoStartAtTimestamp : undefined;
return {
@@ -154,6 +162,9 @@
<button class="btn join-item hover:btn-accent" on:click={openInvidious}>
{$translate("Open in Invidious")}
</button>
<button class="btn join-item hover:btn-accent" on:click={openYouTube}>
{$translate("Open in YouTube")}
</button>
<button class="btn join-item hover:btn-accent"
>{$translate("Cancel")}</button
>
@@ -204,10 +204,10 @@
const newVideos = items;
newVideos.forEach((item) => {
if (item.videoId) {
item.type = "video";
} else if (item.playlistId) {
if (item.playlistId) {
item.type = "playlist";
} else if (item.videoId) {
item.type = "video";
}
});