Add support for casting clips from web app
This commit is contained in:
1 parent
a0efb3bd76
commit
463b38200b
3 files changed
+41
No files matched your search
@@ -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 casting clips from web app
|
||||||
|
|
||||||
## [0.25.6] - 2024-09-12
|
## [0.25.6] - 2024-09-12
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ export class InvidiousApi {
|
|||||||
return await response.json();
|
return await response.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getClipMetadata(clipId: string) {
|
||||||
|
const response = await fetch(`${this.instance}/api/v1/clips/${clipId}`);
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
|
|
||||||
public async getChannelMetadata(ucid: string) {
|
public async getChannelMetadata(ucid: string) {
|
||||||
const response = await fetch(`${this.instance}/api/v1/channels/${ucid}`);
|
const response = await fetch(`${this.instance}/api/v1/channels/${ucid}`);
|
||||||
return await response.json();
|
return await response.json();
|
||||||
|
|||||||
@@ -67,6 +67,9 @@
|
|||||||
if (videoInfo.videoId) {
|
if (videoInfo.videoId) {
|
||||||
searchForVideoById(videoInfo.videoId, videoInfo.timestamp);
|
searchForVideoById(videoInfo.videoId, videoInfo.timestamp);
|
||||||
return;
|
return;
|
||||||
|
} else if (videoInfo.clipId) {
|
||||||
|
searchVideoByClipId(videoInfo.clipId);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
// TODO:P2 make a HEAD request and check for a redirect, then
|
// TODO:P2 make a HEAD request and check for a redirect, then
|
||||||
// resolve the redirect url.
|
// resolve the redirect url.
|
||||||
@@ -82,6 +85,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function searchVideoByClipId(clipId) {
|
||||||
|
try {
|
||||||
|
isLoading = true;
|
||||||
|
|
||||||
|
const clipInfo = await invidiousApi.getClipMetadata(clipId);
|
||||||
|
const video = clipInfo.video;
|
||||||
|
if (clipInfo.clipTitle) {
|
||||||
|
video.title = `${clipInfo.clipTitle} (${video.title})`;
|
||||||
|
}
|
||||||
|
videoMetadata = video;
|
||||||
|
videoStartAtChecked = !!clipInfo.startTime;
|
||||||
|
if (videoStartAtChecked) {
|
||||||
|
videoStartAtTimestamp = clipInfo.startTime;
|
||||||
|
}
|
||||||
|
videoModal.show();
|
||||||
|
} finally {
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function searchForVideoById(videoId, timestamp) {
|
async function searchForVideoById(videoId, timestamp) {
|
||||||
try {
|
try {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
@@ -149,6 +172,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (url.startsWith("https://www.youtube.com/clip/")) {
|
||||||
|
const clipId = url.substring("https://www.youtube.com/clip/".length);
|
||||||
|
return {
|
||||||
|
clipId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Share/Short url
|
// Share/Short url
|
||||||
const YoutubeUrls = [
|
const YoutubeUrls = [
|
||||||
"https://youtu.be/",
|
"https://youtu.be/",
|
||||||
|
|||||||
Reference in new issue
Block a user