Skip to content

Commit

Permalink
Merge pull request #89 from AN0NCER/develop
Browse files Browse the repository at this point in the history
Fix error not loading player
  • Loading branch information
AN0NCER authored Mar 29, 2024
2 parents 1763071 + a49adde commit 5ac895b
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 9 deletions.
75 changes: 67 additions & 8 deletions javascript/modules/TunimeApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ class Tunime {
this.time = 299000;
this.interval = undefined;
this.url = 'tunime.onrender.com';
this.link = {
save: 'hujg',
domain: 'onrender.com',
name: 'tunime'
};
this.tunime = {
url: 'tunime.onrender.com',
save: 'hujg',
name: 'tunime'
};
this.m3u8 = {
url: 'anime-m3u8.onrender.com',
save: 'qmyf',
name: 'anime-m3u8'
};
if (window.location.pathname != '/player.html') {
this.Update();
}
Expand Down Expand Up @@ -38,21 +53,28 @@ class Tunime {

online() {
return new Promise((resolve) => {
let code = 503;
const data = this.access;
fetch(`https://${this.url}/online/`, {
fetch(`https://${this.tunime.url}/online/`, {
method: 'POST',
body: new URLSearchParams({ id: data.id, key: data.key })
}).then((response) => {
code = response.status;
return response.json()
}).then((val) => {
this.access = { id: val.id, key: val.key, date: Date.now() }
this.Update();
resolve(true);
}).catch(async (reas) => {
console.log(`Error: ${this.tunime.url} Code: ${code}`);
if (code == 503) {
this.tunime.url = `${this.tunime.name}-${this.link.save}.onrender.com`;
return resolve(this.online());
}
this.access = Tunime.standart;
await Sleep(1000);
this.Update();
resolve(false);
return resolve(false);
});
});
}
Expand All @@ -68,37 +90,53 @@ class Tunime {
}

anime(id) {
let code = 503;
const data = this.access;
fetch(`https://${this.url}/online/${id}/o`, {
fetch(`https://${this.tunime.url}/online/${id}/o`, {
method: 'POST',
body: new URLSearchParams({ id: data.id, key: data.key })
}).then((response) => {
code = response.status;
return response.json();
}).then((val) => {
this.access = { id: val.id, key: val.key, date: Date.now() }
}).catch(async (err) => {
console.log(`Error: ${this.tunime.url} Code: ${code}`);
if (code == 503) {
this.tunime.url = `${this.tunime.name}-${this.link.save}.onrender.com`;
return this.anime(id);
}
await Sleep(1000);
this.access = Tunime.standart;
await this.online();
this.anime(id);
});
}

//https://anime-m3u8-qmyf.onrender.com - save url
stream(url) {
return new Promise(async (resolve) => {
let code = 503;
const access = this.access;
fetch(`https://anime-m3u8.onrender.com/link-anime`, {
this.m3u8.url
fetch(`https://${this.m3u8.url}/link-anime`, {
body: new URLSearchParams({
'link': url,
'id': access.id,
'key': access.key
}), method: 'post'
}).then((response) => {
code = response.status;
return response.json();
}).then((data) => {
this.access = { id: access.id, key: data.key, date: Date.now() };
return resolve(data);
}).catch(async (res) => {
console.log(`Error: ${this.m3u8.url} Code: ${code}`);
if (code == 503) {
this.m3u8.url = `${this.m3u8.name}-${this.m3u8.save}.onrender.com`;
return resolve(this.stream(url));
}
await Sleep(3000);
return resolve(this.stream(url));
});
Expand All @@ -111,71 +149,92 @@ class Tunime {
.filter(([key, value]) => value !== undefined)
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
.join('&');
return `https://anime-m3u8.onrender.com/m3u8?${queryParams}`;
return `https://${this.m3u8.url}/m3u8?${queryParams}`;
}

tsget(id) {
return new Promise((resolve) => {
let code = 503;
const access = this.access;
if (access.id == Tunime.standart.id) {
return resolve({ translations: [] });
}
fetch(`https://${this.url}/ts/${id}`, {
fetch(`https://${this.tunime.url}/ts/${id}`, {
method: 'POST',
body: new URLSearchParams({
'id': access.id,
'key': access.key
})
}).then((res) => {
code = res.status;
return res.json();
}).then((val) => {
return resolve(val);
}).catch(() => {
console.log(`Error: ${this.tunime.url} Code: ${code}`);
if (code == 503) {
this.tunime.url = `${this.tunime.name}-${this.link.save}.onrender.com`;
return resolve(this.tsget(id));
}
return resolve({ translations: [] });
});
});
}

tsset(aid, tid) {
return new Promise((resolve) => {
let code = 503;
const access = this.access;
if (access.id === Tunime.standart.id) {
return resolve({ completed: false });
}
fetch(`https://${this.url}/ts/${aid}/${tid}`, {
fetch(`https://${this.tunime.url}/ts/${aid}/${tid}`, {
method: 'POST',
body: new URLSearchParams({
'id': access.id,
'key': access.key
})
}).then((res) => {
code = res.status;
return res.json();
}).then((val) => {
return resolve(val);
}).catch(() => {
console.log(`Error: ${this.tunime.url} Code: ${code}`);
if (code == 503) {
this.tunime.url = `${this.tunime.name}-${this.link.save}.onrender.com`;
return resolve(this.tsset(aid, tid));
}
return resolve({ completed: false });
});
});
}

loadpage(data, id) {
return new Promise((resolve) => {
let code = 503;
const access = this.access;
if (access.id === Tunime.standart.id) {
return resolve({ completed: false });
}
fetch(`https://${this.url}/page/load/${id}`, {
fetch(`https://${this.tunime.url}/page/load/${id}`, {
method: 'POST',
body: new URLSearchParams({
'id': access.id,
'key': access.key,
'data': JSON.stringify(data)
})
}).then((res) => {
code = res.status;
return res.json();
}).then((val) => {
return resolve(val);
}).catch(() => {
console.log(`Error: ${this.tunime.url} Code: ${code}`);
if (code == 503) {
this.tunime.url = `${this.tunime.name}-${this.link.save}.onrender.com`;
return resolve(this.loadpage(data, id));
}
return resolve({ completed: false });
});
})
Expand Down
2 changes: 1 addition & 1 deletion sw.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var version = '156';
var version = '157';
var cacheName = 'pwa-tunime-v' + version;
var appShellFilesToCache = [
// Директория: /images/icons
Expand Down

0 comments on commit 5ac895b

Please sign in to comment.