From 1dd08046d84029f76178cc985015e82a4be3986a Mon Sep 17 00:00:00 2001 From: ThaUnknown <6506529+ThaUnknown@users.noreply.github.com> Date: Fri, 14 Jul 2023 18:22:30 +0200 Subject: [PATCH] feat: new better RSS View --- package.json | 2 +- src/renderer/css.css | 7 +- src/renderer/modules/providers/tosho.js | 21 ++- src/renderer/views/RSSView.svelte | 131 ++++++++++++++---- src/renderer/views/Search.svelte | 2 +- src/renderer/views/ViewAnime/ViewAnime.svelte | 2 +- 6 files changed, 129 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index 7a7a8a7..755317b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Miru", - "version": "4.1.14", + "version": "4.1.15", "author": "ThaUnknown_ ", "description": "Stream anime torrents, real-time with no waiting for downloads.", "main": "build/main.js", diff --git a/src/renderer/css.css b/src/renderer/css.css index 444edb9..23e9eb7 100644 --- a/src/renderer/css.css +++ b/src/renderer/css.css @@ -21,8 +21,11 @@ --gray-color-light: hsl(var(--gray-color-light-hsl)); --gray-color-light-hsl: var(--gray-color-base-hue), 10%, 28%; --gray-color-base-hue: 216; - --secondary-color: #fff; - --secondary-color-light: #ddd; +} + +.btn-secondary { + --dm-button-secondary-bg-color: #fff !important; + --dm-button-secondary-bg-color-hover: #ddd !important; } .material-symbols-outlined { diff --git a/src/renderer/modules/providers/tosho.js b/src/renderer/modules/providers/tosho.js index 38dedf6..6cacdd5 100644 --- a/src/renderer/modules/providers/tosho.js +++ b/src/renderer/modules/providers/tosho.js @@ -3,6 +3,7 @@ import { fastPrettyBytes } from '../util.js' import { exclusions } from '../rss.js' import { set } from '@/views/Settings.svelte' import { alRequest } from '../anilist.js' +import anitomyscript from 'anitomyscript' export default async function tosho ({ media, episode }) { const json = await getAniDBFromAL(media) @@ -17,7 +18,13 @@ export default async function tosho ({ media, episode }) { if (!entries.length && !movie) entries = await getToshoEntries(media, aniDBEpisode, json) - return mapBestRelease(mapTosho2dDeDupedEntry(entries)) + const mapped = mapBestRelease(mapTosho2dDeDupedEntry(entries)) + + const parseObjects = await anitomyscript(mapped.map(({ title }) => title)) + + for (const i in parseObjects) mapped[i].parseObject = parseObjects[i] + + return mapped } window.tosho = tosho @@ -100,7 +107,7 @@ async function getToshoEntries (media, episode, { mappings }, quality) { // look for batches and movies const movie = isMovie(media) if (mappings.anidb_id && media.status === 'FINISHED' && (movie || media.episodes !== 1)) { - promises.push(fetchBatches({ episodeCount: media.episodes, id: mappings.anidb_id, quality })) + promises.push(fetchBatches({ episodeCount: media.episodes, id: mappings.anidb_id, quality, movie })) console.log('fetching batch', quality, movie) if (!movie) { const courRelation = getSplitCourRelation(media) @@ -204,12 +211,17 @@ function buildQuery (quality) { return query } -async function fetchBatches ({ episodeCount, id, quality }) { +async function fetchBatches ({ episodeCount, id, quality, movie }) { const queryString = buildQuery(quality) const torrents = await fetch(set.toshoURL + 'json?order=size-d&aid=' + id + queryString) // safe if AL includes EP 0 or doesn't const batches = (await torrents.json()).filter(entry => entry.num_files >= episodeCount) + if (!movie) { + for (const batch of batches) { + batch.batch = true + } + } console.log({ batches }) return batches } @@ -234,6 +246,7 @@ function mapTosho2dDeDupedEntry (entries) { dupe.leechers ||= entry.leechers >= 100000 ? 0 : entry.leechers dupe.downloads ||= entry.torrent_downloaded_count dupe.size ||= entry.total_size && fastPrettyBytes(entry.total_size) + dupe.verified ||= !!entry.anidb_fid dupe.date ||= entry.timestamp && new Date(entry.timestamp * 1000) } else { deduped[entry.info_hash] = { @@ -244,6 +257,8 @@ function mapTosho2dDeDupedEntry (entries) { leechers: entry.leechers >= 100000 ? 0 : entry.leechers, downloads: entry.torrent_downloaded_count, size: entry.total_size && fastPrettyBytes(entry.total_size), + verified: !!entry.anidb_fid, + batch: entry.batch, date: entry.timestamp && new Date(entry.timestamp * 1000) } } diff --git a/src/renderer/views/RSSView.svelte b/src/renderer/views/RSSView.svelte index 3660065..ba9fc43 100644 --- a/src/renderer/views/RSSView.svelte +++ b/src/renderer/views/RSSView.svelte @@ -71,37 +71,111 @@ } let modal $: table && modal?.focus() + const termMapping = { + 5.1: '5.1', + '5.1CH': '5.1', + 'TRUEHD5.1': 'TrueHD 5.1', + AAC: 'AAC', + AACX2: 'AAC', + AACX3: 'AAC', + AACX4: 'AAC', + AC3: 'AC3', + EAC3: 'EAC3', + 'E-AC-3': 'EAC3', + FLAC: 'FLAC', + FLACX2: 'FLAC', + FLACX3: 'FLAC', + FLACX4: 'FLAC', + VORBIS: 'Vorbis', + DUALAUDIO: 'Dual Audio', + 'Dual Audio': 'Dual Audio', + '10BIT': '10 Bit', + '10BITS': '10 Bit', + '10-BIT': '10 Bit', + '10-BITS': '10 Bit', + HI10: '10 Bit', + HI10P: '10 Bit', + HI444: 'HI444', + HI444P: 'HI444', + HI444PP: 'HI444', + H265: 'HEVC', + 'H.265': 'HEVC', + X265: 'HEVC', + HEVC: 'HEVC', + AV1: 'AV1' + } + function sanitiseTerms ({ video_term: video, audio_term: audio, video_resolution: resolution }) { + if (!Array.isArray(video)) video = [video] + if (!Array.isArray(audio)) audio = [audio] + + const terms = [] + + if (resolution) terms.push({ text: resolution, color: '#c6ec58' }) + for (const text of audio) { + if (termMapping[text]) terms.push({ text: termMapping[text], color: '#f67255' }) + } + for (const text of video) { + if (termMapping[text]) terms.push({ text: termMapping[text], color: '#0c8ce9' }) + } + + return terms + }