Skip to content

Commit

Permalink
Handle private videos, use iOS client
Browse files Browse the repository at this point in the history
  • Loading branch information
iBicha committed Sep 22, 2024
1 parent 11d1aef commit 1ff9622
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
8 changes: 7 additions & 1 deletion playlet-web/src/lib/Api/YoutubeJs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,13 @@ export class YoutubeJs {

static async getVideoInfo(videoId: string) {
await this.init();
const info = await YoutubeJs.innerTube.getBasicInfo(videoId, 'ANDROID');
const info = await YoutubeJs.innerTube.getBasicInfo(videoId, 'IOS');

console.log('[YTJS] info:', info);

if (info.playability_status.status !== 'OK') {
throw new Error(`Video not available: ${info.playability_status.reason}`);
}

const formatStreams = info.streaming_data.formats.map(format => {
return {
Expand Down
19 changes: 12 additions & 7 deletions playlet-web/src/lib/VideoFeed/VideoCastDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,18 @@
async function playOnTvHotFix() {
// measure length of time it takes to get video info
const start = performance.now();
const videoInfo = await YoutubeJs.getVideoInfo(videoId);
const end = performance.now();
console.log(`Time to get video info: ${end - start}ms`);
await YoutubeJs.postCacheData(videoInfo);
await playOnTv();
try {
const start = performance.now();
const videoInfo = await YoutubeJs.getVideoInfo(videoId);
const end = performance.now();
console.log(`Time to get video info: ${end - start}ms`);
await YoutubeJs.postCacheData(videoInfo);
await playOnTv();
} catch (e) {
console.error(e);
alert(e.toString());
}
}
async function queueOnTv() {
Expand Down

0 comments on commit 1ff9622

Please sign in to comment.