feat: add timestamps to cards and RSS feeds

This commit is contained in:
ThaUnknown 2023-04-25 21:22:51 +02:00
parent 7b3045d973
commit 5a687c0cd5
7 changed files with 40 additions and 9 deletions

View file

@ -23,6 +23,9 @@ One of four reasons:
- your ISP blocks Nyaa, see [this tutorial](https://thewiki.moe/en/tutorials/unblock) for a fix
- the app couldn't find a matching torrent for the anime
## **I selected an episode to play, but Miru plays something else!**
Finding desired episodes can sometimes be difficult, if Miru auto-selects an episode incorrectly you can either disable auto-play torrents in settings to select torrents yourself during episode choosing, or manually find and paste in a .torrent file URL or a magnet URL into Miru to play a desired episode manually.
## **Will you make an android version?**
No. This app cannot be ported to android in any way.

View file

@ -1,6 +1,6 @@
{
"name": "Miru",
"version": "3.9.10",
"version": "3.10.0",
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
"description": "Stream anime torrents, real-time with no waiting for downloads.",
"main": "src/index.js",
@ -111,7 +111,7 @@
"discord-rpc": "4.0.1",
"electron-log": "^4.4.8",
"electron-updater": "^4.6.5",
"jassub": "1.5.12",
"jassub": "1.5.13",
"js-levenshtein": "^1.1.6",
"matroska-subtitles": "github:ThaUnknown/matroska-subtitles#redist",
"mime": "^3.0.0",

View file

@ -12,7 +12,7 @@ specifiers:
electron-log: ^4.4.8
electron-notarize: ^1.2.2
electron-updater: ^4.6.5
jassub: 1.5.12
jassub: 1.5.13
js-levenshtein: ^1.1.6
matroska-subtitles: github:ThaUnknown/matroska-subtitles#redist
mime: ^3.0.0
@ -36,7 +36,7 @@ dependencies:
discord-rpc: 4.0.1
electron-log: 4.4.8
electron-updater: 4.6.5
jassub: 1.5.12
jassub: 1.5.13
js-levenshtein: 1.1.6
matroska-subtitles: github.com/ThaUnknown/matroska-subtitles/6241556509536ff09ba2ea3f050ceb7a3f12190a
mime: 3.0.0
@ -1873,8 +1873,8 @@ packages:
minimatch: 3.1.2
dev: true
/jassub/1.5.12:
resolution: {integrity: sha512-CJiuNCXMMGqfmVVlaDyxqaKfOy3RIHW4HBwVWvbq8pl/d1/y1fgTarfR31whUUupHZCe7Tfq8XB7WDgdu6IHaA==}
/jassub/1.5.13:
resolution: {integrity: sha512-mQM88BcYgppvpPG6VE+DPQm7r6QS65EBedbm13RE4lRIhdrnQ+ihWhBOZXYZe3SlGhg+ROIDRK8uY4dm9ER2XQ==}
dependencies:
rvfc-polyfill: 1.0.4
dev: false

View file

@ -1,5 +1,5 @@
<script>
import { countdown, wrapEnter } from '@/modules/util.js'
import { countdown, since, wrapEnter } from '@/modules/util.js'
import { getContext } from 'svelte'
export let cards = new Promise(() => {})
const view = getContext('view')
@ -74,6 +74,11 @@
{'EP ' + card.media.nextAiringEpisode.episode + ' in ' + countdown(card.media.nextAiringEpisode.timeUntilAiring)}
</span>
{/if}
{#if card.date}
<span class='text-muted font-weight-bold'>
{since(card.date)}
</span>
{/if}
<p class='text-muted m-0 text-capitalize details'>
<span class='text-nowrap'>
{#if card.media.format === 'TV'}

View file

@ -39,6 +39,7 @@
hasNext = items.length === limit
const media = await resolveFileMedia(items.map(item => item.querySelector('title').textContent))
media.forEach((mediaInformation, index) => {
mediaInformation.date = new Date(items[index].querySelector('pubDate').textContent)
mediaInformation.onclick = () => {
add(items[index].querySelector('link').textContent)
}
@ -290,7 +291,7 @@
const newData = await self.load(1, 6, false, false)
if (newData) self.previewData = newData
}, 15000)
self.previewData = await self.load(1, 6, false, false)
self.previewData = await self.load(1, 6, false, true)
}
return self.previewData
}

View file

@ -1,5 +1,5 @@
<script context='module'>
import { DOMPARSER, wrapEnter } from '@/modules/util.js'
import { DOMPARSER, wrapEnter, since } from '@/modules/util.js'
import { set } from './Settings.svelte'
import { addToast } from './Toasts.svelte'
import { alRequest } from '@/modules/anilist.js'
@ -321,6 +321,7 @@
<th scope='col'>Seed</th>
<th scope='col'>Leech</th>
<th scope='col'>Downloads</th>
<th scope='col'>Released</th>
<th scope='col'>Play</th>
</tr>
</thead>
@ -333,6 +334,7 @@
<td>{row.seeders}</td>
<td>{row.leechers}</td>
<td>{row.downloads}</td>
<td>{since(row.date)}</td>
<td class='material-icons font-size-20'>play_arrow</td>
</tr>
{/each}

View file

@ -12,6 +12,26 @@ export function countdown (s) {
return tmp.join(' ')
}
export function since (date) {
const formatter = new Intl.RelativeTimeFormat('en')
const ranges = {
years: 3600 * 24 * 365,
months: 3600 * 24 * 30,
weeks: 3600 * 24 * 7,
days: 3600 * 24,
hours: 3600,
minutes: 60,
seconds: 1
}
const secondsElapsed = (date.getTime() - Date.now()) / 1000
for (const key in ranges) {
if (ranges[key] < Math.abs(secondsElapsed)) {
const delta = secondsElapsed / ranges[key]
return formatter.format(Math.round(delta), key)
}
}
}
const units = [' B', ' kB', ' MB', ' GB', ' TB']
export function fastPrettyBytes (num) {
if (isNaN(num)) return '0 B'