reordered some settings, settings doesnt error out on invalid, corrected episode display for specials [.5], title changes to media title

This commit is contained in:
ThaUnknown 2021-01-31 16:10:05 +01:00
parent 1811160539
commit b49da6a8a0
4 changed files with 20 additions and 16 deletions

View file

@ -742,15 +742,15 @@
Other Settings
</h1>
<div class="custom-switch mb-10" data-toggle="tooltip" data-placement="top"
data-title="Sends A Notification When A New Episode Is Released">
<input type="checkbox" id="other1">
<label for="other1">Release Notifications</label>
</div>
<div class="custom-switch mb-20" data-toggle="tooltip" data-placement="top"
data-title="Automatically Marks Episodes As Complete On AniList When You Finish Watching Them, Requires AniList Login">
<input type="checkbox" id="other2">
<label for="other2">Autocomplete Episodes</label>
</div>
<div class="custom-switch mb-20" data-toggle="tooltip" data-placement="top"
data-title="Sends A Notification When A New Episode Is Released">
<input type="checkbox" id="other3">
<label for="other3">Release Notifications</label>
</div>
</div>
</div>

View file

@ -57,7 +57,7 @@ async function loadHomePage() {
homeReleases.innerHTML = ''
homeReleases.appendChild(gallerySkeletonFrag(5))
resolveFileMedia({ fileName: doc.querySelector("item").querySelector("title").innerHTML, method: "SearchName", isRelease: true }).then(mediaInformation => {
if (settings.other3) {
if (settings.other1) {
let notification = new Notification(mediaInformation.media.title.userPreferred, {
body: `Episode ${mediaInformation.episode} was just released!`,
icon: mediaInformation.media.coverImage.medium

View file

@ -47,6 +47,7 @@ function cleanupVideo() { // cleans up objects, attemps to clear as much video c
video.pause()
video.src = "";
video.load()
document.title = "Miru"
// if (typeof client !== 'undefined' && client.torrents[0] && client.torrents[0].files.length > 1) {
// client.torrents[0].files.forEach(file => file.deselect());
// client.torrents[0].deselect(0, client.torrents[0].pieces.length - 1, false);
@ -142,7 +143,7 @@ async function buildVideo(torrent, opts) { // sets video source and creates a bu
if (playerData.nowPlaying && playerData.nowPlaying[0] && playerData.nowPlaying[1]) {
mediaMetadata = new MediaMetadata({
title: playerData.nowPlaying[0].title.userPreferred,
artist: `Episode ${parseInt(playerData.nowPlaying[1])}`,
artist: `Episode ${Number(playerData.nowPlaying[1])}`,
album: "Miru",
artwork: [{
src: playerData.nowPlaying[0].coverImage.medium,
@ -150,19 +151,22 @@ async function buildVideo(torrent, opts) { // sets video source and creates a bu
type: 'image/jpg'
}]
});
nowPlayingDisplay.innerHTML = `EP ${parseInt(playerData.nowPlaying[1])}`
nowPlayingDisplay.innerHTML = `EP ${Number(playerData.nowPlaying[1])}`
if (parseInt(playerData.nowPlaying[1]) >= playerData.nowPlaying[0].episodes)
bnext.setAttribute("disabled", "")
if (playerData.nowPlaying[0].streamingEpisodes.length >= parseInt(playerData.nowPlaying[1])) {
let streamingEpisode = playerData.nowPlaying[0].streamingEpisodes.filter(episode => episodeRx.exec(episode.title) && episodeRx.exec(episode.title)[1] == parseInt(playerData.nowPlaying[1]))[0]
if (playerData.nowPlaying[0].streamingEpisodes.length >= Number(playerData.nowPlaying[1])) {
let streamingEpisode = playerData.nowPlaying[0].streamingEpisodes.filter(episode => episodeRx.exec(episode.title) && episodeRx.exec(episode.title)[1] == Number(playerData.nowPlaying[1]))[0]
video.poster = streamingEpisode.thumbnail
mediaMetadata.artist = `Episode ${parseInt(playerData.nowPlaying[1])} - ${episodeRx.exec(streamingEpisode.title)[2]}`
document.title = `${playerData.nowPlaying[0].title.userPreferred} - ${Number(playerData.nowPlaying[1])} - EP ${episodeRx.exec(streamingEpisode.title)[2]} - Miru`
mediaMetadata.artist = `Episode ${Number(playerData.nowPlaying[1])} - ${episodeRx.exec(streamingEpisode.title)[2]}`
mediaMetadata.artwork = [{
src: streamingEpisode.thumbnail,
sizes: '256x256',
type: 'image/jpg'
}]
nowPlayingDisplay.innerHTML = `EP ${parseInt(playerData.nowPlaying[1])} - ${episodeRx.exec(streamingEpisode.title)[2]}`
nowPlayingDisplay.innerHTML = `EP ${Number(playerData.nowPlaying[1])} - ${episodeRx.exec(streamingEpisode.title)[2]}`
} else {
document.title = `${playerData.nowPlaying[0].title.userPreferred} - EP ${Number(playerData.nowPlaying[1])} - Miru`
}
}
if ('mediaSession' in navigator && mediaMetadata) navigator.mediaSession.metadata = mediaMetadata

View file

@ -1,5 +1,5 @@
const settingsElements = [
volume, player2, player3, player5, player6, player8, player10, subtitle1, subtitle3, torrent1, torrent2, torrent3, torrent4, torrent5, torrent6, torrent9, other2, other3
volume, player2, player3, player5, player6, player8, player10, subtitle1, subtitle3, torrent1, torrent2, torrent3, torrent4, torrent5, torrent6, torrent9, other1, other2
]
setRes.addEventListener("click", restoreDefaults)
settingsTab.addEventListener("click", applySettingsTimeout)
@ -25,7 +25,7 @@ function saveSettings() {
function renderSettings() {
Object.entries(settings).forEach(setting => {
let settingElement = settingsElements.filter(e => e.id == setting[0])[0]
settingElement.type == "checkbox" ? settingElement.checked = setting[1] : settingElement.value = setting[1]
if (settingElement) settingElement.type == "checkbox" ? settingElement.checked = setting[1] : settingElement.value = setting[1]
})
}
function registerProtocol() {
@ -50,8 +50,8 @@ clearRelCache.onclick = () => {
}
renderSettings()
other3.onclick = () => {
Notification.requestPermission().then(perm => perm == "denied" ? other3.checked = false : "")
other1.onclick = () => {
Notification.requestPermission().then(perm => perm == "denied" ? other1.checked = false : "")
}
let searchParams = new URLSearchParams(location.href)