better undefined handling, changes to torrent removing

This commit is contained in:
ThaUnknown 2020-11-12 00:01:50 +01:00
parent 534124803f
commit b4d80e1e28
3 changed files with 7 additions and 6 deletions

View file

@ -305,7 +305,7 @@
<label for="player7">Picture In Picture</label>
</div>
<div class="custom-switch mb-20" data-toggle="tooltip" data-placement="top" data-title="Improves UX And Performance After A Download
Finishes, Greatly Increases RAM Usage">
Finishes, Small Spike In CPU And RAM Usage For A Few Seconds">
<input type="checkbox" id="player8" checked>
<label for="player8">Post-Download Processing</label>
</div>

View file

@ -129,7 +129,7 @@ async function buildVideo(file, nowPlaying) {
} else {
bnext.removeAttribute("disabled")
}
if (playerData.nowPlaying && playerData.nowPlaying[0]) {
if (playerData.nowPlaying && playerData.nowPlaying[0].streamingEpisodes.length == 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] : ""}`
} else if (playerData.nowPlaying && playerData.nowPlaying[1]) {
nowPlayingDisplay.textContent = `EP ${parseInt(playerData.nowPlaying[1])}`
@ -137,11 +137,11 @@ async function buildVideo(file, nowPlaying) {
if ('mediaSession' in navigator && playerData.nowPlaying && playerData.nowPlaying[0]) {
navigator.mediaSession.metadata = new MediaMetadata({
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] : ""),
artist: "Episode " + parseInt(playerData.nowPlaying[1]) + (playerData.nowPlaying[0].streamingEpisodes.length == parseInt(playerData.nowPlaying[1]) ? " - " + episodeRx.exec(playerData.nowPlaying[0].streamingEpisodes.filter(episode => episodeRx.exec(episode.title)[1] == parseInt(playerData.nowPlaying[1]))[0].title)[2] : ""),
album: "Miru",
artwork: [
{
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,
src: playerData.nowPlaying[0].streamingEpisodes.length == parseInt(playerData.nowPlaying[1]) ? 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'
}

View file

@ -82,8 +82,9 @@ let maxTorrents = 1,
videoFiles
async function addTorrent(magnet, media, episode) {
if (client.torrents.length >= maxTorrents) {
client.torrents[0].store ? client.torrents[0].store.destroy() : ""
client.torrents[0].destroy()
client.remove(client.torrents[0].infoHash)
// client.torrents[0].store ? client.torrents[0].store.destroy() : ""
// client.torrents[0].destroy()
}
halfmoon.hideModal("tsearch")
document.location.hash = "#player"