Skip to content

Commit

Permalink
Merge pull request #77 from AN0NCER/develop
Browse files Browse the repository at this point in the history
January update
  • Loading branch information
AN0NCER authored Jan 18, 2024
2 parents 1fb2a03 + 72a5588 commit 87a501a
Show file tree
Hide file tree
Showing 16 changed files with 331 additions and 59 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ Interactive menu with easy settings options
![Menu](https://github.com/AN0NCER/resources/blob/main/new-interact-menu.png?raw=true)
___

<img src="https://raw.githubusercontent.com/AN0NCER/resources/main/screenshot_2.PNG" align="left" width="310">
<img src="https://raw.githubusercontent.com/AN0NCER/resources/main/screenshot_3.PNG" align="lefy" width="310">
<img src="https://raw.githubusercontent.com/AN0NCER/resources/main/screenshot_4.PNG" align="left" width="310">
<img src="https://raw.githubusercontent.com/AN0NCER/resources/main/screenshot_5.PNG" align="left" width="310">
<img src="https://raw.githubusercontent.com/AN0NCER/resources/main/screenshot_2.PNG" align="left" width="23%">
<img src="https://raw.githubusercontent.com/AN0NCER/resources/main/screenshot_3.PNG" align="left" width="23%">
<img src="https://raw.githubusercontent.com/AN0NCER/resources/main/screenshot_4.PNG" align="left" width="23%">
<img src="https://raw.githubusercontent.com/AN0NCER/resources/main/screenshot_5.PNG" align="left" width="23%">
<img src ="https://raw.githubusercontent.com/AN0NCER/resources/main/screenshot_7.jpg" align="left" width="23%">
1 change: 1 addition & 0 deletions images/icons/manifest-b.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"display": "standalone",
"scope": "/",
"start_url": "/?mode=standalone",
"id": "beta-tunime",
"icons": [
{
"src": "/images/icons/logo-x192-b.png",
Expand Down
1 change: 1 addition & 0 deletions images/icons/manifest-o.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"display": "standalone",
"scope": "/",
"start_url": "/?mode=standalone",
"id": "tunime",
"icons": [
{
"src": "/images/icons/logo-x192-o.png",
Expand Down
140 changes: 95 additions & 45 deletions javascript/modules/TunimeApi.js
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();
3 changes: 2 additions & 1 deletion javascript/pages/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FULL_PLAYER, InitSettings, QUALITY } from "./player/mod_settings.js";
import { AnimLoadPlayer } from "./player/mod_animation.js";
import { LoadM3U8, LoadM3U8Episode } from "./player/mod_stream.js";

/**@type {HTMLVideoElement}*/
export const Player = document.getElementById('player');
export const hls = new Hls();
export const onBuffered$ = new rxjs.Subject();
Expand Down Expand Up @@ -129,7 +130,7 @@ function LoadPlayer(stream_file) {
});
let f = onPlay$.subscribe({
next: () => {
if(FULL_PLAYER){
if (FULL_PLAYER) {
toggleFullScreen();
}
f.unsubscribe();
Expand Down
47 changes: 45 additions & 2 deletions javascript/pages/player/mod_animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* кнопок воспроизведения / пауза
* Библиотеки: anime.js, jqery.js
* Возвращает: AnimLoadPlayer, AnimationPlay, AnimButtonStatus, AnimSettings,
* AnimRate
* AnimRate, AnimSkip
*/

import { Skips } from "./mod_stream.js";

//Отвечает за анимацию загрузки плеера
export const AnimLoadPlayer = {
load: false,
Expand Down Expand Up @@ -38,6 +40,12 @@ export const AnimRate = {
hide: () => _amRhide()
}

//Отвечает за анимацию кнопки пропуска
export const AnimSkip = {
show: (index) => _amSkShow(index),
hide: () => _amSkHide()
}

//Html анимцации загрузки
const LOAD_PLAYER_HTML = `<div class="spinner-wrapper"><div class="spinner"><div class="sk-folding-cube"><div class="sk-cube1 sk-cube"></div><div class="sk-cube2 sk-cube"></div><div class="sk-cube4 sk-cube"></div><div class="sk-cube3 sk-cube"></div></div></div></div>`;

Expand Down Expand Up @@ -232,11 +240,46 @@ function _amRShow() {
/**
* Анимация скрытия скорости воспроизведения
*/
function _amRhide(){
function _amRhide() {
anime({
targets: ".video-speed",
easing: "easeInQuad",
duration: 100,
translateX: 0
})
}

/**
* Анимация отображение кнопки пропуска сегмента
*/
function _amSkShow(index) {
if (!Skips.showed) {
anime({
targets: ".player-skip",
easing: "easeInQuad",
duration: 100,
right: 10
});
Skips.index = index;
Skips.showed = !Skips.showed;
}
}

/**
* Анимация скрытия кнопки пропуска сегмента
*/
function _amSkHide(){
if(Skips.showed){
anime({
targets: ".player-skip",
easing: "easeInQuad",
duration: 100,
opacity: 0,
complete:() => {
$('.player-skip').css({right: '', opacity: ''});
}
});
Skips.index = -1;
Skips.showed = !Skips.showed;
}
}
22 changes: 21 additions & 1 deletion javascript/pages/player/mod_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
* Возвращает: InitFunctions, CURSOR_WIDTH, onPlaybackRate2$
*/
import { AnimeQuery, Player, hls, onBuffered$, toggleFullScreen } from "../player.js";
import { AnimSkip } from "./mod_animation.js";
import { SendAPI } from "./mod_api.js";
import { onDuration$, onTimeUpdate$ } from "./mod_event.js";
import { ALTERNATIVE_FULLSCREEN, AUTO_NEKST } from "./mod_settings.js";
import { InitShortcuts } from "./mod_shortcuts.js";
import { Skips } from "./mod_stream.js";

let END_TIME = 0; //Продолжительность видео после обрезки
//Настоящий размер курсора
Expand Down Expand Up @@ -158,6 +160,24 @@ export function InitFunctions() {
}
});

onTimeUpdate$.subscribe({
next: () => {
if (Skips.list.length <= 0) {
return;
}

const index = Skips.list.findIndex(x => {
return (x.start <= Player.currentTime && Player.currentTime <= x.end)
});

if (index > -1 && Skips.index != index) {
AnimSkip.show(index);
} else if (index == -1 && Skips.index > -1) {
AnimSkip.hide();
}
}
})

onBuffered$.subscribe({
next: (time) => {
if (AUTO_NEKST && END_TIME != 0) {
Expand All @@ -174,7 +194,7 @@ export function InitFunctions() {
InitShortcuts();
}

export function ResetFunctions(){
export function ResetFunctions() {
api_nexte_called = false;
}

Expand Down
39 changes: 39 additions & 0 deletions javascript/pages/player/mod_mediasession.js
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) => {

});
}
}
Loading

0 comments on commit 87a501a

Please sign in to comment.