Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintainence Release #214

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion netlify/edge-functions/opengraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default async (request: Request, context: Context) => {

const response = await context.next();
const page = await response.text();
const instance = 'https://inv.nadeko.net';
const instance = 'https://invidious.jing.rocks';
const data = await fetch(instance + '/api/v1/videos/' + id).then(res => res.json());
const music = data.author.endsWith(' - Topic') ? 'https://wsrv.nl?w=180&h=180&fit=cover&url=' : '';
const thumbnail = music + data.videoThumbnails.find((v: { quality: string }) => v.quality === 'medium').url;
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
"dependencies": {
"hls.js": "^1.5.15",
"imsc": "^1.1.5",
"solid-js": "^1.8.22",
"solid-js": "^1.9.1",
"sortablejs": "^1.15.3"
},
"devDependencies": {
"@netlify/edge-functions": "^2.10.0",
"@types/node": "^22.5.5",
"@netlify/edge-functions": "^2.11.0",
"@types/node": "^22.7.2",
"@types/sortablejs": "^1.15.8",
"autoprefixer": "^10.4.20",
"eruda": "^3.3.0",
"typescript": "^5.6.2",
"vite": "^5.4.6",
"vite": "^5.4.8",
"vite-plugin-pwa": "^0.20.5",
"vite-plugin-solid": "^2.10.2"
},
Expand Down
4 changes: 3 additions & 1 deletion src/lib/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const store: {
invidious: string[],
hyperpipe: string,
index: number,
unified: number
},
loadImage: 'off' | 'lazy' | 'eager',
linkHost: string,
Expand Down Expand Up @@ -59,7 +60,8 @@ export const store: {
piped: [],
invidious: [],
hyperpipe: 'https://hyperpipeapi.onrender.com',
index: 0
index: 0,
unified: 0
},
loadImage: getSaved('imgLoad') as 'off' | 'lazy' || 'eager',
linkHost: getSaved('linkHost') || location.origin,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export async function errorHandler(

if (
message !== 'No Data Found' &&
store.api.index < store.api.invidious.length - 1
store.api.index < store.api.unified - 1
) {
store.api.index++;
redoAction();
Expand Down
4 changes: 2 additions & 2 deletions src/modules/getStreamData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function getData(
uploader: data.author,
duration: data.lengthSeconds,
uploaderUrl: data.authorUrl,
category: data.genre,
category: data.genre || 'non-music',
liveStream: data.liveNow,
subtitles: [],
relatedStreams: data.recommendedVideos.map(v => ({
Expand Down Expand Up @@ -72,7 +72,7 @@ export async function getData(

const res = await Promise.any(
pi
.filter((_, i) => i < (h ? pi : iv).length)
.filter((_, i) => i < (h ? pi.length : store.api.unified))
.map(fetchDataFromPiped)
)
.catch(() => h ? {} : Promise.any(
Expand Down
4 changes: 3 additions & 1 deletion src/modules/setAudioStreams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ export function setAudioStreams(audioStreams: {
if (proxyViaPiped && useProxy) return url;

const oldUrl = new URL(url);
const proxy = getSaved('custom_instance_2') ? store.api.invidious[0] : 'https://invidious.fdn.fr';
const isIvUrl = store.api.invidious.includes(oldUrl.origin);
if (isIvUrl && useProxy) return url;

const proxy = store.api.invidious[store.api.index];
const host = useProxy ? proxy :
`https://${oldUrl.searchParams.get('host')}`;

Expand Down
17 changes: 15 additions & 2 deletions src/modules/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default async function() {
.then(data => {
a.piped = data.piped;
a.invidious = data.invidious;
a.unified = data.unified;
});
}

Expand All @@ -46,9 +47,21 @@ export default async function() {
audio.play();
});
h.on(mod.default.Events.ERROR, (_, d) => {

if (d.details === 'manifestLoadError') {
notify(d.details);
player(id);
const hlsUrl = store.player.data!.hls;
const piProxy = (new URL(hlsUrl)).origin;
const defProxy = 'https://invidious.fdn.fr';
if (piProxy === defProxy) {
notify(d.details);
return;
}
const newUrl = hlsUrl.replace(piProxy, defProxy);
h.loadSource(newUrl);
}
else {
notify('load error, retrying...')
player(store.stream.id);
}

})
Expand Down
36 changes: 18 additions & 18 deletions src/scripts/audioEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,31 +173,31 @@ audio.oncanplaythrough = function() {
getData(nextItem);
}

audio.onerror = async function() {

audio.onerror = function() {
audio.pause();

if (getSaved('custom_instance_2'))
return notify('Proxy Failed to decrypt stream');
return notify('Proxy failed to decrypt stream');

if (store.player.HLS)
return player(store.stream.id);
if (store.player.HLS || getSaved('proxyViaInvidious') === 'false') {
notify('PipedProxy failed to decrypt stream, Retrying...');
player(store.stream.id);
return;
}
/*
Error Proxies
Normal : Unified Invidious Proxied
Negative : Non-Unified Invidious Proxied
*/

const data = store.player.data as Piped;
const adaptiveUrl = data.audioStreams[0].url;
const piProxy = new URL(adaptiveUrl).origin;
const ivProxy = new URL(audio.src).origin;
const ivProxy = (new URL(audio.src)).origin;
const defProxy = 'https://invidious.fdn.fr';


audio.src = audio.src.replace(
ivProxy,
ivProxy === defProxy ?
store.api.invidious[store.api.index] :
ivProxy !== piProxy ?
piProxy : defProxy
);

if (ivProxy === defProxy) {
playButton.classList.replace(playButton.className, 'ri-stop-circle-fill');
notify('Could not play stream in any ways..');
}
else audio.src = audio.src.replace(ivProxy, defProxy);
}


Expand Down