mirror of
https://github.com/NoCrypt/migu.git
synced 2026-04-20 16:12:31 +00:00
feat: add airing schedule
This commit is contained in:
parent
574cc09860
commit
f763242755
9 changed files with 56 additions and 33 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Miru",
|
||||
"version": "0.6.4",
|
||||
"version": "0.8.0",
|
||||
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<img src="./logo.ico" alt="ico" />
|
||||
{document.title}
|
||||
</div>
|
||||
<div class="controls d-flex h-full">
|
||||
<div class="controls d-flex h-full pointer">
|
||||
<div class="d-flex align-items-center" on:click={() => window.minimize()}>
|
||||
<svg viewBox="0 0 24 24">
|
||||
<path d="M19 13H5v-2h14v2z" />
|
||||
|
|
|
|||
|
|
@ -1,26 +1,24 @@
|
|||
<script context='module'>
|
||||
<script context="module">
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
export const files = writable([])
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import { getContext } from 'svelte'
|
||||
import Home from './pages/home/Home.svelte'
|
||||
import Player from './pages/Player.svelte'
|
||||
import Settings from './pages/Settings.svelte'
|
||||
import Schedule from './pages/Schedule.svelte'
|
||||
export let page = 'home'
|
||||
const current = getContext('gallery')
|
||||
</script>
|
||||
|
||||
<div class="overflow-y-hidden content-wrapper">
|
||||
<Player files={$files} miniplayer={page !== 'player'} bind:page />
|
||||
{#if page === 'schedule'}
|
||||
<Schedule />
|
||||
{:else if page === 'settings'}
|
||||
{#if page === 'settings'}
|
||||
<Settings />
|
||||
{:else if page === 'home'}
|
||||
<Home />
|
||||
<Home bind:current={$current} />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -23,13 +23,14 @@
|
|||
icon: 'home',
|
||||
text: 'Home Page'
|
||||
},
|
||||
// {
|
||||
// click: () => {
|
||||
// page = 'schedule'
|
||||
// },
|
||||
// icon: 'schedule',
|
||||
// text: 'Airing Schedule'
|
||||
// },
|
||||
{
|
||||
click: () => {
|
||||
page = 'home'
|
||||
$gallery = 'schedule'
|
||||
},
|
||||
icon: 'schedule',
|
||||
text: 'Airing Schedule'
|
||||
},
|
||||
{
|
||||
click: () => {
|
||||
if (media) $view = media
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@
|
|||
{/each}
|
||||
{:then cards}
|
||||
{#each cards as card}
|
||||
{#if !card.media}
|
||||
{#if typeof card === 'string'}
|
||||
<div class="day-row font-size-24 font-weight-bold h-50 d-flex align-items-end">{card}</div>
|
||||
{:else if !card.media}
|
||||
<div class="card m-0 p-0" on:click={card.onclick}>
|
||||
<div class="row h-full">
|
||||
<div class="col-4 skeloader" />
|
||||
|
|
@ -155,4 +157,7 @@
|
|||
object-fit: cover;
|
||||
background-color: var(--color) !important;
|
||||
}
|
||||
.day-row {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -7,25 +7,19 @@
|
|||
import { alRequest } from '@/modules/anilist.js'
|
||||
import { resolveFileMedia, relations } from '@/modules/anime.js'
|
||||
import { getRSSContent, getRSSurl } from '@/lib/RSSView.svelte'
|
||||
import { getContext } from 'svelte'
|
||||
|
||||
let media = getContext('gallery')
|
||||
let media = null
|
||||
let search = {}
|
||||
let current = null
|
||||
export let current = null
|
||||
let page = 1
|
||||
|
||||
$: if (!$media) {
|
||||
current = null
|
||||
canScroll = true
|
||||
}
|
||||
|
||||
let canScroll = true
|
||||
let hasNext = true
|
||||
async function infiniteScroll() {
|
||||
if (current && canScroll && hasNext && this.scrollTop + this.clientHeight > this.scrollHeight - 800) {
|
||||
canScroll = false
|
||||
const res = await sections[current].load(++page)
|
||||
$media = $media.then(old => {
|
||||
media = media.then(old => {
|
||||
return old.concat(res)
|
||||
})
|
||||
canScroll = hasNext
|
||||
|
|
@ -36,13 +30,16 @@
|
|||
function load(current) {
|
||||
if (sections[current]) {
|
||||
page = 1
|
||||
$media = sections[current].load(1)
|
||||
media = sections[current].load(1)
|
||||
} else {
|
||||
$media = null
|
||||
media = null
|
||||
canScroll = true
|
||||
lastDate = null
|
||||
}
|
||||
}
|
||||
|
||||
let lastDate = null
|
||||
|
||||
function processMedia(res) {
|
||||
hasNext = res.data.Page.pageInfo.hasNextPage
|
||||
return res.data.Page.media.map(media => {
|
||||
|
|
@ -120,7 +117,28 @@
|
|||
return alRequest({ method: 'Search', page, perPage, genre: 'Action', sort: 'TRENDING_DESC' }).then(res => processMedia(res))
|
||||
}
|
||||
},
|
||||
schedule: {
|
||||
title: 'Schedule',
|
||||
hide: true,
|
||||
load: (page = 1) => {
|
||||
return alRequest({ method: 'AiringSchedule', page }).then(res => {
|
||||
const entries = res.data.Page.airingSchedules.filter(entry => entry.media.countryOfOrigin !== 'CN' && !entry.media.isAdult)
|
||||
const media = []
|
||||
hasNext = res.data.Page.pageInfo.hasNextPage
|
||||
let date = new Date()
|
||||
for (const entry of entries) {
|
||||
if (entry.timeUntilAiring && (!lastDate || new Date(+date + entry.timeUntilAiring * 1000).getDay() !== lastDate.getDay())) {
|
||||
lastDate = new Date(+date + entry.timeUntilAiring * 1000)
|
||||
media.push(lastDate.toLocaleDateString('en-US', { weekday: 'long' }))
|
||||
}
|
||||
media.push(entry)
|
||||
}
|
||||
return media
|
||||
})
|
||||
}
|
||||
},
|
||||
search: {
|
||||
title: 'Search',
|
||||
hide: true,
|
||||
load: (page = 1, perPage = 50) => {
|
||||
const opts = {
|
||||
|
|
@ -139,9 +157,9 @@
|
|||
|
||||
<div class="d-flex h-full flex-column overflow-y-scroll root" on:scroll={infiniteScroll}>
|
||||
<div class="h-full py-10">
|
||||
<Search bind:media={$media} bind:search bind:current />
|
||||
{#if $media}
|
||||
<Gallery media={$media} />
|
||||
<Search bind:media bind:search bind:current />
|
||||
{#if media}
|
||||
<Gallery {media} />
|
||||
{:else}
|
||||
<div>
|
||||
{#each Object.entries(sections) as [key, opts] (opts.title)}
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ query ($page: Int, $perPage: Int, $from: Int, $to: Int) {
|
|||
episode,
|
||||
timeUntilAiring,
|
||||
airingAt,
|
||||
media(isAdult: false){
|
||||
media{
|
||||
${queryObjects}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ export async function add (torrentID) {
|
|||
files.set([])
|
||||
page.set('player')
|
||||
if (typeof torrentID === 'string' && !torrentID.startsWith('magnet:')) {
|
||||
// IMPORTANT, this is because node's get bypasses proxies, wut????
|
||||
const res = await fetch(torrentID)
|
||||
torrentID = new File([await res.arrayBuffer()], 'file.torrent', {
|
||||
type: 'application/x-bittorrent'
|
||||
|
|
|
|||
Loading…
Reference in a new issue