mirror of
https://github.com/NoCrypt/migu.git
synced 2026-04-21 00:22:08 +00:00
feat: resolve adult media
fix: episode list issues
This commit is contained in:
parent
9e96c21605
commit
9a339342aa
7 changed files with 28 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Miru",
|
"name": "Miru",
|
||||||
"version": "4.4.11",
|
"version": "4.4.12",
|
||||||
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
|
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
|
||||||
"description": "Stream anime torrents, real-time with no waiting for downloads.",
|
"description": "Stream anime torrents, real-time with no waiting for downloads.",
|
||||||
"main": "build/main.js",
|
"main": "build/main.js",
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ export default class {
|
||||||
this.discord.subscribe('ACTIVITY_JOIN')
|
this.discord.subscribe('ACTIVITY_JOIN')
|
||||||
this.discord.subscribe('ACTIVITY_SPECTATE')
|
this.discord.subscribe('ACTIVITY_SPECTATE')
|
||||||
})
|
})
|
||||||
this.discord.on('ACTIVITY_JOIN', (args) => {
|
this.discord.on('ACTIVITY_JOIN', ({ secret }) => {
|
||||||
this.window.webContents.send('w2glink', args.secret)
|
this.window.webContents.send('w2glink', secret)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.loginRPC()
|
this.loginRPC()
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ function createWindow () {
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
try {
|
try {
|
||||||
webtorrentWindow.webContents.postMessage('destroy', null)
|
webtorrentWindow.webContents.postMessage('destroy', null)
|
||||||
} catch(e) {}
|
} catch (e) {}
|
||||||
app.quit()
|
app.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -305,13 +305,14 @@ export async function alRequest (opts) {
|
||||||
switch (opts.method) {
|
switch (opts.method) {
|
||||||
case 'SearchName': {
|
case 'SearchName': {
|
||||||
variables.search = opts.name
|
variables.search = opts.name
|
||||||
|
variables.isAdult = variables.isAdult ?? false
|
||||||
query = /* js */`
|
query = /* js */`
|
||||||
query($page: Int, $perPage: Int, $sort: [MediaSort], $search: String, $status: [MediaStatus], $year: Int){
|
query($page: Int, $perPage: Int, $sort: [MediaSort], $search: String, $status: [MediaStatus], $year: Int, $isAdult: Boolean){
|
||||||
Page(page: $page, perPage: $perPage){
|
Page(page: $page, perPage: $perPage){
|
||||||
pageInfo{
|
pageInfo{
|
||||||
hasNextPage
|
hasNextPage
|
||||||
},
|
},
|
||||||
media(type: ANIME, search: $search, sort: $sort, status_in: $status, isAdult: false, format_not: MUSIC, seasonYear: $year){
|
media(type: ANIME, search: $search, sort: $sort, status_in: $status, isAdult: $isAdult, format_not: MUSIC, seasonYear: $year){
|
||||||
${queryObjects}
|
${queryObjects}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,11 @@ async function resolveTitle (parseObject) {
|
||||||
media = (await alSearch(method)).data.Page.media[0]
|
media = (await alSearch(method)).data.Page.media[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// check adult
|
||||||
|
if (!media) {
|
||||||
|
method.isAdult = true
|
||||||
|
media = (await alSearch(method)).data.Page.media[0]
|
||||||
|
}
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
|
|
||||||
if (media) relations[getRelationKey(parseObject)] = media
|
if (media) relations[getRelationKey(parseObject)] = media
|
||||||
|
|
|
||||||
|
|
@ -3,32 +3,38 @@
|
||||||
import { click } from '@/modules/click.js'
|
import { click } from '@/modules/click.js'
|
||||||
import { getEpisodeNumberByAirDate } from '@/modules/providers/tosho.js'
|
import { getEpisodeNumberByAirDate } from '@/modules/providers/tosho.js'
|
||||||
import { alRequest } from '@/modules/anilist'
|
import { alRequest } from '@/modules/anilist'
|
||||||
import { media } from '../Player/MediaHandler.svelte'
|
|
||||||
|
|
||||||
export let id
|
export let media
|
||||||
|
|
||||||
|
const id = media.id
|
||||||
|
|
||||||
|
const duration = media.duration
|
||||||
|
|
||||||
export let episodeCount
|
export let episodeCount
|
||||||
|
|
||||||
export let userProgress = 0
|
export let userProgress = 0
|
||||||
|
|
||||||
export let duration
|
|
||||||
|
|
||||||
export let play
|
export let play
|
||||||
|
|
||||||
const episodeList = Array.from({ length: episodeCount }, (_, i) => ({ episode: i + 1 }))
|
const episodeList = Array.from({ length: episodeCount }, (_, i) => ({
|
||||||
|
episode: i + 1, image: null, summary: null, rating: null, title: null, length: null, airdate: null, airingAt: null
|
||||||
|
}))
|
||||||
async function load () {
|
async function load () {
|
||||||
const episodesPromise = alRequest({ method: 'Episodes', id })
|
|
||||||
const res = await fetch('https://api.ani.zip/mappings?anilist_id=' + id)
|
const res = await fetch('https://api.ani.zip/mappings?anilist_id=' + id)
|
||||||
const { episodes, specialCount, episodeCount } = await res.json()
|
const { episodes, specialCount, episodeCount } = await res.json()
|
||||||
const settled = (await episodesPromise).data.Page?.airingSchedules
|
let alEpisodes = episodeList
|
||||||
const alEpisodes = settled?.length ? settled : episodeList
|
|
||||||
|
if (!(media.episodes && media.episodes === episodeCount && media.status === 'FINISHED')) {
|
||||||
|
const settled = (await alRequest({ method: 'Episodes', id })).data.Page?.airingSchedules
|
||||||
|
if (settled?.length) alEpisodes = settled
|
||||||
|
}
|
||||||
for (const { episode, airingAt } of alEpisodes) {
|
for (const { episode, airingAt } of alEpisodes) {
|
||||||
const alDate = new Date((airingAt || 0) * 1000)
|
const alDate = new Date((airingAt || 0) * 1000)
|
||||||
|
|
||||||
const needsValidation = !(!specialCount || (media.episodes && media.episodes === episodeCount && episodes[Number(episode)]))
|
const needsValidation = !(!specialCount || (media.episodes && media.episodes === episodeCount && episodes[Number(episode)]))
|
||||||
const { image, summary, rating, title, length, airdate } = needsValidation ? getEpisodeNumberByAirDate(alDate, episodes, episode) : (episodes[Number(episode)] || {})
|
const { image, summary, rating, title, length, airdate } = needsValidation ? getEpisodeNumberByAirDate(alDate, episodes, episode) : (episodes[Number(episode)] || {})
|
||||||
|
|
||||||
episodeList[episode - 1] = { episode, image, summary, rating, title, length: length || duration, airdate: +alDate || airdate }
|
episodeList[episode - 1] = { episode, image, summary, rating, title, length: length || duration, airdate: +alDate || airdate, airingAt: +alDate || airdate }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
load()
|
load()
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@
|
||||||
</ToggleList>
|
</ToggleList>
|
||||||
</div>
|
</div>
|
||||||
<div class='col-5 d-flex flex-column pl-20'>
|
<div class='col-5 d-flex flex-column pl-20'>
|
||||||
<EpisodeList id={media.id} userProgress={media.mediaListEntry && media.mediaListEntry.status === 'CURRENT' && media.mediaListEntry.progress} episodeCount={getMediaMaxEp(media)} duration={media.duration} {play} />
|
<EpisodeList {media} userProgress={media.mediaListEntry && media.mediaListEntry.status === 'CURRENT' && media.mediaListEntry.progress} episodeCount={getMediaMaxEp(media)} {play} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue