mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-21 09:21:58 +00:00
fixes for video nowplaying data and AL complete
This commit is contained in:
parent
1a09a7995f
commit
b7ecac692b
3 changed files with 21 additions and 38 deletions
|
|
@ -261,9 +261,9 @@ query ($page: Int, $perPage: Int, $from: Int, $to: Int) {
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
async function alEntry () {
|
async function alEntry () {
|
||||||
if (playerData.nowPlaying && playerData.nowPlaying[0] && localStorage.getItem('ALtoken')) {
|
if (client.nowPlaying.media && localStorage.getItem('ALtoken')) {
|
||||||
const res = await alRequest({ method: 'SearchIDStatus', id: playerData.nowPlaying[0].id })
|
const res = await alRequest({ method: 'SearchIDStatus', id: client.nowPlaying.media.id })
|
||||||
if ((res.errors && res.errors[0].status === 404) || res.data.MediaList.progress <= parseInt(playerData.nowPlaying[1])) {
|
if ((res.errors && res.errors[0].status === 404) || res.data.MediaList.progress <= client.nowPlaying.episodeNumber) {
|
||||||
const query = `
|
const query = `
|
||||||
mutation ($id: Int, $status: MediaListStatus, $episode: Int, $repeat: Int) {
|
mutation ($id: Int, $status: MediaListStatus, $episode: Int, $repeat: Int) {
|
||||||
SaveMediaListEntry (mediaId: $id, status: $status, progress: $episode, repeat: $repeat) {
|
SaveMediaListEntry (mediaId: $id, status: $status, progress: $episode, repeat: $repeat) {
|
||||||
|
|
@ -275,11 +275,11 @@ mutation ($id: Int, $status: MediaListStatus, $episode: Int, $repeat: Int) {
|
||||||
}`
|
}`
|
||||||
const variables = {
|
const variables = {
|
||||||
repeat: 0,
|
repeat: 0,
|
||||||
id: playerData.nowPlaying[0].id,
|
id: client.nowPlaying.media.id,
|
||||||
status: 'CURRENT',
|
status: 'CURRENT',
|
||||||
episode: parseInt(playerData.nowPlaying[1])
|
episode: client.nowPlaying.episodeNumber
|
||||||
}
|
}
|
||||||
if (parseInt(playerData.nowPlaying[1]) === playerData.nowPlaying[0].episodes) {
|
if (client.nowPlaying.episodeNumber === client.nowPlaying.media.episodes) {
|
||||||
variables.status = 'COMPLETED'
|
variables.status = 'COMPLETED'
|
||||||
if (res.data.MediaList.status === 'COMPLETED') {
|
if (res.data.MediaList.status === 'COMPLETED') {
|
||||||
variables.repeat = res.data.MediaList.repeat + 1
|
variables.repeat = res.data.MediaList.repeat + 1
|
||||||
|
|
@ -614,8 +614,6 @@ async function resolveFileMedia (opts) {
|
||||||
res = await alRequest(method)
|
res = await alRequest(method)
|
||||||
}
|
}
|
||||||
if (res.data.Page.media[0]) store[elems.anime_title] = res.data.Page.media[0]
|
if (res.data.Page.media[0]) store[elems.anime_title] = res.data.Page.media[0]
|
||||||
} else {
|
|
||||||
store[elems.anime_title] = await alRequest({ id: store[elems.anime_title].id, method: 'SearchIDSingle' }).then(res => res.data.Media)
|
|
||||||
}
|
}
|
||||||
let episode; let media = store[elems.anime_title]
|
let episode; let media = store[elems.anime_title]
|
||||||
// resolve episode, if movie, dont.
|
// resolve episode, if movie, dont.
|
||||||
|
|
@ -721,7 +719,7 @@ async function releasesCards (items, frag, limit) {
|
||||||
results.forEach((mediaInformation, index) => {
|
results.forEach((mediaInformation, index) => {
|
||||||
const o = items[index].querySelector.bind(items[index])
|
const o = items[index].querySelector.bind(items[index])
|
||||||
template = cardCreator(mediaInformation)
|
template = cardCreator(mediaInformation)
|
||||||
template.onclick = () => client.addTorrent(o('link').innerHTML, { media: mediaInformation.media, episode: mediaInformation.episode })
|
template.onclick = () => client.addTorrent(o('link').innerHTML, { media: mediaInformation, episode: mediaInformation.episode })
|
||||||
frag.appendChild(template)
|
frag.appendChild(template)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ async function loadHomePage () {
|
||||||
})
|
})
|
||||||
notification.onclick = async () => {
|
notification.onclick = async () => {
|
||||||
window.parent.focus()
|
window.parent.focus()
|
||||||
client.addTorrent(doc.querySelector('item').querySelector('link').innerHTML, { media: mediaInformation.media, episode: mediaInformation.episode })
|
client.addTorrent(doc.querySelector('item').querySelector('link').innerHTML, { media: mediaInformation, episode: mediaInformation.episode })
|
||||||
store[mediaInformation.parseObject.anime_title] = await alRequest({ id: mediaInformation.media.id, method: 'SearchIDSingle' }).then(res => res.data.Media)
|
store[mediaInformation.parseObject.anime_title] = await alRequest({ id: mediaInformation.media.id, method: 'SearchIDSingle' }).then(res => res.data.Media)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ Style: Default,${options.defaultSSAStyles || 'Roboto Medium,26,&H00FFFFFF,&H0000
|
||||||
navigator.mediaSession.setActionHandler('seekforward', () => this.seek(seekTime))
|
navigator.mediaSession.setActionHandler('seekforward', () => this.seek(seekTime))
|
||||||
navigator.mediaSession.setActionHandler('nexttrack', () => this.playNext())
|
navigator.mediaSession.setActionHandler('nexttrack', () => this.playNext())
|
||||||
}
|
}
|
||||||
if ('setPositionState' in navigator.mediaSession) video.addEventListener('timeupdate', () => this.updatePositionState())
|
if ('setPositionState' in navigator.mediaSession) this.video.addEventListener('timeupdate', () => this.updatePositionState())
|
||||||
|
|
||||||
this.videoExtensions = ['.3g2', '.3gp', '.asf', '.avi', '.dv', '.flv', '.gxf', '.m2ts', '.m4a', '.m4b', '.m4p', '.m4r', '.m4v', '.mkv', '.mov', '.mp4', '.mpd', '.mpeg', '.mpg', '.mxf', '.nut', '.ogm', '.ogv', '.swf', '.ts', '.vob', '.webm', '.wmv', '.wtv']
|
this.videoExtensions = ['.3g2', '.3gp', '.asf', '.avi', '.dv', '.flv', '.gxf', '.m2ts', '.m4a', '.m4b', '.m4p', '.m4r', '.m4v', '.mkv', '.mov', '.mp4', '.mpd', '.mpeg', '.mpg', '.mxf', '.nut', '.ogm', '.ogv', '.swf', '.ts', '.vob', '.webm', '.wmv', '.wtv']
|
||||||
this.videoFiles = undefined
|
this.videoFiles = undefined
|
||||||
|
|
@ -355,16 +355,6 @@ Style: Default,${options.defaultSSAStyles || 'Roboto Medium,26,&H00FFFFFF,&H0000
|
||||||
this.controls.nowPlaying.textContent = 'EP ' + episodeInfo
|
this.controls.nowPlaying.textContent = 'EP ' + episodeInfo
|
||||||
document.title = [this.nowPlaying.mediaTitle, episodeInfo ? 'EP ' + episodeInfo : false, this.nowPlaying.name || 'TorrentPlayer'].filter(s => s).join(' - ')
|
document.title = [this.nowPlaying.mediaTitle, episodeInfo ? 'EP ' + episodeInfo : false, this.nowPlaying.name || 'TorrentPlayer'].filter(s => s).join(' - ')
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (opts.media && this.videoFiles.length === 1) {
|
|
||||||
// // if this is a single file, then the media is most likely accurate, just update it!
|
|
||||||
// this.nowPlaying = [await alRequest({ id: opts.media.id, method: 'SearchIDSingle' }).then(res => res.data.Media), opts.episode || 1]
|
|
||||||
// // update store with entry, but dont really do anything with it
|
|
||||||
// resolveFileMedia({ fileName: this.currentFile.name, method: 'SearchName' })
|
|
||||||
// } else {
|
|
||||||
// // if this is a batch or single unresolved file, then resolve the single selected file, batches can include specials
|
|
||||||
// const mediaInformation = await resolveFileMedia({ fileName: this.currentFile.name, method: 'SearchName' })
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanupVideo () { // cleans up objects, attemps to clear as much video caching as possible
|
cleanupVideo () { // cleans up objects, attemps to clear as much video caching as possible
|
||||||
|
|
@ -381,12 +371,7 @@ Style: Default,${options.defaultSSAStyles || 'Roboto Medium,26,&H00FFFFFF,&H0000
|
||||||
this.onDone = undefined
|
this.onDone = undefined
|
||||||
document.title = 'Miru'
|
document.title = 'Miru'
|
||||||
this.setProgress(0)
|
this.setProgress(0)
|
||||||
// if (typeof client !== 'undefined' && client.torrents[0] && client.torrents[0].files.length > 1) {
|
// look for file and delete its store, idk how to do this
|
||||||
// client.torrents[0].files.forEach(file => file.deselect());
|
|
||||||
// client.torrents[0].deselect(0, client.torrents[0].pieces.length - 1, false);
|
|
||||||
// console.log(videoFiles.filter(file => `${scope}webtorrent/${client.torrents[0].infoHash}/${encodeURI(file.path)}` == video.src))
|
|
||||||
// look for file and delete its store
|
|
||||||
// }
|
|
||||||
this.subtitleData = {
|
this.subtitleData = {
|
||||||
fonts: [],
|
fonts: [],
|
||||||
headers: [],
|
headers: [],
|
||||||
|
|
@ -471,11 +456,11 @@ Style: Default,${options.defaultSSAStyles || 'Roboto Medium,26,&H00FFFFFF,&H0000
|
||||||
playNext () {
|
playNext () {
|
||||||
clearTimeout(this.nextTimeout)
|
clearTimeout(this.nextTimeout)
|
||||||
this.nextTimeout = setTimeout(() => {
|
this.nextTimeout = setTimeout(() => {
|
||||||
if (this.videoFiles?.length > 1 && this.videoFiles.indexOf(this.currentFile) < this.videoFiles.length) {
|
if (this.videoFiles?.indexOf(this.currentFile) < this.videoFiles?.length) {
|
||||||
const fileIndex = this.videoFiles.indexOf(this.currentFile) + 1
|
const nowPlaying = this.nowPlaying
|
||||||
const nowPlaying = [this.nowPlaying[0], parseInt(this.nowPlaying[1]) + 1] // TODO: fix
|
nowPlaying.episodeNumber += 1
|
||||||
this.cleanupVideo()
|
this.cleanupVideo()
|
||||||
this.buildVideo(this.videoFiles[fileIndex], nowPlaying) // TODO: fix
|
this.buildVideo(this.currentTorrent, { media: nowPlaying, file: this.videoFiles[this.videoFiles.indexOf(this.currentFile) + 1] })
|
||||||
} else {
|
} else {
|
||||||
if (this.onNext) this.onNext()
|
if (this.onNext) this.onNext()
|
||||||
}
|
}
|
||||||
|
|
@ -590,10 +575,9 @@ Style: Default,${options.defaultSSAStyles || 'Roboto Medium,26,&H00FFFFFF,&H0000
|
||||||
}
|
}
|
||||||
|
|
||||||
checkCompletion () {
|
checkCompletion () {
|
||||||
if (!this.completed && video.duration - 180 < video.currentTime) {
|
if (!this.completed && this.video.duration - 180 < this.video.currentTime) {
|
||||||
this.onWatched()
|
|
||||||
} else {
|
|
||||||
this.completed = true
|
this.completed = true
|
||||||
|
this.onWatched()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1019,11 +1003,12 @@ const client = new TorrentPlayer({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onWatched: () => { // TODO: fix
|
onWatched: () => { // TODO: fix
|
||||||
if (settings.other2 && !(!(playerData.nowPlaying[0].episodes || playerData.nowPlaying[0].nextAiringEpisode.episode) && playerData.nowPlaying[0].streamingEpisodes.length && parseInt(playerData.nowPlaying[1] > 12))) {
|
console.log('ran')
|
||||||
|
if (settings.other2 && (client.nowPlaying.media?.episodes || client.nowPlaying.media?.nextAiringEpisode?.episode)) {
|
||||||
alEntry()
|
alEntry()
|
||||||
} else {
|
} else {
|
||||||
halfmoon.initStickyAlert({
|
halfmoon.initStickyAlert({
|
||||||
content: `Do You Want To Mark <br><b>${playerData.nowPlaying[0].title.userPreferred}</b><br>Episode ${playerData.nowPlaying[1]} As Completed?<br>
|
content: `Do You Want To Mark <br><b>${client.nowPlaying.mediaTitle}</b><br>Episode ${client.nowPlaying.episodeNumber} As Completed?<br>
|
||||||
<button class="btn btn-sm btn-square btn-success mt-5" onclick="alEntry()" data-dismiss="alert" type="button" aria-label="Close">✓</button>
|
<button class="btn btn-sm btn-square btn-success mt-5" onclick="alEntry()" data-dismiss="alert" type="button" aria-label="Close">✓</button>
|
||||||
<button class="btn btn-sm btn-square mt-5" data-dismiss="alert" type="button" aria-label="Close"><span aria-hidden="true">X</span></button>`,
|
<button class="btn btn-sm btn-square mt-5" data-dismiss="alert" type="button" aria-label="Close"><span aria-hidden="true">X</span></button>`,
|
||||||
title: 'Episode Complete',
|
title: 'Episode Complete',
|
||||||
|
|
@ -1035,8 +1020,8 @@ const client = new TorrentPlayer({
|
||||||
window.location.hash = '#playlist'
|
window.location.hash = '#playlist'
|
||||||
},
|
},
|
||||||
onNext: () => {
|
onNext: () => {
|
||||||
if (playerData.nowPlaying[0]) {
|
if (client.nowPlaying.media) {
|
||||||
nyaaSearch(playerData.nowPlaying[0], parseInt(playerData.nowPlaying[1]) + 1)
|
nyaaSearch(client.nowPlaying.media, client.nowPlaying.episodeNumber)
|
||||||
} else {
|
} else {
|
||||||
halfmoon.initStickyAlert({
|
halfmoon.initStickyAlert({
|
||||||
content: 'Couldn\'t find anime name! Try specifying a torrent manually.',
|
content: 'Couldn\'t find anime name! Try specifying a torrent manually.',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue