Support drag and drop links for channels
This commit is contained in:
1 parent
549913ef7d
commit
6051d45a80
4 files changed
+73
-18
No files matched your search
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Known issue: thumbnails might appear cropped/misaligned at the end of videos. This will be addressed in a later release.
|
- Known issue: thumbnails might appear cropped/misaligned at the end of videos. This will be addressed in a later release.
|
||||||
- Search filters in web app
|
- Search filters in web app
|
||||||
- Channels and Playlists can be opened on TV from web app
|
- Channels and Playlists can be opened on TV from web app
|
||||||
|
- Channel links can be drag and dropped into the web app
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,16 @@ export class InvidiousApi {
|
|||||||
return await response.json();
|
return await response.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getChannelMetadata(ucid: string) {
|
||||||
|
const response = await fetch(`${this.instance}/api/v1/channels/${ucid}`);
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async resolveUrl(url: string) {
|
||||||
|
const response = await fetch(`${this.instance}/api/v1/resolveurl?url=${encodeURIComponent(url)}`);
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
|
|
||||||
public async markFeedSourcePagination(feedSource: any) {
|
public async markFeedSourcePagination(feedSource: any) {
|
||||||
const endpoint = this.endpoints[feedSource.endpoint]
|
const endpoint = this.endpoints[feedSource.endpoint]
|
||||||
if (!endpoint || !endpoint.paginationType) {
|
if (!endpoint || !endpoint.paginationType) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
let videoStartAtTimestamp;
|
let videoStartAtTimestamp;
|
||||||
|
|
||||||
let videoMetadata;
|
let videoMetadata;
|
||||||
|
let channelMetadata;
|
||||||
|
|
||||||
let tvName = "Roku TV";
|
let tvName = "Roku TV";
|
||||||
let invidiousInstance;
|
let invidiousInstance;
|
||||||
@@ -44,14 +45,20 @@
|
|||||||
for (var i in event.dataTransfer.items) {
|
for (var i in event.dataTransfer.items) {
|
||||||
let item = event.dataTransfer.items[i];
|
let item = event.dataTransfer.items[i];
|
||||||
if (item.kind === "string" && item.getAsString) {
|
if (item.kind === "string" && item.getAsString) {
|
||||||
let dataString = await new Promise((resolve) =>
|
let dataString = (await new Promise((resolve) =>
|
||||||
item.getAsString(resolve)
|
item.getAsString(resolve)
|
||||||
);
|
)) as string;
|
||||||
if (isValidHttpUrl(dataString)) {
|
if (isValidHttpUrl(dataString)) {
|
||||||
const videoInfo = parseYouTubeUrl(dataString);
|
const videoInfo = parseYouTubeUrl(dataString);
|
||||||
if (videoInfo.videoId) {
|
if (videoInfo.videoId) {
|
||||||
searchForVideoById(videoInfo.videoId, videoInfo.timestamp);
|
searchForVideoById(videoInfo.videoId, videoInfo.timestamp);
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
const urlInfo: any = await invidiousApi.resolveUrl(dataString);
|
||||||
|
if (urlInfo && urlInfo.pageType === "WEB_PAGE_TYPE_CHANNEL") {
|
||||||
|
searchForChannelById(urlInfo.ucid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,6 +79,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function searchForChannelById(channelId) {
|
||||||
|
try {
|
||||||
|
isLoading = true;
|
||||||
|
channelMetadata = await invidiousApi.getChannelMetadata(channelId);
|
||||||
|
modal.showModal();
|
||||||
|
} finally {
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onDragOver(event) {
|
function onDragOver(event) {
|
||||||
modal.close();
|
modal.close();
|
||||||
clearTimeout(dragEndTimeout);
|
clearTimeout(dragEndTimeout);
|
||||||
@@ -162,13 +179,22 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function openInvidiousInNewTab() {
|
async function openChannelOnTv() {
|
||||||
|
await PlayletApi.openChannel(channelMetadata?.authorId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function openVideoInvidiousInNewTab() {
|
||||||
let url = `${invidiousInstance}/watch?v=${videoMetadata?.videoId}`;
|
let url = `${invidiousInstance}/watch?v=${videoMetadata?.videoId}`;
|
||||||
if (videoStartAtChecked && videoStartAtTimestamp) {
|
if (videoStartAtChecked && videoStartAtTimestamp) {
|
||||||
url += `&t=${videoStartAtTimestamp}`;
|
url += `&t=${videoStartAtTimestamp}`;
|
||||||
}
|
}
|
||||||
window.open(url);
|
window.open(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openChannelInvidiousInNewTab() {
|
||||||
|
let url = `${invidiousInstance}/channel/${channelMetadata?.authorId}`;
|
||||||
|
window.open(url);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -185,22 +211,37 @@
|
|||||||
|
|
||||||
<dialog bind:this={modal} id="modal_video_drag_drop" class="modal">
|
<dialog bind:this={modal} id="modal_video_drag_drop" class="modal">
|
||||||
<form method="dialog" class="modal-box bg-base-100">
|
<form method="dialog" class="modal-box bg-base-100">
|
||||||
<h3 class="text-lg m-5">{videoMetadata?.title}</h3>
|
{#if videoMetadata}
|
||||||
<div class="flex flex-col">
|
<h3 class="text-lg m-5">{videoMetadata.title}</h3>
|
||||||
<VideoStartAt
|
<div class="flex flex-col">
|
||||||
bind:checked={videoStartAtChecked}
|
<VideoStartAt
|
||||||
bind:timestamp={videoStartAtTimestamp}
|
bind:checked={videoStartAtChecked}
|
||||||
lengthSeconds={videoMetadata?.lengthSeconds}
|
bind:timestamp={videoStartAtTimestamp}
|
||||||
/>
|
lengthSeconds={videoMetadata.lengthSeconds}
|
||||||
<button class="btn m-2" on:click={playVideoOnTv}>Play on {tvName}</button>
|
/>
|
||||||
<button class="btn m-2" on:click={queueVideoOnTv}
|
<button class="btn m-2" on:click={playVideoOnTv}>
|
||||||
>Queue on {tvName}
|
Play on {tvName}
|
||||||
|
</button>
|
||||||
|
<button class="btn m-2" on:click={queueVideoOnTv}>
|
||||||
|
Queue on {tvName}
|
||||||
|
</button>
|
||||||
|
<button class="btn m-2" on:click={openVideoInvidiousInNewTab}>
|
||||||
|
Open in Invidious
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{:else if channelMetadata}
|
||||||
|
<h3 class="text-lg m-5">{channelMetadata.author}</h3>
|
||||||
|
<div class="text-sm m-5 line-clamp-3">{channelMetadata.description}</div>
|
||||||
|
<button class="btn m-2" on:click={openChannelOnTv}>
|
||||||
|
Open on {tvName}
|
||||||
</button>
|
</button>
|
||||||
<button class="btn m-2" on:click={openInvidiousInNewTab}
|
<button class="btn m-2" on:click={openChannelInvidiousInNewTab}>
|
||||||
>Open in Invidious</button
|
Open in Invidious
|
||||||
>
|
</button>
|
||||||
<button class="btn m-2">Cancel</button>
|
{:else}
|
||||||
</div>
|
<span class="loading loading-spinner loading-md" />
|
||||||
|
{/if}
|
||||||
|
<button class="btn m-2">Cancel</button>
|
||||||
</form>
|
</form>
|
||||||
<form method="dialog" class="modal-backdrop">
|
<form method="dialog" class="modal-backdrop">
|
||||||
<button>close</button>
|
<button>close</button>
|
||||||
|
|||||||
@@ -182,6 +182,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// TODO:P0 handle case of unauthenticated calls
|
||||||
|
// TODO:P0 handle case of popular feed disabled
|
||||||
|
// If we're done loading all the feed, but still have no videos, hide the whole component.
|
||||||
console.error(error);
|
console.error(error);
|
||||||
feedSource.state.loadState = FeedLoadState.Error;
|
feedSource.state.loadState = FeedLoadState.Error;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user