Support for parsing playlist urls in web app

This commit is contained in:
Brahim Hadriche committed 2024-09-06 16:17:43 -04:00
1 parent 46c7f3ebf6
commit 8cd3264766
3 files changed
+42

No files matched your search

+6
View File
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Support for parsing playlist urls in web app (`https://www.youtube.com/playlist?list=ID`)
## [0.25.5] - 2024-09-06 ## [0.25.5] - 2024-09-06
### Fixed ### Fixed
+9
View File
@@ -57,6 +57,15 @@ export class InvidiousApi {
return await response.json(); return await response.json();
} }
public async getPlaylistMetadata(plid: string) {
if (plid.startsWith("VLPL")) {
plid = plid.substring(2);
}
const response = await fetch(`${this.instance}/api/v1/playlists/${plid}`);
return await response.json();
}
public async resolveUrl(url: string) { public async resolveUrl(url: string) {
const response = await fetch(`${this.instance}/api/v1/resolveurl?url=${encodeURIComponent(url)}`); const response = await fetch(`${this.instance}/api/v1/resolveurl?url=${encodeURIComponent(url)}`);
return await response.json(); return await response.json();
+27
View File
@@ -4,9 +4,11 @@
import { InvidiousApi } from "lib/Api/InvidiousApi"; import { InvidiousApi } from "lib/Api/InvidiousApi";
import VideoCastDialog from "./VideoFeed/VideoCastDialog.svelte"; import VideoCastDialog from "./VideoFeed/VideoCastDialog.svelte";
import ChannelCastDialog from "./VideoFeed/ChannelCastDialog.svelte"; import ChannelCastDialog from "./VideoFeed/ChannelCastDialog.svelte";
import PlaylistCastDialog from "./VideoFeed/PlaylistCastDialog.svelte";
let videoModal; let videoModal;
let channelModal; let channelModal;
let playlistModal;
let isDragging; let isDragging;
let isLoading; let isLoading;
let dragEndTimeout; let dragEndTimeout;
@@ -16,6 +18,7 @@
let videoMetadata; let videoMetadata;
let channelMetadata; let channelMetadata;
let playlistMetadata;
let invidiousApi = new InvidiousApi(); let invidiousApi = new InvidiousApi();
@@ -71,6 +74,9 @@
if (urlInfo && urlInfo.pageType === "WEB_PAGE_TYPE_CHANNEL") { if (urlInfo && urlInfo.pageType === "WEB_PAGE_TYPE_CHANNEL") {
searchForChannelById(urlInfo.ucid); searchForChannelById(urlInfo.ucid);
return; return;
} else if (urlInfo && urlInfo.pageType === "WEB_PAGE_TYPE_PLAYLIST") {
searchForPlaylistById(urlInfo.ucid);
return;
} }
} }
} }
@@ -100,6 +106,16 @@
} }
} }
async function searchForPlaylistById(playlistId) {
try {
isLoading = true;
playlistMetadata = await invidiousApi.getPlaylistMetadata(playlistId);
playlistModal.show();
} finally {
isLoading = false;
}
}
function onDragOver(event) { function onDragOver(event) {
closeModal(); closeModal();
clearTimeout(dragEndTimeout); clearTimeout(dragEndTimeout);
@@ -183,8 +199,10 @@
function closeModal() { function closeModal() {
videoModal?.close(); videoModal?.close();
channelModal?.close(); channelModal?.close();
playlistModal?.close();
videoMetadata = undefined; videoMetadata = undefined;
channelMetadata = undefined; channelMetadata = undefined;
playlistMetadata = undefined;
} }
</script> </script>
@@ -221,3 +239,12 @@
authorId={channelMetadata?.authorId} authorId={channelMetadata?.authorId}
authorThumbnails={channelMetadata?.authorThumbnails} authorThumbnails={channelMetadata?.authorThumbnails}
/> />
<PlaylistCastDialog
bind:this={playlistModal}
title={playlistMetadata?.title}
playlistId={playlistMetadata?.playlistId}
playlistThumbnail={playlistMetadata?.playlistThumbnail}
videoCount={playlistMetadata?.videoCount}
videos={playlistMetadata?.videos}
/>