mirror of
https://github.com/NoCrypt/migu.git
synced 2026-03-11 17:45:32 +00:00
feat: streamed download
This commit is contained in:
parent
d44ae0dce8
commit
5f67d3c109
6 changed files with 47 additions and 46 deletions
|
|
@ -134,6 +134,7 @@ export const defaults = {
|
|||
torrentDHT: false,
|
||||
torrentPeX: false,
|
||||
torrentPort: 0,
|
||||
torrentStreamedDownload: true,
|
||||
dhtPort: 0,
|
||||
missingFont: true,
|
||||
maxConns: 50,
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ import { SUPPORTS } from './support.js'
|
|||
// HACK: this is https only, but electron doesnt run in https, weirdge
|
||||
if (!globalThis.FileSystemFileHandle) globalThis.FileSystemFileHandle = false
|
||||
|
||||
const LARGE_FILESIZE = 32_000_000_000
|
||||
|
||||
const announce = [
|
||||
atob('d3NzOi8vdHJhY2tlci5vcGVud2VidG9ycmVudC5jb20='),
|
||||
atob('d3NzOi8vdHJhY2tlci53ZWJ0b3JyZW50LmRldg=='),
|
||||
|
|
@ -142,19 +140,9 @@ export default class TorrentClient extends WebTorrent {
|
|||
url: this.serverMode === 'node' ? 'http://localhost:' + this.server.address().port + file.streamURL : file.streamURL
|
||||
}
|
||||
})
|
||||
if (torrent.length > LARGE_FILESIZE) {
|
||||
for (const file of torrent.files) {
|
||||
file.deselect()
|
||||
}
|
||||
this.dispatch('warn', 'Detected Large Torrent! To Conserve Drive Space Files Will Be Downloaded Selectively Instead Of Downloading The Entire Torrent.')
|
||||
}
|
||||
this.dispatch('files', files)
|
||||
this.dispatch('magnet', { magnet: torrent.magnetURI, hash: torrent.infoHash })
|
||||
localStorage.setItem('torrent', JSON.stringify([...torrent.torrentFile])) // this won't work on mobile, but really it only speeds stuff up by ~1-2 seconds since magnet data doesn't need to be resolved
|
||||
|
||||
if (torrent.length > await this.storageQuota(torrent.path)) {
|
||||
this.dispatchError('Torrent Too Big! This Torrent Exceeds The Selected Drive\'s Available Space. Change Download Location In Torrent Settings To A Drive With More Space And Restart The App!')
|
||||
}
|
||||
}
|
||||
|
||||
async findFontFiles (targetFile) {
|
||||
|
|
@ -243,7 +231,8 @@ export default class TorrentClient extends WebTorrent {
|
|||
path: this.torrentPath || undefined,
|
||||
destroyStoreOnDestroy: !this.settings.torrentPersist,
|
||||
skipVerify,
|
||||
announce
|
||||
announce,
|
||||
deselect: this.settings.torrentStreamedDownload
|
||||
})
|
||||
|
||||
torrent.once('done', () => {
|
||||
|
|
@ -256,7 +245,8 @@ export default class TorrentClient extends WebTorrent {
|
|||
case 'current': {
|
||||
if (data.data) {
|
||||
const torrent = await this.get(data.data.current.infoHash)
|
||||
const found = torrent?.files.find(file => file.path === data.data.current.path)
|
||||
if (!torrent) return
|
||||
const found = torrent.files.find(file => file.path === data.data.current.path)
|
||||
if (!found) return
|
||||
if (this.playerProcess) {
|
||||
this.playerProcess.kill()
|
||||
|
|
@ -264,9 +254,13 @@ export default class TorrentClient extends WebTorrent {
|
|||
}
|
||||
if (this.current) {
|
||||
this.current.removeAllListeners('stream')
|
||||
this.current.deselect()
|
||||
}
|
||||
this.parser?.destroy()
|
||||
found.select()
|
||||
if (found.length > await this.storageQuota(torrent.path)) {
|
||||
this.dispatchError('File Too Big! This File Exceeds The Selected Drive\'s Available Space. Change Download Location In Torrent Settings To A Drive With More Space And Restart The App!')
|
||||
}
|
||||
this.current = found
|
||||
if (data.data.external && this.player) {
|
||||
this.playerProcess = spawn(this.player, [encodeURI('http://localhost:' + this.server.address().port + found.streamURL)])
|
||||
|
|
|
|||
|
|
@ -159,6 +159,12 @@
|
|||
</div>
|
||||
</SettingCard>
|
||||
{/if}
|
||||
<SettingCard title='Streamed Download' description="Only downloads the single file that's currently being watched, instead of downloading an entire batch of episodes. Saves bandwidth and reduces strain on the peer swarm.">
|
||||
<div class='custom-switch'>
|
||||
<input type='checkbox' id='torrent-streamed-download' bind:checked={settings.torrentStreamedDownload} />
|
||||
<label for='torrent-streamed-download'>{settings.torrentStreamedDownload ? 'On' : 'Off'}</label>
|
||||
</div>
|
||||
</SettingCard>
|
||||
<SettingCard title='Transfer Speed Limit' description='Download/Upload speed limit for torrents, higher values increase CPU usage, and values higher than your storage write speeds will quickly fill up RAM.'>
|
||||
<div class='input-group w-100 mw-full'>
|
||||
<input type='number' inputmode='numeric' pattern={'[0-9]*.?[0-9]*'} bind:value={settings.torrentSpeed} min='0' max='50' step='0.1' class='form-control text-right bg-dark' />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Menu, app } from 'electron'
|
||||
import { app } from 'electron'
|
||||
import App from './app.js'
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
|
|
@ -9,7 +9,7 @@ function createWindow () {
|
|||
main = new App()
|
||||
}
|
||||
|
||||
Menu.setApplicationMenu(null) // performance
|
||||
// Menu.setApplicationMenu(null) // performance, but no keyboard shortcuts, sucks
|
||||
app.on('ready', createWindow)
|
||||
|
||||
app.on('activate', () => {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
"webpack": "^5.91.0",
|
||||
"webpack-cli": "^5.1.4",
|
||||
"webpack-dev-server": "^5.0.2",
|
||||
"webtorrent": "^2.4.1"
|
||||
"webtorrent": "^2.4.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/workers-types": "^4.20240222.0",
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ importers:
|
|||
specifier: ^5.0.2
|
||||
version: 5.0.2(webpack-cli@5.1.4)(webpack@5.91.0)
|
||||
webtorrent:
|
||||
specifier: ^2.4.1
|
||||
version: 2.4.1
|
||||
specifier: ^2.4.11
|
||||
version: 2.4.11
|
||||
devDependencies:
|
||||
'@cloudflare/workers-types':
|
||||
specifier: ^4.20240222.0
|
||||
|
|
@ -1274,19 +1274,19 @@ packages:
|
|||
resolution: {integrity: sha512-flrfEMbSwwdhu+5wVsMgX0tGG+njCtAQ4jnA7ywjLNhSil/KirlzN34q3l0lKCnitFJgp1vOoHNCgkkkMWQ85Q==}
|
||||
dev: false
|
||||
|
||||
/@thaunknown/idb-chunk-store@1.0.2:
|
||||
resolution: {integrity: sha512-UdKshbKdHDP+p0XPdv55QiU/scdB9TzvovGFSgXThf+7Yd3noLeYp6KpkYyc1jzUXvI3/8+TemPeASOimrOXvw==}
|
||||
/@thaunknown/idb-chunk-store@1.0.4:
|
||||
resolution: {integrity: sha512-4/XDQZHKHyJCGeqnVjHyqeAXClZJ9l90rRvoTslUiuvwTGAUpIb3poL0LfGJEdSuWV+zzGdDjIm/3L4x6crwbg==}
|
||||
dependencies:
|
||||
idb: 6.1.5
|
||||
idb: 7.1.1
|
||||
queue-microtask: 1.2.3
|
||||
dev: false
|
||||
|
||||
/@thaunknown/simple-peer@10.0.7:
|
||||
resolution: {integrity: sha512-b4oPNaJEWk9UT/ADV8IFWcAyow+gOPLa73SptuOqm6IdMDr4zlsqGsdl4LQmvgMKMgWAOHdVViw/RYF5qYvkCg==}
|
||||
/@thaunknown/simple-peer@10.0.9:
|
||||
resolution: {integrity: sha512-oS+iZWrMp/kd0pygyCAoZYYWoZCshKbjFLRuyRH58zYJ/Yyjzksgwj1g+m6wHY7pznl2+cKXttuLDD9Td4QXWA==}
|
||||
dependencies:
|
||||
debug: 4.3.5
|
||||
err-code: 3.0.1
|
||||
streamx: 2.16.1
|
||||
streamx: 2.18.0
|
||||
uint8-util: 2.2.5
|
||||
webrtc-polyfill: 1.1.6
|
||||
transitivePeerDependencies:
|
||||
|
|
@ -2419,15 +2419,15 @@ packages:
|
|||
resolution: {integrity: sha512-VyLcUjVMEOdSpHaCG/7odvCdLbAB1y3l9A2V6WIje24uV7FkJPrQrH/RrlFmKxP89pFVDEnE+YlHaFujlFIZsg==}
|
||||
dev: false
|
||||
|
||||
/bittorrent-protocol@4.1.12:
|
||||
resolution: {integrity: sha512-peyUDP5NQaiPSau24jCpPhLfDFCCK1DUE0N5xlJSPVIkgQmsVLi62N/Lm++pUNrBenfnhf6WKQo0nyN6x5dufQ==}
|
||||
/bittorrent-protocol@4.1.13:
|
||||
resolution: {integrity: sha512-tUF8HBy/CwexDgEiFmmgWx7RCXC02gc72ZEoFxdRnqraZBUVFN611hYLfB/zArlhFeaUErfJZOa8CWtrDeXQsA==}
|
||||
engines: {node: '>=12.20.0'}
|
||||
dependencies:
|
||||
bencode: 4.0.0
|
||||
bitfield: 4.2.0
|
||||
debug: 4.3.5
|
||||
rc4: 0.1.5
|
||||
streamx: 2.16.1
|
||||
streamx: 2.18.0
|
||||
throughput: 1.0.1
|
||||
uint8-util: 2.2.5
|
||||
unordered-array-remove: 1.0.2
|
||||
|
|
@ -2474,7 +2474,7 @@ packages:
|
|||
engines: {node: '>=16.0.0'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@thaunknown/simple-peer': 10.0.7
|
||||
'@thaunknown/simple-peer': 10.0.9
|
||||
'@thaunknown/simple-websocket': 9.1.1(bufferutil@4.0.8)(utf-8-validate@6.0.4)
|
||||
bencode: 4.0.0
|
||||
bittorrent-peerid: 1.3.6
|
||||
|
|
@ -5388,10 +5388,10 @@ packages:
|
|||
resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==}
|
||||
engines: {node: '>=10.17.0'}
|
||||
|
||||
/hybrid-chunk-store@1.2.4:
|
||||
resolution: {integrity: sha512-wLVIU7rDAz0bQ9sOVwqNWV44A+yAitm+yw66vilkIhZ7V1lVQtiZBQ98YF4vr8rmbqnysgW+pW/PZ1UQtnQCCA==}
|
||||
/hybrid-chunk-store@1.2.6:
|
||||
resolution: {integrity: sha512-D8DkY6FT+exjw4b6uQ8z5QfUokcIb0YYPHaa/zpBdFIoS1CS7mjM4wnd2mGoo2XUeM5Y10C23AXOQRExoifPbA==}
|
||||
dependencies:
|
||||
'@thaunknown/idb-chunk-store': 1.0.2
|
||||
'@thaunknown/idb-chunk-store': 1.0.4
|
||||
cache-chunk-store: 3.2.2
|
||||
fsa-chunk-store: 1.1.5
|
||||
memory-chunk-store: 1.3.5
|
||||
|
|
@ -5434,8 +5434,8 @@ packages:
|
|||
postcss: 8.4.38
|
||||
dev: false
|
||||
|
||||
/idb@6.1.5:
|
||||
resolution: {integrity: sha512-IJtugpKkiVXQn5Y+LteyBCNk1N8xpGV3wWZk9EVtZWH8DYkjBn0bX1XnGP9RkyZF0sAcywa6unHqSWKe7q4LGw==}
|
||||
/idb@7.1.1:
|
||||
resolution: {integrity: sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ==}
|
||||
dev: false
|
||||
|
||||
/ieee754@1.2.1:
|
||||
|
|
@ -6957,8 +6957,8 @@ packages:
|
|||
lines-and-columns: 1.2.4
|
||||
dev: true
|
||||
|
||||
/parse-torrent@11.0.16:
|
||||
resolution: {integrity: sha512-5GoOdmW0HpiB78aQpBz8/5V3V1LjBRDNiL7DOs33pKeCLOzFnfMrsRD6CYmaUBT5Vi/dXE0hfePsjDGJSMF48w==}
|
||||
/parse-torrent@11.0.17:
|
||||
resolution: {integrity: sha512-bkfEtrqIMT4+bSWs+m7+Ktd7LSJsDefA9qfJQ3UFwOeBqipiQ+347guu79zX++nRwMnrdvRecLmgaRcdiYjE4w==}
|
||||
engines: {node: '>=12.20.0'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
|
|
@ -8168,7 +8168,7 @@ packages:
|
|||
resolution: {integrity: sha512-Ax+TbUOho84bWUc3AKqWtkIvAIVws7d6QI4oJkgH4yQ5Yil+lR3vjd/7qd51dHKGzS5bFxg0++QwyNRN7s6rZA==}
|
||||
dependencies:
|
||||
limiter: 1.1.5
|
||||
streamx: 2.16.1
|
||||
streamx: 2.18.0
|
||||
dev: false
|
||||
|
||||
/split2@3.2.2:
|
||||
|
|
@ -8223,8 +8223,8 @@ packages:
|
|||
engines: {node: '>= 0.10.0'}
|
||||
dev: true
|
||||
|
||||
/streamx@2.16.1:
|
||||
resolution: {integrity: sha512-m9QYj6WygWyWa3H1YY69amr4nVgy61xfjys7xO7kviL5rfIEc2naf+ewFiOA+aEJD7y0JO3h2GoiUv4TDwEGzQ==}
|
||||
/streamx@2.17.0:
|
||||
resolution: {integrity: sha512-mzRXEeafEA0skX5XLiDht/zdIqEVs4kgayUTFHDoMjiaZ2kC7DoFsQDJVXRILI2Qme/kWXxLpuU6P0B+xcXpFA==}
|
||||
dependencies:
|
||||
fast-fifo: 1.3.2
|
||||
queue-tick: 1.0.1
|
||||
|
|
@ -9538,17 +9538,17 @@ packages:
|
|||
resolution: {integrity: sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==}
|
||||
engines: {node: '>=0.8.0'}
|
||||
|
||||
/webtorrent@2.4.1:
|
||||
resolution: {integrity: sha512-9/WTMFaAAbfopNQiGK5rD7ZJJTdPwOrl/T6izTWVEk56+cJdtZBz9FelMnwnS4Q7rqFKoEYuonzi+ig0nXjYsA==}
|
||||
/webtorrent@2.4.11:
|
||||
resolution: {integrity: sha512-aRq8gJTm7JGuGgBggitv+o5QZ8vGS64un3Sx3MPl9eBPbhDRKyYKouPUh4NIJqNAPvUBIOGu6nB1IOjcJ5wUhw==}
|
||||
engines: {node: '>=16'}
|
||||
dependencies:
|
||||
'@silentbot1/nat-api': 0.4.7
|
||||
'@thaunknown/simple-peer': 10.0.7
|
||||
'@thaunknown/simple-peer': 10.0.9
|
||||
'@webtorrent/http-node': 1.3.0
|
||||
addr-to-ip-port: 2.0.0
|
||||
bitfield: 4.2.0
|
||||
bittorrent-dht: 11.0.6
|
||||
bittorrent-protocol: 4.1.12
|
||||
bittorrent-protocol: 4.1.13
|
||||
cache-chunk-store: 3.2.2
|
||||
chunk-store-iterator: 1.0.3
|
||||
cpus: 1.0.3
|
||||
|
|
@ -9557,7 +9557,7 @@ packages:
|
|||
debug: 4.3.5
|
||||
escape-html: 1.0.3
|
||||
fs-chunk-store: 4.1.0
|
||||
hybrid-chunk-store: 1.2.4
|
||||
hybrid-chunk-store: 1.2.6
|
||||
immediate-chunk-store: 2.2.0
|
||||
join-async-iterator: 1.1.1
|
||||
load-ip-set: 3.0.1
|
||||
|
|
@ -9565,7 +9565,7 @@ packages:
|
|||
memory-chunk-store: 1.3.5
|
||||
mime: 3.0.0
|
||||
once: 1.4.0
|
||||
parse-torrent: 11.0.16
|
||||
parse-torrent: 11.0.17
|
||||
pump: 3.0.0
|
||||
queue-microtask: 1.2.3
|
||||
random-iterate: 1.0.1
|
||||
|
|
@ -9573,7 +9573,7 @@ packages:
|
|||
run-parallel: 1.2.0
|
||||
run-parallel-limit: 1.1.0
|
||||
speed-limiter: 1.0.2
|
||||
streamx: 2.16.1
|
||||
streamx: 2.17.0
|
||||
throughput: 1.0.1
|
||||
torrent-discovery: 11.0.6
|
||||
torrent-piece: 3.0.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue