mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-18 13:22:06 +00:00
better nowplaying handling, minor fixes
This commit is contained in:
parent
fc6029bf64
commit
d47adcc09b
5 changed files with 22 additions and 23 deletions
|
|
@ -437,7 +437,7 @@
|
|||
<script src="js/rangeParser.js"></script>
|
||||
<script src="js/idbkv-chunk-store.js"></script>
|
||||
<script src="js/torrentHandler.js"></script>
|
||||
<script src="js/matroska-subtitles.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/matroska-subtitles@3.2.1/dist/matroska-subtitles.min.js"></script>
|
||||
<script src="js/subtitles-octopus.js"></script>
|
||||
<script src="js/subtitleOctopus.js"></script>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ async function nyaaSearch(media, episode) {
|
|||
if (results.children.length == 0) {
|
||||
title = title.replace(/ /g, "+")
|
||||
let url = new URL(`https://miru.kirdow.com/request/?url=https://nyaa.si/?page=rss$c=1_2$f=${settings.torrent3 == true ? 2 : 0}$s=seeders$o=desc$q=${title}"+${episode}+"+${settings.torrent1}`)
|
||||
results = await nyaaRss(url)
|
||||
results = await nyaaRss(url, media, parseInt(episode))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -389,18 +389,17 @@ async function nyaaSearch(media, episode) {
|
|||
table.textContent = ""
|
||||
table.appendChild(results)
|
||||
halfmoon.toggleModal("tsearch")
|
||||
playerData.selected = [media, parseInt(episode)]
|
||||
}
|
||||
}
|
||||
|
||||
async function nyaaRss(url) {
|
||||
async function nyaaRss(url, media, episode) {
|
||||
let frag = document.createDocumentFragment()
|
||||
res = await fetch(url)
|
||||
await res.text().then((xmlTxt) => {
|
||||
try {
|
||||
let doc = DOMPARSER(xmlTxt, "text/xml")
|
||||
if (settings.torrent2 && doc.querySelectorAll("infoHash")[0]) {
|
||||
addTorrent(doc.querySelectorAll("infoHash")[0].textContent)
|
||||
addTorrent(doc.querySelectorAll("infoHash")[0].textContent, media, episode)
|
||||
halfmoon.toggleModal("tsearch")
|
||||
}
|
||||
doc.querySelectorAll("item").forEach((item, index) => {
|
||||
|
|
@ -413,7 +412,7 @@ async function nyaaRss(url) {
|
|||
<td>${i("seeders").textContent}</td>
|
||||
<td>${i("leechers").textContent}</td>
|
||||
<td>${i("downloads").textContent}</td>
|
||||
<td onclick="addTorrent('${i('infoHash').textContent}')" class="pointer">Play</td>`
|
||||
<td onclick="addTorrent('${i('infoHash').textContent},${media},${episode}')" class="pointer">Play</td>`
|
||||
frag.appendChild(template)
|
||||
})
|
||||
|
||||
|
|
@ -460,8 +459,7 @@ async function hsRss() {
|
|||
let media = store[regexParse[2]],
|
||||
template = cardCreator(media, regexParse)
|
||||
template.onclick = () => {
|
||||
playerData.selected = [regexParse[2], regexParse[4]]
|
||||
addTorrent(i('link').textContent)
|
||||
addTorrent(i('link').textContent, media, regexParse[4])
|
||||
}
|
||||
frag.appendChild(template)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,8 +210,8 @@ function toTS(sec) {
|
|||
return "00:00";
|
||||
}
|
||||
|
||||
let hours = Math.floor(sec / 3600)
|
||||
let minutes = Math.floor((sec - (hours * 3600)) / 60)
|
||||
let hours = Math.floor(sec / 3600);
|
||||
let minutes = Math.floor((sec - (hours * 3600)) / 60);
|
||||
let seconds = Math.floor(sec - (hours * 3600) - (minutes * 60));
|
||||
|
||||
if (minutes < 10) {
|
||||
|
|
@ -486,23 +486,22 @@ document.onkeydown = (a) => {
|
|||
}
|
||||
|
||||
// media session
|
||||
function selPlaying(sel) {
|
||||
playerData.nowPlaying = sel
|
||||
if ('mediaSession' in navigator) {
|
||||
function selPlaying() {
|
||||
if ('mediaSession' in navigator && playerData.nowPlaying) {
|
||||
navigator.mediaSession.metadata = new MediaMetadata({
|
||||
title: store[playerData.nowPlaying[0]] ? store[playerData.nowPlaying[0]].title.userPreferred : playerData.nowPlaying[0],
|
||||
artist: "Episode " + parseInt(playerData.nowPlaying[1]),
|
||||
title: playerData.nowPlaying[0].title.userPreferred,
|
||||
artist: "Episode " + parseInt(playerData.nowPlaying[1]) + (playerData.nowPlaying[0].streamingEpisodes.length ? " - " + episodeRx.exec(playerData.nowPlaying[0].streamingEpisodes.filter(episode => episodeRx.exec(episode.title)[1] == parseInt(playerData.nowPlaying[1]))[0].title)[2] : ""),
|
||||
album: "Miru",
|
||||
artwork: [
|
||||
{
|
||||
src: store[playerData.nowPlaying[0]] ? store[playerData.nowPlaying[0]].coverImage.medium : "",
|
||||
src: playerData.nowPlaying[0].streamingEpisodes.length ? playerData.nowPlaying[0].streamingEpisodes.filter(episode => episodeRx.exec(episode.title)[1] == parseInt(playerData.nowPlaying[1]))[0].thumbnail : playerData.nowPlaying[0].coverImage.medium,
|
||||
sizes: '128x128',
|
||||
type: 'image/png'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
nowPlayingDisplay.textContent = `EP ${parseInt(playerData.nowPlaying[1])}`
|
||||
nowPlayingDisplay.textContent = `EP ${parseInt(playerData.nowPlaying[1])}${playerData.nowPlaying[0].streamingEpisodes.length ? " - " + episodeRx.exec(playerData.nowPlaying[0].streamingEpisodes.filter(episode => episodeRx.exec(episode.title)[1] == parseInt(playerData.nowPlaying[1]))[0].title)[2] : ""}`
|
||||
}
|
||||
|
||||
function updatePositionState() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
let client = new WebTorrent({maxConns: settings.torrent6})
|
||||
let client = new WebTorrent({ maxConns: settings.torrent6 })
|
||||
window.onbeforeunload = () => {
|
||||
client.torrents[0] ? client.torrents[0].store.destroy() : ""
|
||||
client.torrents[0] ? client.torrents[0].destroy() : ""
|
||||
|
|
@ -71,17 +71,19 @@ WEBTORRENT_ANNOUNCE = announceList
|
|||
return url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0
|
||||
})
|
||||
let maxTorrents = 1
|
||||
async function addTorrent(magnet) {
|
||||
async function addTorrent(magnet, media, episode) {
|
||||
if (client.torrents.length >= maxTorrents) {
|
||||
client.torrents[0].store ? client.torrents[0].store.destroy() : ""
|
||||
client.torrents[0].destroy()
|
||||
}
|
||||
halfmoon.hideModal("tsearch")
|
||||
document.location.hash = "#player"
|
||||
let selected = playerData.selected,
|
||||
store
|
||||
let store
|
||||
resetVideo()
|
||||
selected ? selPlaying(selected) : ""
|
||||
if (media && episode) {
|
||||
playerData.nowPlaying = [media, episode];
|
||||
selPlaying()
|
||||
}
|
||||
await sw
|
||||
settings.torrent5 ? store = { store: IdbkvChunkStore } : store = {}
|
||||
client.add(magnet, store, function (torrent) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
],
|
||||
"intent_filters": {
|
||||
"scope_url_scheme": "https",
|
||||
"scope_url_host": "miru.moe",
|
||||
"scope_url_host": "mirumoe.netlify.app",
|
||||
"scope_url_path": "/app/"
|
||||
},
|
||||
"protocol_handlers": [
|
||||
|
|
|
|||
Loading…
Reference in a new issue