mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-13 11:50:24 +00:00
use relations for anime name resolving
This commit is contained in:
parent
9f7efce30e
commit
aba08797df
4 changed files with 21 additions and 17 deletions
|
|
@ -237,7 +237,7 @@
|
|||
</span>
|
||||
</div>
|
||||
</section>
|
||||
<section id="home" class="flex-column overflow-y-auto">
|
||||
<section id="home" class="flex-column overflow-y-scroll">
|
||||
<div class="h-full py-10">
|
||||
<div class="container-fluid row p-20" id="searchWrapper">
|
||||
<div class="col-lg col-3 p-10 d-flex flex-column justify-content-end">
|
||||
|
|
|
|||
|
|
@ -206,7 +206,6 @@ query ($id: Int, $mediaId: Int){
|
|||
date.setHours(0, 0, 0, 0)
|
||||
variables.from = date.getTime() / 1000
|
||||
variables.to = (date.getTime() + 7 * 24 * 60 * 60 * 1000) / 1000
|
||||
console.log(variables)
|
||||
query = `
|
||||
query ($page: Int, $perPage: Int, $from: Int, $to: Int) {
|
||||
Page (page: $page, perPage: $perPage) {
|
||||
|
|
@ -377,9 +376,9 @@ function viewAnime (media) {
|
|||
viewRelationsGallery.classList.add('d-none')
|
||||
}
|
||||
viewSynonym.onclick = () => {
|
||||
store[viewSynonymText.value] = media
|
||||
relations[viewSynonymText.value] = media.id
|
||||
viewSynonymText.value = ''
|
||||
localStorage.setItem('store', JSON.stringify(store))
|
||||
localStorage.setItem('relations', JSON.stringify(relations))
|
||||
}
|
||||
episodes.innerHTML = ''
|
||||
if (media.streamingEpisodes.length) {
|
||||
|
|
@ -519,7 +518,7 @@ async function resolveFileMedia (opts) {
|
|||
// opts.fileName opts.method opts.isRelease
|
||||
|
||||
const elems = await anitomyscript(opts.fileName)
|
||||
if (!store[elems.anime_title]) {
|
||||
if (!relations[elems.anime_title]) {
|
||||
// resolve name and shit
|
||||
let method, res
|
||||
if (opts.isRelease) {
|
||||
|
|
@ -535,9 +534,15 @@ async function resolveFileMedia (opts) {
|
|||
method.status = undefined
|
||||
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]) {
|
||||
relations[elems.anime_title] = res.data.Page.media[0].id
|
||||
store[res.data.Page.media[0].id] = res.data.Page.media[0]
|
||||
}
|
||||
}
|
||||
let episode; let media = store[elems.anime_title]
|
||||
if (!store[relations[elems.anime_title]] && relations[elems.anime_title]) {
|
||||
store[relations[elems.anime_title]] = (await alRequest({ method: 'SearchIDSingle', id: relations[elems.anime_title] })).data.Media
|
||||
}
|
||||
let episode; let media = store[relations[elems.anime_title]]
|
||||
// resolve episode, if movie, dont.
|
||||
if ((media?.format !== 'MOVIE' || (media.episodes || media.nextAiringEpisode.episode)) && elems.episode_number) {
|
||||
async function resolveSeason (opts) {
|
||||
|
|
@ -620,8 +625,8 @@ async function resolveFileMedia (opts) {
|
|||
}
|
||||
}
|
||||
|
||||
let store = JSON.parse(localStorage.getItem('store')) || {}
|
||||
store = store || {}
|
||||
const store = {}
|
||||
const relations = JSON.parse(localStorage.getItem('relations')) || {}
|
||||
|
||||
function getRSSurl () {
|
||||
if (Object.values(torrent4list.options).filter(item => item.value === settings.torrent4)[0]) {
|
||||
|
|
@ -645,7 +650,7 @@ async function releasesCards (items, limit) {
|
|||
cards.push(cardCreator(mediaInformation))
|
||||
})
|
||||
})
|
||||
localStorage.setItem('store', JSON.stringify(store))
|
||||
localStorage.setItem('relations', JSON.stringify(relations))
|
||||
return cards
|
||||
}
|
||||
async function releasesRss (limit) {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ async function loadHomePage () {
|
|||
notification.onclick = async () => {
|
||||
window.parent.focus()
|
||||
client.addTorrent(doc.querySelector('item').querySelector('link').textContent, { media: mediaInformation, episode: mediaInformation.episode })
|
||||
store[mediaInformation.parseObject.anime_title] = await alRequest({ id: mediaInformation.media.id, method: 'SearchIDSingle' }).then(res => res.data.Media)
|
||||
store[relations[mediaInformation.parseObject.anime_title]] = await alRequest({ id: mediaInformation.media.id, method: 'SearchIDSingle' }).then(res => res.data.Media)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -169,6 +169,7 @@ async function loadHomePage () {
|
|||
media = media.media
|
||||
}
|
||||
cards.push(cardCreator({ media: media, schedule: opts.schedule, onclick: () => viewAnime(media) }))
|
||||
store[media.id] = media
|
||||
})
|
||||
opts.gallery.append(...cards)
|
||||
canScroll = true
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ setRes.addEventListener('click', restoreDefaults)
|
|||
settingsTab.addEventListener('click', applySettingsTimeout)
|
||||
volume.addEventListener('click', applySettingsTimeout)
|
||||
regProtButton.addEventListener('click', registerProtocol)
|
||||
let settings = {}
|
||||
const settings = JSON.parse(localStorage.getItem('settings')) || {}
|
||||
function restoreDefaults () {
|
||||
localStorage.removeItem('settings')
|
||||
location.reload()
|
||||
|
|
@ -38,15 +38,13 @@ function registerProtocol () {
|
|||
}
|
||||
}
|
||||
|
||||
if (!localStorage.getItem('settings')) {
|
||||
if (!settings) {
|
||||
saveSettings()
|
||||
location.reload()
|
||||
} else {
|
||||
settings = JSON.parse(localStorage.getItem('settings'))
|
||||
}
|
||||
clearRelCache.onclick = () => {
|
||||
localStorage.removeItem('store')
|
||||
store = {}
|
||||
localStorage.removeItem('relations')
|
||||
relations = {}
|
||||
}
|
||||
renderSettings()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue