Fixes to recommended videos via ytjs
This commit is contained in:
+2
-2
@@ -4,10 +4,10 @@
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2025-07-08T06:06:15.619274581Z">
|
||||
<DropdownSelection timestamp="2025-07-21T02:41:45.413890396Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="LocalEmulator" identifier="path=/home/ward/.android/avd/Television_4K.avd" />
|
||||
<DeviceId pluginId="LocalEmulator" identifier="path=/home/ward/.android/avd/Pixel_7_Pro.avd" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
|
||||
Generated
+10
-22
@@ -6,7 +6,7 @@
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "materialious",
|
||||
"version": "1.9.20",
|
||||
"version": "1.9.21",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@capacitor-community/electron": "^5.0.1",
|
||||
@@ -37,7 +37,7 @@
|
||||
"sponsorblock-api": "^0.2.4",
|
||||
"svelte-infinite-loading": "^1.4.0",
|
||||
"svelte-persisted-store": "^0.12.0",
|
||||
"youtubei.js": "^14.0.0"
|
||||
"youtubei.js": "^15.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@capacitor/assets": "^3.0.5",
|
||||
@@ -2119,15 +2119,6 @@
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@fastify/busboy": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
|
||||
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/@hugotomazi/capacitor-navigation-bar": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@hugotomazi/capacitor-navigation-bar/-/capacitor-navigation-bar-4.0.1.tgz",
|
||||
@@ -12037,15 +12028,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici": {
|
||||
"version": "5.29.0",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz",
|
||||
"integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==",
|
||||
"version": "6.21.3",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.21.3.tgz",
|
||||
"integrity": "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@fastify/busboy": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0"
|
||||
"node": ">=18.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
@@ -13748,9 +13736,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/youtubei.js": {
|
||||
"version": "14.0.0",
|
||||
"resolved": "https://registry.npmjs.org/youtubei.js/-/youtubei.js-14.0.0.tgz",
|
||||
"integrity": "sha512-KAFttOw+9fwwBUvBc1T7KzMNBLczDOuN/dfote8BA9CABxgx8MPgV+vZWlowdDB6DnHjSUYppv+xvJ4VNBLK9A==",
|
||||
"version": "15.0.0",
|
||||
"resolved": "https://registry.npmjs.org/youtubei.js/-/youtubei.js-15.0.0.tgz",
|
||||
"integrity": "sha512-giPZREn+q0z8Jr45NUcJUXE7QA2+UD2jx5FR+ULdnexvtHg5uQZr9Am8aYcECPKzbBNe6ksBD1yT4SKNbhpRqA==",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/LuanRT"
|
||||
],
|
||||
@@ -13759,7 +13747,7 @@
|
||||
"@bufbuild/protobuf": "^2.0.0",
|
||||
"jintr": "^3.3.1",
|
||||
"tslib": "^2.5.0",
|
||||
"undici": "^5.19.1"
|
||||
"undici": "^6.21.3"
|
||||
}
|
||||
},
|
||||
"node_modules/zimmerframe": {
|
||||
|
||||
@@ -68,6 +68,6 @@
|
||||
"sponsorblock-api": "^0.2.4",
|
||||
"svelte-infinite-loading": "^1.4.0",
|
||||
"svelte-persisted-store": "^0.12.0",
|
||||
"youtubei.js": "^14.0.0"
|
||||
"youtubei.js": "^15.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { androidPoTokenMinter } from '$lib/android/youtube/minter';
|
||||
import type {
|
||||
AdaptiveFormats,
|
||||
Captions,
|
||||
Image,
|
||||
StoryBoard,
|
||||
Thumbnail,
|
||||
@@ -78,6 +77,8 @@ export async function patchYoutubeJs(videoId: string): Promise<VideoPlay> {
|
||||
throw new Error('Unable to pull video info from youtube.js');
|
||||
}
|
||||
|
||||
console.log(video);
|
||||
|
||||
let dashUri: string | undefined;
|
||||
|
||||
if (video.streaming_data) {
|
||||
@@ -98,7 +99,7 @@ export async function patchYoutubeJs(videoId: string): Promise<VideoPlay> {
|
||||
? video.streaming_data.hls_manifest_url // HLS is preferred for DVR streams.
|
||||
: `${video.streaming_data.dash_manifest_url}/mpd_version/7`;
|
||||
} else {
|
||||
dashUri = `data:application/dash+xml;base64,${btoa(await video.toDash({ captions_format: 'vtt' }))}`;
|
||||
dashUri = `data:application/dash+xml;base64,${btoa(await video.toDash({ manifest_options: { captions_format: 'vtt' } }))}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,20 +117,30 @@ export async function patchYoutubeJs(videoId: string): Promise<VideoPlay> {
|
||||
|
||||
const recommendedVideos: VideoBase[] = [];
|
||||
video.watch_next_feed?.forEach((recommended: Record<string, any>) => {
|
||||
if (!recommended.title) {
|
||||
if (
|
||||
!recommended.metadata.title.text ||
|
||||
recommended.content_type !== 'VIDEO' ||
|
||||
!recommended.metadata.metadata.metadata_rows ||
|
||||
recommended.metadata.metadata.metadata_rows.length < 2
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
recommendedVideos.push({
|
||||
videoThumbnails: (recommended?.thumbnails as Thumbnail[]) || [],
|
||||
videoId: recommended?.id || '',
|
||||
title: recommended?.title?.toString() || '',
|
||||
viewCountText: recommended.view_count
|
||||
? numberWithCommas(Number(recommended?.view_count.toString().replace(/\D/g, ''))) || ''
|
||||
videoThumbnails: (recommended?.content_image?.image as Thumbnail[]) || [],
|
||||
videoId: recommended?.content_id || '',
|
||||
title: recommended.metadata.title?.text || '',
|
||||
viewCountText: recommended.metadata.metadata.metadata_rows[1]?.metadata_parts[0]
|
||||
? recommended.metadata.metadata.metadata_rows[1]?.metadata_parts[0]?.text.text?.replace(
|
||||
'views',
|
||||
''
|
||||
)
|
||||
: '',
|
||||
lengthSeconds: recommended?.duration?.seconds || 0,
|
||||
author: recommended?.author?.name || '',
|
||||
authorId: recommended?.author?.id || ''
|
||||
author: recommended.metadata.metadata.metadata_rows[0]?.metadata_parts[0]?.text.text || '',
|
||||
authorId:
|
||||
recommended.metadata?.image?.renderer_context?.command_context?.on_tap.payload?.browseId ||
|
||||
''
|
||||
});
|
||||
});
|
||||
|
||||
@@ -202,7 +213,7 @@ export async function patchYoutubeJs(videoId: string): Promise<VideoPlay> {
|
||||
videoThumbnails: video.basic_info.thumbnail as Thumbnail[],
|
||||
author: video.basic_info.author || 'Unknown',
|
||||
lengthSeconds: video.basic_info.duration || 0,
|
||||
subCountText: '',
|
||||
subCountText: video.secondary_info.owner?.subscriber_count.text || '',
|
||||
keywords: video.basic_info.keywords || [],
|
||||
allowedRegions: [],
|
||||
ytjs: {
|
||||
|
||||
Reference in New Issue
Block a user