mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-21 03:22:13 +00:00
torrent stats
This commit is contained in:
parent
e86d9ef7d6
commit
4efedcbdaf
2 changed files with 34 additions and 3 deletions
|
|
@ -30,10 +30,11 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { alEntry } from '@/modules/anilist.js'
|
import { alEntry } from '@/modules/anilist.js'
|
||||||
|
import { client } from '@/modules/torrent.js'
|
||||||
import { resolveFileMedia } from '@/modules/anime.js'
|
import { resolveFileMedia } from '@/modules/anime.js'
|
||||||
import Peer from '@/modules/Peer.js'
|
import Peer from '@/modules/Peer.js'
|
||||||
import Subtitles from '@/modules/subtitles.js'
|
import Subtitles from '@/modules/subtitles.js'
|
||||||
import { toTS, videoRx } from '@/modules/util.js'
|
import { toTS, videoRx, fastPrettyBytes } from '@/modules/util.js'
|
||||||
import Keyboard from './Keyboard.svelte'
|
import Keyboard from './Keyboard.svelte'
|
||||||
|
|
||||||
async function mediaChange(current, image) {
|
async function mediaChange(current, image) {
|
||||||
|
|
@ -629,6 +630,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const torrent = {}
|
||||||
|
function updateStats() {
|
||||||
|
torrent.peers = (client?.torrents.length && client?.torrents[0].numPeers) || 0
|
||||||
|
torrent.up = (client?.torrents.length && client?.torrents[0].uploadSpeed) || 0
|
||||||
|
torrent.down = (client?.torrents.length && client?.torrents[0].downloadSpeed) || 0
|
||||||
|
}
|
||||||
|
setInterval(updateStats, 200)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:keydown={handleKeydown} bind:innerWidth bind:innerHeight />
|
<svelte:window on:keydown={handleKeydown} bind:innerWidth bind:innerHeight />
|
||||||
|
|
@ -691,7 +699,16 @@
|
||||||
Buffer health: {stats.buffer || 0}
|
Buffer health: {stats.buffer || 0}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="top z-40 d-flex flex-row-reverse">
|
<div class="top z-40 d-flex justify-content-between">
|
||||||
|
<div />
|
||||||
|
<div class="d-flex">
|
||||||
|
<span class="material-icons" data-name="peers"> people </span>
|
||||||
|
<span class="stats">{torrent.peers}</span>
|
||||||
|
<span class="material-icons"> arrow_downward </span>
|
||||||
|
<span class="stats">{fastPrettyBytes(torrent.up)}/s</span>
|
||||||
|
<span class="material-icons"> arrow_upward </span>
|
||||||
|
<span class="stats">{fastPrettyBytes(torrent.down)}/s</span>
|
||||||
|
</div>
|
||||||
<span class="material-icons ctrl font-size-12 p-10" title="Keybinds [`]" data-name="togglePopout" on:click={() => (showKeybinds = true)}> help_outline </span>
|
<span class="material-icons ctrl font-size-12 p-10" title="Keybinds [`]" data-name="togglePopout" on:click={() => (showKeybinds = true)}> help_outline </span>
|
||||||
</div>
|
</div>
|
||||||
<div class="middle d-flex align-items-center justify-content-center flex-grow-1 z-40 position-relative">
|
<div class="middle d-flex align-items-center justify-content-center flex-grow-1 z-40 position-relative">
|
||||||
|
|
@ -799,6 +816,13 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.stats {
|
||||||
|
font-size: 1.8rem !important;
|
||||||
|
white-space: nowrap;
|
||||||
|
align-self: center;
|
||||||
|
font-weight: 600;
|
||||||
|
font-family: Roboto, Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
.miniplayer {
|
.miniplayer {
|
||||||
transition: width 0.2s ease;
|
transition: width 0.2s ease;
|
||||||
width: 25vw !important;
|
width: 25vw !important;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,14 @@ export function countdown (s) {
|
||||||
if (d || h) tmp.push(h + 'h')
|
if (d || h) tmp.push(h + 'h')
|
||||||
if (d || h || m) tmp.push(m + 'm')
|
if (d || h || m) tmp.push(m + 'm')
|
||||||
return tmp.join(' ')
|
return tmp.join(' ')
|
||||||
|
}
|
||||||
|
|
||||||
|
const units = [' B', ' kB', ' MB', ' GB', ' TB']
|
||||||
|
export function fastPrettyBytes (num) {
|
||||||
|
if (isNaN(num)) return '0 B'
|
||||||
|
if (num < 1) return num + ' B'
|
||||||
|
const exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), units.length - 1)
|
||||||
|
return Number((num / Math.pow(1000, exponent)).toFixed(2)) + units[exponent]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DOMPARSER = DOMParser.prototype.parseFromString.bind(new DOMParser())
|
export const DOMPARSER = DOMParser.prototype.parseFromString.bind(new DOMParser())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue