-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from AN0NCER/develop
January update
- Loading branch information
Showing
16 changed files
with
331 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,110 @@ | ||
let _updateData = undefined; | ||
let _enabled = false; | ||
|
||
GetOnlineData(); | ||
setInterval(() => { | ||
GetOnlineData(); | ||
}, 299000); | ||
|
||
function GetOnlineData() { | ||
fetch('https://tunime.onrender.com/online').then((response) => { | ||
return response.json(); | ||
}).then((val) => { | ||
_updateData = val; | ||
_enabled = true; | ||
}); | ||
} | ||
import { Sleep } from "./funcitons.js"; | ||
|
||
export const ApiTunime = { | ||
anime: async function (id) { | ||
fetch(`https://tunime.onrender.com/online/${id}/o`).then((response) => { | ||
return response.json(); | ||
}).then((val) => { | ||
console.log(val); | ||
}); | ||
}, | ||
class Tunime { | ||
static get standart() { | ||
return { id: 'shadow', key: 'tunime-register', date: Date.now() - 10000 } | ||
} | ||
|
||
online: function () { | ||
constructor() { | ||
this.lk = 'shadow-api'; | ||
this.life = 350000; | ||
this.time = 299000; | ||
this.interval = undefined; | ||
this.url = 'tunime.onrender.com'; | ||
if (window.location.pathname != '/player.html') { | ||
this.Update(); | ||
} | ||
} | ||
|
||
}, | ||
set access(val) { | ||
if (val && val?.id && val?.key && val?.date) { | ||
localStorage.setItem(this.lk, JSON.stringify(val)); | ||
} | ||
} | ||
|
||
/** | ||
* Получение stream аниме | ||
* @param {string} url - ссыка на Kodik c https:// | ||
* @returns | ||
* @returns {{id: string, key: string, date: number}} | ||
*/ | ||
stream: function (url) { | ||
return new Promise((resolve) => { | ||
fetch(`https://anime-m3u8.onrender.com/link-anime`, { body: new URLSearchParams({ 'link': url }), method: 'post' }) | ||
.then(function (response) { return response.json(); }) | ||
.then(function (data) { return resolve(data); }) | ||
.catch((res) => { console.log(res) }); | ||
get access() { | ||
let inl = localStorage.getItem(this.lk); | ||
inl = inl || JSON.stringify(Tunime.standart); | ||
let val = JSON.parse(inl); | ||
if ((new Date() - val.date) > this.life) { | ||
val = Tunime.standart; | ||
} | ||
this.access = val; | ||
return val; | ||
} | ||
|
||
online() { | ||
const data = this.access; | ||
fetch(`http://${this.url}/online/`, { | ||
method: 'POST', | ||
body: new URLSearchParams({ id: data.id, key: data.key }) | ||
}).then((response) => { | ||
return response.json() | ||
}).then((val) => { | ||
this.access = { id: val.id, key: val.key, date: Date.now() } | ||
this.Update(); | ||
}).catch(async (reas) => { | ||
this.access = Tunime.standart; | ||
await Sleep(1000); | ||
this.Update(); | ||
}); | ||
}, | ||
} | ||
|
||
/** | ||
* Создание обьединеного файла m3u8 | ||
* @param {string} q720 - ссылка на 720p | ||
* @param {string} q480 - ссылка на 480p | ||
* @param {string} q360 - ссылка на 360p | ||
* @returns Ссылку на объединенный файл m3u8 | ||
*/ | ||
link_file: function ({ q720 = undefined, q480 = undefined, q360 = undefined } = {}) { | ||
Update() { | ||
if (this.access.id == 'shadow') { | ||
this.online(); | ||
} | ||
clearInterval(this.interval); | ||
this.interval = setInterval(() => { | ||
this.online(); | ||
}, this.time - (Date.now() - this.access.date)); | ||
} | ||
|
||
anime(id) { | ||
const data = this.access; | ||
fetch(`http://${this.url}/online/${id}/o`, { | ||
method: 'POST', | ||
body: new URLSearchParams({ id: data.id, key: data.key }) | ||
}).then((response) => { | ||
return response.json(); | ||
}).then((val) => { | ||
this.access = { id: val.id, key: val.key, date: Date.now() } | ||
}).catch(async (err) => { | ||
await Sleep(1000); | ||
this.anime(id); | ||
}); | ||
} | ||
|
||
stream(url) { | ||
return new Promise(async (resolve) => { | ||
const access = this.access; | ||
fetch(`http://anime-m3u8.onrender.com/link-anime`, { | ||
body: new URLSearchParams({ | ||
'link': url, | ||
'id': access.id, | ||
'key': access.key | ||
}), method: 'post' | ||
}).then((response) => { | ||
return response.json(); | ||
}).then((data) => { | ||
this.access = { id: access.id, key: data.key, date: Date.now() }; | ||
return resolve(data); | ||
}).catch((res) => { | ||
}); | ||
}); | ||
} | ||
|
||
link({ q720 = undefined, q480 = undefined, q360 = undefined } = {}) { | ||
const params = { q720, q480, q360 }; | ||
const queryParams = Object.entries(params) | ||
.filter(([key, value]) => value !== undefined) | ||
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`) | ||
.join('&'); | ||
return `https://anime-m3u8.onrender.com/m3u8?${queryParams}`; | ||
} | ||
} | ||
} | ||
|
||
export const ApiTunime = new Tunime(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Файл: mod_mediasession.js | ||
* Описание: Мод управляющий метадаными воспроизведения | ||
* Возвращает: InitMediaSession | ||
*/ | ||
|
||
/** | ||
* @param {{time: string, results:[{screenshots:[string], title:string, translation: {title: string}, shikimori_id: number}]}} data | ||
*/ | ||
export function InitMediaSession(data) { | ||
if ("mediaSession" in navigator && $PARAMETERS.watch.previewbs) { | ||
fetch(`https://api.jikan.moe/v4/anime/${data.results[0].shikimori_id}/full`).then((response) => { | ||
if (!response.ok) | ||
return; | ||
return response.json(); | ||
}).then((json) => { | ||
let metadata = { | ||
title: data.results[0].title, | ||
artist: data.results[0].translation.title, | ||
album: "Tunime", | ||
artwork: [ | ||
{ | ||
src: json.data.images.jpg.large_image_url, | ||
sizes: "512x512", | ||
type: "image/png" | ||
}, | ||
{ | ||
src: './images/icons/logo-x256-o.png', | ||
sizes: "256x256", | ||
type: "image/png" | ||
} | ||
] | ||
}; | ||
navigator.mediaSession.metadata = new MediaMetadata(metadata); | ||
}).catch((err) => { | ||
|
||
}); | ||
} | ||
} |
Oops, something went wrong.