mirror of
https://github.com/leoherzog/TorrentParts.git
synced 2026-01-24 04:08:04 -08:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4af414e16 | ||
|
|
d22fdf219c | ||
|
|
d60f8ffcf1 | ||
|
|
0c5f522459 | ||
|
|
f81243896c | ||
|
|
41f408d828 | ||
|
|
e17b51276b | ||
|
|
c54f496dcc | ||
|
|
2e584fe04f | ||
|
|
307af881ad | ||
|
|
09f885238e | ||
|
|
fdcf397f64 | ||
|
|
6d6f53d288 | ||
|
|
b477e9c8c9 | ||
|
|
1ad87324d2 | ||
|
|
418cb0c6b7 | ||
|
|
2d908ecf02 | ||
|
|
a1296b456d |
48
README.md
48
README.md
@@ -24,7 +24,6 @@ This project wouldn't be possible without the fantastic work of:
|
|||||||
- [@feross](https://github.com/feross) and contributors, for [`parse-torrent`](https://github.com/webtorrent/parse-torrent) and [`WebTorrent`](https://github.com/webtorrent/webtorrent)
|
- [@feross](https://github.com/feross) and contributors, for [`parse-torrent`](https://github.com/webtorrent/parse-torrent) and [`WebTorrent`](https://github.com/webtorrent/webtorrent)
|
||||||
- [@cvisuri](https://github.com/cvisuri), for design work
|
- [@cvisuri](https://github.com/cvisuri), for design work
|
||||||
- [@CorralPeltzer](https://github.com/CorralPeltzer), for [`newTrackon`](https://github.com/CorralPeltzer/newTrackon)
|
- [@CorralPeltzer](https://github.com/CorralPeltzer), for [`newTrackon`](https://github.com/CorralPeltzer/newTrackon)
|
||||||
- [@substack](https://github.com/substack) and contributors, for [`Browserify`](https://github.com/browserify/browserify)
|
|
||||||
- [Cloudflare Pages](https://pages.cloudflare.com/) hosting
|
- [Cloudflare Pages](https://pages.cloudflare.com/) hosting
|
||||||
|
|
||||||
## License
|
## License
|
||||||
@@ -42,24 +41,53 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|||||||
## About Me
|
## About Me
|
||||||
|
|
||||||
<a href="https://herzog.tech/" target="_blank">
|
<a href="https://herzog.tech/" target="_blank">
|
||||||
<img src="https://herzog.tech/signature/link.svg.png" width="32px" />
|
<picture>
|
||||||
|
<source media="(prefers-color-scheme: dark)" srcset="https://herzog.tech/signature/link-light.svg.png">
|
||||||
|
<source media="(prefers-color-scheme: light)" srcset="https://herzog.tech/signature/link.svg.png">
|
||||||
|
<img src="https://herzog.tech/signature/link.svg.png" width="32px">
|
||||||
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://twitter.com/xd1936" target="_blank">
|
<a href="https://mastodon.social/@herzog" target="_blank">
|
||||||
<img src="https://herzog.tech/signature/twitter.svg.png" width="32px" />
|
<picture>
|
||||||
|
<source media="(prefers-color-scheme: dark)" srcset="https://herzog.tech/signature/mastodon-light.svg.png">
|
||||||
|
<source media="(prefers-color-scheme: light)" srcset="https://herzog.tech/signature/mastodon.svg.png">
|
||||||
|
<img src="https://herzog.tech/signature/mastodon.svg.png" width="32px">
|
||||||
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/leoherzog" target="_blank">
|
<a href="https://github.com/leoherzog" target="_blank">
|
||||||
<img src="https://herzog.tech/signature/github.svg.png" width="32px" />
|
<picture>
|
||||||
|
<source media="(prefers-color-scheme: dark)" srcset="https://herzog.tech/signature/github-light.svg.png">
|
||||||
|
<source media="(prefers-color-scheme: light)" srcset="https://herzog.tech/signature/github.svg.png">
|
||||||
|
<img src="https://herzog.tech/signature/github.svg.png" width="32px">
|
||||||
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://keybase.io/leoherzog" target="_blank">
|
<a href="https://keybase.io/leoherzog" target="_blank">
|
||||||
<img src="https://herzog.tech/signature/keybase.svg.png" width="32px" />
|
<picture>
|
||||||
|
<source media="(prefers-color-scheme: dark)" srcset="https://herzog.tech/signature/keybase-light.svg.png">
|
||||||
|
<source media="(prefers-color-scheme: light)" srcset="https://herzog.tech/signature/keybase.svg.png">
|
||||||
|
<img src="https://herzog.tech/signature/keybase.svg.png" width="32px">
|
||||||
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://www.linkedin.com/in/leoherzog" target="_blank">
|
<a href="https://www.linkedin.com/in/leoherzog" target="_blank">
|
||||||
<img src="https://herzog.tech/signature/linkedin.svg.png" width="32px" />
|
<picture>
|
||||||
|
<source media="(prefers-color-scheme: dark)" srcset="https://herzog.tech/signature/linkedin-light.svg.png">
|
||||||
|
<source media="(prefers-color-scheme: light)" srcset="https://herzog.tech/signature/linkedin.svg.png">
|
||||||
|
<img src="https://herzog.tech/signature/linkedin.svg.png" width="32px">
|
||||||
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://hope.edu/directory/people/herzog-leo/" target="_blank">
|
<a href="https://hope.edu/directory/people/herzog-leo/" target="_blank">
|
||||||
<img src="https://herzog.tech/signature/anchor.svg.png" width="32px" />
|
<picture>
|
||||||
|
<source media="(prefers-color-scheme: dark)" srcset="https://herzog.tech/signature/anchor-light.svg.png">
|
||||||
|
<source media="(prefers-color-scheme: light)" srcset="https://herzog.tech/signature/anchor.svg.png">
|
||||||
|
<img src="https://herzog.tech/signature/anchor.svg.png" width="32px">
|
||||||
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
<br />
|
<br />
|
||||||
<a href="https://www.buymeacoffee.com/leoherzog" target="_blank">
|
<a href="https://herzog.tech/$" target="_blank">
|
||||||
<img src="https://cdn.buymeacoffee.com/buttons/lato-black.png" alt="Buy Me A Coffee" width="217px" />
|
<picture>
|
||||||
|
<source media="(prefers-color-scheme: dark)" srcset="https://herzog.tech/signature/mug-tea-saucer-solid-light.svg.png">
|
||||||
|
<source media="(prefers-color-scheme: light)" srcset="https://herzog.tech/signature/mug-tea-saucer-solid.svg.png">
|
||||||
|
<img src="https://herzog.tech/signature/mug-tea-saucer-solid.svg.png" alt="Buy Me A Tea" width="32px">
|
||||||
|
</picture>
|
||||||
|
Found this helpful? Buy me a tea!
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
63058
bin/bundle.js
63058
bin/bundle.js
File diff suppressed because one or more lines are too long
108
bin/bundle.min.js
vendored
108
bin/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
BIN
ext/alata-v9-latin-regular.ttf
Normal file
BIN
ext/alata-v9-latin-regular.ttf
Normal file
Binary file not shown.
BIN
ext/alata-v9-latin-regular.woff2
Normal file
BIN
ext/alata-v9-latin-regular.woff2
Normal file
Binary file not shown.
2
ext/notyf.min.js
vendored
2
ext/notyf.min.js
vendored
File diff suppressed because one or more lines are too long
16
index.html
16
index.html
@@ -36,12 +36,12 @@
|
|||||||
|
|
||||||
<title>Torrent Parts | Inspect and edit what's in your Torrent file or Magnet link</title>
|
<title>Torrent Parts | Inspect and edit what's in your Torrent file or Magnet link</title>
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/tippy.js@6/dist/tippy.css" rel="stylesheet" />
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/tippy.js@6/animations/shift-away-subtle.css" rel="stylesheet" />
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.css" rel="stylesheet" />
|
||||||
<link href="/src/style.css" rel="stylesheet" />
|
<link href="/src/style.css" rel="stylesheet" />
|
||||||
<link href="/ext/alata-latin-400.woff2" rel="preload" as="style">
|
|
||||||
<link href="/ext/alata-latin-400.woff" rel="preload" as="style">
|
|
||||||
<script async src="/ext/fa.min.js"></script>
|
<script async src="/ext/fa.min.js"></script>
|
||||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||||
<script src="/ext/notyf.min.js"></script>
|
|
||||||
|
|
||||||
<script async defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "6f97f49b4c384ee197a2f319cebec274"}'></script>
|
<script async defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "6f97f49b4c384ee197a2f319cebec274"}'></script>
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
<header>
|
<header>
|
||||||
<h1 id="logo">Torrent<span id="originalSourceIcon"><span class="fad fa-magnet fa-fw" aria-hidden="true"></span></span>Parts</h1>
|
<h1 id="logo">Torrent<span id="originalSourceIcon"><span class="fad fa-magnet fa-fw" aria-hidden="true"></span></span>Parts</h1>
|
||||||
<a class="github-button" href="https://github.com/leoherzog/TorrentParts" data-icon="octicon-star" data-show-count="true" aria-label="Star leoherzog/TorrentParts on GitHub">Star</a>
|
<a class="github-button" href="https://github.com/leoherzog/TorrentParts" data-icon="octicon-star" data-show-count="true" aria-label="Star TorrentParts on GitHub">Star</a>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div id="startButtons">
|
<div id="startButtons">
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<input id="name" type="text" placeholder="Unnamed" />
|
<input id="name" type="text" placeholder="Unnamed" dir="auto" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<input id="comment" type="text" placeholder="Not included in the URL/File provided" />
|
<input id="comment" type="text" placeholder="Not included in the URL/File provided" dir="auto" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -216,10 +216,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<a href="https://github.com/leoherzog/TorrentParts/releases" target="_blank" rel="noopener">v1.2</a>
|
<a href="https://github.com/leoherzog/TorrentParts/releases" target="_blank" rel="noopener">v2.0.1</a>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="/bin/bundle.min.js"></script>
|
<script type="module" src="/src/parse.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
|
|||||||
42
package.json
42
package.json
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "torrentparts",
|
|
||||||
"version": "1.2",
|
|
||||||
"description": "📑 A website to inspect and edit Torrent files and Magnet URLs",
|
|
||||||
"main": "bin/bundle.js",
|
|
||||||
"dependencies": {
|
|
||||||
"browserify": "^17.0.0",
|
|
||||||
"bytes": "^3.1.2",
|
|
||||||
"clipboard": "^2.0.10",
|
|
||||||
"magnet-uri": "^6.2.0",
|
|
||||||
"mime-types": "^2.1.35",
|
|
||||||
"parse-torrent": "^9.1.4",
|
|
||||||
"tippy.js": "^6.3.7",
|
|
||||||
"webtorrent": "^1.8.6"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"buffer": "^6.0.3",
|
|
||||||
"notyf": "^3.10.0",
|
|
||||||
"terser": "^5.12.1",
|
|
||||||
"watchify": "^4.0.0"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"watch": "watchify src/parse.js -o bin/bundle.js",
|
|
||||||
"compile": "browserify src/parse.js -o bin/bundle.js",
|
|
||||||
"minify": "terser bin/bundle.js -c -m -o bin/bundle.min.js",
|
|
||||||
"build": "npm run compile && npm run minify",
|
|
||||||
"update": "npm update -g && npm update && npm run build"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/leoherzog/TorrentParts.git"
|
|
||||||
},
|
|
||||||
"glitch": {
|
|
||||||
"projectType": "generated_static"
|
|
||||||
},
|
|
||||||
"author": "Leo Herzog",
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/leoherzog/TorrentParts/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/leoherzog/TorrentParts"
|
|
||||||
}
|
|
||||||
155
src/parse.js
155
src/parse.js
@@ -1,10 +1,11 @@
|
|||||||
require('buffer');
|
import { Buffer } from 'https://cdn.jsdelivr.net/npm/buffer@6/+esm';
|
||||||
const clipboard = require('clipboard');
|
import clipboard from 'https://cdn.jsdelivr.net/npm/clipboard@2/+esm';
|
||||||
const parser = require('parse-torrent');
|
import parseTorrent, { toMagnetURI, toTorrentFile, remote as parseTorrentRemote } from 'https://cdn.jsdelivr.net/npm/parse-torrent@11/+esm';
|
||||||
const bytes = require('bytes');
|
import bytes from 'https://cdn.jsdelivr.net/npm/bytes@3/+esm';
|
||||||
const mime = require('mime-types');
|
import mime from 'https://cdn.jsdelivr.net/npm/mime-types@2/+esm';
|
||||||
const WebTorrent = require('webtorrent');
|
import WebTorrent from 'https://cdn.jsdelivr.net/npm/webtorrent@2/dist/webtorrent.min.js';
|
||||||
const tippy = require('tippy.js').default;
|
import tippy from 'https://cdn.jsdelivr.net/npm/tippy.js@6/+esm';
|
||||||
|
import { Notyf } from 'https://cdn.jsdelivr.net/npm/notyf@3/+esm';
|
||||||
|
|
||||||
var examples = document.getElementById('examples');
|
var examples = document.getElementById('examples');
|
||||||
var example1 = document.getElementById('example1');
|
var example1 = document.getElementById('example1');
|
||||||
@@ -13,7 +14,7 @@ var example3 = document.getElementById('example3');
|
|||||||
var properties = document.getElementById('properties');
|
var properties = document.getElementById('properties');
|
||||||
var originalSourceIcon = document.getElementById('originalSourceIcon');
|
var originalSourceIcon = document.getElementById('originalSourceIcon');
|
||||||
var source;
|
var source;
|
||||||
var sourceTooltip = tippy(originalSourceIcon, {"theme": "torrent-parts", "animation": "shift-away-subtle"});
|
var sourceTooltip = tippy(originalSourceIcon, { theme: 'torrent-parts', animation: 'shift-away-subtle' });
|
||||||
var name = document.getElementById('name');
|
var name = document.getElementById('name');
|
||||||
var reset = document.getElementById('reset');
|
var reset = document.getElementById('reset');
|
||||||
var created = document.getElementById('created');
|
var created = document.getElementById('created');
|
||||||
@@ -36,45 +37,45 @@ var copyURL = document.getElementById('copyURL');
|
|||||||
var copyMagnet = document.getElementById('copyMagnet');
|
var copyMagnet = document.getElementById('copyMagnet');
|
||||||
var downloadTorrentWrapper = document.getElementById('downloadTorrentWrapper');
|
var downloadTorrentWrapper = document.getElementById('downloadTorrentWrapper');
|
||||||
var downloadTorrent = document.getElementById('downloadTorrent');
|
var downloadTorrent = document.getElementById('downloadTorrent');
|
||||||
var openURLTooltip = tippy(openURL, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Open this Magnet URL in your Torrent client"});
|
var openURLTooltip = tippy(openURL, { theme: 'torrent-parts', animation: 'shift-away-subtle', content: 'Open this Magnet URL in your Torrent client' });
|
||||||
var copyURLTooltip = tippy(copyURL, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Copy torrent.parts link to clipboard"});
|
var copyURLTooltip = tippy(copyURL, { theme: 'torrent-parts', animation: 'shift-away-subtle', content: 'Copy torrent.parts link to clipboard' });
|
||||||
var copyMagnetTooltip = tippy(copyMagnet, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Copy Magnet link to clipboard"});
|
var copyMagnetTooltip = tippy(copyMagnet, { theme: 'torrent-parts', animation: 'shift-away-subtle', content: 'Copy Magnet link to clipboard' });
|
||||||
var downloadTorrentTooltip = tippy(downloadTorrentWrapper, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Download Torrent file"});
|
var downloadTorrentTooltip = tippy(downloadTorrentWrapper, { theme: 'torrent-parts', animation: 'shift-away-subtle', content: 'Download Torrent file' });
|
||||||
var parsed;
|
var parsed;
|
||||||
var client = new WebTorrent();
|
var client = new WebTorrent();
|
||||||
var notyf = new Notyf({
|
var notyf = new Notyf({
|
||||||
"duration": 8000,
|
duration: 8000,
|
||||||
"dismissible": true,
|
dismissible: true,
|
||||||
"ripple": false,
|
ripple: false,
|
||||||
"position": {
|
position: {
|
||||||
"x": "right",
|
x: 'right',
|
||||||
"y": "top",
|
y: 'top',
|
||||||
},
|
},
|
||||||
"types": [
|
types: [
|
||||||
{
|
{
|
||||||
"type": "success",
|
type: 'success',
|
||||||
"background": "#46835C",
|
background: '#46835C',
|
||||||
"icon": false
|
icon: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "error",
|
type: 'error',
|
||||||
"background": "#A60A0A",
|
background: '#A60A0A',
|
||||||
"icon": false
|
icon: false,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
function placeDownloadTooltips(e) {
|
function placeDownloadTooltips(e) {
|
||||||
if (window.innerWidth > 1080) {
|
if (window.innerWidth > 1080) {
|
||||||
openURLTooltip.setProps({"placement": "right"});
|
openURLTooltip.setProps({ placement: 'right' });
|
||||||
copyURLTooltip.setProps({"placement": "right"});
|
copyURLTooltip.setProps({ placement: 'right' });
|
||||||
copyMagnetTooltip.setProps({"placement": "right"});
|
copyMagnetTooltip.setProps({ placement: 'right' });
|
||||||
downloadTorrentTooltip.setProps({"placement": "right"});
|
downloadTorrentTooltip.setProps({ placement: 'right' });
|
||||||
} else {
|
} else {
|
||||||
openURLTooltip.setProps({"placement": "top"});
|
openURLTooltip.setProps({ placement: 'top' });
|
||||||
copyURLTooltip.setProps({"placement": "top"});
|
copyURLTooltip.setProps({ placement: 'top' });
|
||||||
copyMagnetTooltip.setProps({"placement": "top"});
|
copyMagnetTooltip.setProps({ placement: 'top' });
|
||||||
downloadTorrentTooltip.setProps({"placement": "top"});
|
downloadTorrentTooltip.setProps({ placement: 'top' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +85,6 @@ placeDownloadTooltips();
|
|||||||
document.addEventListener('DOMContentLoaded', start);
|
document.addEventListener('DOMContentLoaded', start);
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
|
|
||||||
// magnet input
|
// magnet input
|
||||||
document.getElementById('magnet').addEventListener('keyup', function (event) {
|
document.getElementById('magnet').addEventListener('keyup', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -92,7 +92,7 @@ function start() {
|
|||||||
source = 'magnet';
|
source = 'magnet';
|
||||||
originalSourceIcon.innerHTML = '<span class="fad fa-magnet fa-fw"></span>';
|
originalSourceIcon.innerHTML = '<span class="fad fa-magnet fa-fw"></span>';
|
||||||
sourceTooltip.setContent('Currently loaded information sourced from Magnet URL');
|
sourceTooltip.setContent('Currently loaded information sourced from Magnet URL');
|
||||||
parse(magnet.value);
|
parse(this.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -114,7 +114,10 @@ function start() {
|
|||||||
|
|
||||||
document.addEventListener('drop', function (event) {
|
document.addEventListener('drop', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.dataTransfer.items[0].getAsFile().arrayBuffer().then(function(arrayBuffer) {
|
event.dataTransfer.items[0]
|
||||||
|
.getAsFile()
|
||||||
|
.arrayBuffer()
|
||||||
|
.then(function (arrayBuffer) {
|
||||||
source = 'torrent-file';
|
source = 'torrent-file';
|
||||||
originalSourceIcon.innerHTML = '<span class="fad fa-file-alt fa-fw"></span>';
|
originalSourceIcon.innerHTML = '<span class="fad fa-file-alt fa-fw"></span>';
|
||||||
sourceTooltip.setContent('Currently loaded information sourced from Torrent file');
|
sourceTooltip.setContent('Currently loaded information sourced from Torrent file');
|
||||||
@@ -125,11 +128,11 @@ function start() {
|
|||||||
// example buttons
|
// example buttons
|
||||||
example1.addEventListener('click', function (event) {
|
example1.addEventListener('click', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
notyf.success('Parsing Ubuntu 22.04 Magnet URL');
|
notyf.success('Parsing Ubuntu 24.04 Magnet URL');
|
||||||
source = 'magnet';
|
source = 'magnet';
|
||||||
originalSourceIcon.innerHTML = '<span class="fad fa-magnet fa-fw"></span>';
|
originalSourceIcon.innerHTML = '<span class="fad fa-magnet fa-fw"></span>';
|
||||||
sourceTooltip.setContent('Currently loaded information sourced from Magnet URL');
|
sourceTooltip.setContent('Currently loaded information sourced from Magnet URL');
|
||||||
parse('magnet:?xt=urn:btih:2c6b6858d61da9543d4231a71db4b1c9264b0685&dn=ubuntu-22.04-desktop-amd64.iso&tr=https%3A%2F%2Ftorrent.ubuntu.com%2Fannounce&tr=https%3A%2F%2Fipv6.torrent.ubuntu.com%2Fannounce');
|
parse('magnet:?xt=urn:btih:2aa4f5a7e209e54b32803d43670971c4c8caaa05&dn=ubuntu-24.04-desktop-amd64.iso&tr=https%3A%2F%2Ftorrent.ubuntu.com%2Fannounce&tr=https%3A%2F%2Fipv6.torrent.ubuntu.com%2Fannounce');
|
||||||
});
|
});
|
||||||
|
|
||||||
example2.addEventListener('click', async function (event) {
|
example2.addEventListener('click', async function (event) {
|
||||||
@@ -189,7 +192,7 @@ function start() {
|
|||||||
removeWebseeds.addEventListener('click', () => removeAllRows('urlList'));
|
removeWebseeds.addEventListener('click', () => removeAllRows('urlList'));
|
||||||
getFiles.addEventListener('click', getFilesFromPeers);
|
getFiles.addEventListener('click', getFilesFromPeers);
|
||||||
|
|
||||||
tippy('[data-tippy-content]', {"theme": "torrent-parts", "animation": "shift-away-subtle"}); // all element-defined tooltips
|
tippy('[data-tippy-content]', { theme: 'torrent-parts', animation: 'shift-away-subtle' }); // all element-defined tooltips
|
||||||
sourceTooltip.disable();
|
sourceTooltip.disable();
|
||||||
|
|
||||||
if (window.location.hash) {
|
if (window.location.hash) {
|
||||||
@@ -198,50 +201,55 @@ function start() {
|
|||||||
sourceTooltip.setContent('Currently loaded information sourced from shared torrent.parts link');
|
sourceTooltip.setContent('Currently loaded information sourced from shared torrent.parts link');
|
||||||
parse(window.location.hash.split('#')[1]);
|
parse(window.location.hash.split('#')[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse(toLoad) {
|
async function parse(toLoad) {
|
||||||
resetProperties();
|
resetProperties();
|
||||||
try {
|
try {
|
||||||
console.info('Attempting parse');
|
console.info('Attempting parse');
|
||||||
parsed = parser(toLoad);
|
parsed = await parseTorrent(toLoad);
|
||||||
display();
|
display();
|
||||||
if (parsed.xs) {
|
if (parsed.xs) {
|
||||||
console.info('Magnet includes xs, attempting remote parse');
|
console.info('Magnet includes xs, attempting remote parse');
|
||||||
parseRemote(parsed.xs);
|
parseRemote(parsed.xs);
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
catch(e) { // maybe they put a URL to a torrent file in the magnet box?
|
// maybe they put a URL to a torrent file in the magnet box?
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
if (source == 'magnet') {
|
if (source == 'magnet') {
|
||||||
console.info('Attempting remote parse');
|
console.info('Attempting remote parse');
|
||||||
parseRemote(toLoad);
|
parseRemote(toLoad);
|
||||||
} else { // probably not. Just a bad file.
|
} else {
|
||||||
|
// probably not. Just a bad file.
|
||||||
notyf.error('Problem parsing input. Is this a .torrent file?');
|
notyf.error('Problem parsing input. Is this a .torrent file?');
|
||||||
console.error('Problem parsing input');
|
console.error('Problem parsing input');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseRemote(toLoad) {
|
async function parseRemote(toLoad) {
|
||||||
parser.remote(toLoad, function(err, result) {
|
try {
|
||||||
|
parsed = await new Promise((resolve, reject) => {
|
||||||
|
parseTorrentRemote(toLoad, (err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
notyf.error('Problem remotely fetching that file or parsing result');
|
reject(err);
|
||||||
console.warn(err);
|
} else {
|
||||||
resetProperties();
|
resolve(result);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
source = 'remote-torrent-file';
|
source = 'remote-torrent-file';
|
||||||
originalSourceIcon.innerHTML = '<span class="fad fa-file-alt fa-fw"></span>';
|
originalSourceIcon.innerHTML = '<span class="fad fa-file-alt fa-fw"></span>';
|
||||||
sourceTooltip.setContent('Currently loaded information sourced from remotely fetched Torrent file');
|
sourceTooltip.setContent('Currently loaded information sourced from remotely fetched Torrent file');
|
||||||
parsed = result;
|
|
||||||
display();
|
display();
|
||||||
});
|
} catch (err) {
|
||||||
|
console.warn(err);
|
||||||
|
notyf.error('Problem remotely fetching that file or parsing result');
|
||||||
|
resetProperties();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function display() {
|
function display() {
|
||||||
|
|
||||||
console.log(parsed);
|
console.log(parsed);
|
||||||
|
|
||||||
hash.value = parsed.infoHash;
|
hash.value = parsed.infoHash;
|
||||||
@@ -254,7 +262,7 @@ function display() {
|
|||||||
}
|
}
|
||||||
createdBy.value = parsed.createdBy ? ' by ' + parsed.createdBy : '';
|
createdBy.value = parsed.createdBy ? ' by ' + parsed.createdBy : '';
|
||||||
comment.value = parsed.comment ? parsed.comment : '';
|
comment.value = parsed.comment ? parsed.comment : '';
|
||||||
pieces.value = parsed.pieces ? parsed.pieces.length.toLocaleString() + ' ' + bytes.format(parsed.pieceLength, {"decimalPlaces": 1, "unitSeparator": " "}) + ' pieces (last piece ' + bytes.format(parsed.lastPieceLength, {"decimalPlaces": 1, "unitSeparator": " "}) + ')' : '';
|
pieces.value = parsed.pieces ? parsed.pieces.length.toLocaleString() + ' ' + bytes.format(parsed.pieceLength, { decimalPlaces: 1, unitSeparator: ' ' }) + ' pieces (last piece ' + bytes.format(parsed.lastPieceLength, { decimalPlaces: 1, unitSeparator: ' ' }) + ')' : '';
|
||||||
|
|
||||||
announce.innerHTML = '';
|
announce.innerHTML = '';
|
||||||
if (parsed.announce && parsed.announce.length) {
|
if (parsed.announce && parsed.announce.length) {
|
||||||
@@ -324,7 +332,7 @@ function display() {
|
|||||||
files.appendChild(createFileRow('', '...and another ' + (parsed.files.length - 100) + ' more files', ''));
|
files.appendChild(createFileRow('', '...and another ' + (parsed.files.length - 100) + ' more files', ''));
|
||||||
}
|
}
|
||||||
files.appendChild(createFileRow('folder-tree', '', parsed.length));
|
files.appendChild(createFileRow('folder-tree', '', parsed.length));
|
||||||
openURLWrapper.href = parser.toMagnetURI(parsed);
|
openURLWrapper.href = toMagnetURI(parsed);
|
||||||
downloadTorrentTooltip.setContent('Download Torrent file');
|
downloadTorrentTooltip.setContent('Download Torrent file');
|
||||||
downloadTorrent.addEventListener('click', saveTorrent);
|
downloadTorrent.addEventListener('click', saveTorrent);
|
||||||
downloadTorrent.disabled = false;
|
downloadTorrent.disabled = false;
|
||||||
@@ -341,22 +349,21 @@ function display() {
|
|||||||
downloadTorrent.disabled = true;
|
downloadTorrent.disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
copyURL.setAttribute('data-clipboard-text', window.location.origin + '#' + parser.toMagnetURI(parsed));
|
copyURL.setAttribute('data-clipboard-text', window.location.origin + '#' + toMagnetURI(parsed));
|
||||||
copyMagnet.setAttribute('data-clipboard-text', parser.toMagnetURI(parsed));
|
copyMagnet.setAttribute('data-clipboard-text', toMagnetURI(parsed));
|
||||||
|
|
||||||
examples.style.display = 'none';
|
examples.style.display = 'none';
|
||||||
properties.style.display = 'flex';
|
properties.style.display = 'flex';
|
||||||
|
|
||||||
window.location.hash = parser.toMagnetURI(parsed);
|
window.location.hash = toMagnetURI(parsed);
|
||||||
|
|
||||||
if (parsed.name) {
|
if (parsed.name) {
|
||||||
document.title = 'Torrent Parts | ' + parsed.name;
|
document.title = 'Torrent Parts | ' + parsed.name;
|
||||||
} else {
|
} else {
|
||||||
document.title = 'Torrent Parts | Inspect and edit what\'s in your Torrent file or Magnet link';
|
document.title = "Torrent Parts | Inspect and edit what's in your Torrent file or Magnet link";
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceTooltip.enable();
|
sourceTooltip.enable();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createFileRow(icon, name, size) {
|
function createFileRow(icon, name, size) {
|
||||||
@@ -368,7 +375,7 @@ function createFileRow(icon, name, size) {
|
|||||||
namecell.innerHTML = name;
|
namecell.innerHTML = name;
|
||||||
row.appendChild(namecell);
|
row.appendChild(namecell);
|
||||||
let totalcell = document.createElement('td');
|
let totalcell = document.createElement('td');
|
||||||
totalcell.innerHTML = bytes.format(size, {"decimalPlaces": 1, "unitSeparator": " "});
|
totalcell.innerHTML = bytes.format(size, { decimalPlaces: 1, unitSeparator: ' ' });
|
||||||
row.appendChild(totalcell);
|
row.appendChild(totalcell);
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
@@ -383,7 +390,7 @@ function getFontAwesomeIconForMimetype(mimetype) {
|
|||||||
return 'file-word';
|
return 'file-word';
|
||||||
case mimetype.includes('ms-excel'):
|
case mimetype.includes('ms-excel'):
|
||||||
case mimetype.includes('spreadsheet'):
|
case mimetype.includes('spreadsheet'):
|
||||||
return 'file-powerpoint';
|
return 'file-spreadsheet';
|
||||||
case mimetype.includes('powerpoint'):
|
case mimetype.includes('powerpoint'):
|
||||||
case mimetype.includes('presentation'):
|
case mimetype.includes('presentation'):
|
||||||
return 'file-powerpoint';
|
return 'file-powerpoint';
|
||||||
@@ -419,7 +426,7 @@ function propertyChange(e) {
|
|||||||
} else {
|
} else {
|
||||||
parsed[this.id] = this.value ? this.value : '';
|
parsed[this.id] = this.value ? this.value : '';
|
||||||
}
|
}
|
||||||
window.location.hash = parser.toMagnetURI(parsed);
|
window.location.hash = toMagnetURI(parsed);
|
||||||
updateModified();
|
updateModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,13 +442,13 @@ function resetProperties() {
|
|||||||
hash.value = '';
|
hash.value = '';
|
||||||
announce.innerHTML = '';
|
announce.innerHTML = '';
|
||||||
urlList.innerHTML = '';
|
urlList.innerHTML = '';
|
||||||
client.torrents.forEach(torrent => torrent.destroy());
|
client.torrents.forEach((torrent) => torrent.destroy());
|
||||||
getFiles.style.display = 'block';
|
getFiles.style.display = 'block';
|
||||||
files.innerHTML = '';
|
files.innerHTML = '';
|
||||||
window.location.hash = '';
|
window.location.hash = '';
|
||||||
copyURL.setAttribute('data-clipboard-text', '');
|
copyURL.setAttribute('data-clipboard-text', '');
|
||||||
copyMagnet.setAttribute('data-clipboard-text', '');
|
copyMagnet.setAttribute('data-clipboard-text', '');
|
||||||
document.title = 'Torrent Parts | Inspect and edit what\'s in your Torrent file or Magnet link';
|
document.title = "Torrent Parts | Inspect and edit what's in your Torrent file or Magnet link";
|
||||||
sourceTooltip.disable();
|
sourceTooltip.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,8 +464,7 @@ async function addCurrentTrackers() {
|
|||||||
parsed.announce = parsed.announce.filter((v, i) => v && parsed.announce.indexOf(v) === i); // remove duplicates and empties
|
parsed.announce = parsed.announce.filter((v, i) => v && parsed.announce.indexOf(v) === i); // remove duplicates and empties
|
||||||
notyf.success('Added known working trackers from newTrackon');
|
notyf.success('Added known working trackers from newTrackon');
|
||||||
updateModified();
|
updateModified();
|
||||||
}
|
} catch (e) {
|
||||||
catch(e) {
|
|
||||||
notyf.error('Problem fetching trackers from newTrackon');
|
notyf.error('Problem fetching trackers from newTrackon');
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
}
|
}
|
||||||
@@ -503,7 +509,7 @@ function getFilesFromPeers() {
|
|||||||
parsed.announce.push('wss://tracker.btorrent.xyz');
|
parsed.announce.push('wss://tracker.btorrent.xyz');
|
||||||
parsed.announce.push('wss://tracker.fastcast.nz');
|
parsed.announce.push('wss://tracker.fastcast.nz');
|
||||||
parsed.announce = parsed.announce.filter((v, i) => v && parsed.announce.indexOf(v) === i); // remove duplicates and empties
|
parsed.announce = parsed.announce.filter((v, i) => v && parsed.announce.indexOf(v) === i); // remove duplicates and empties
|
||||||
client.add(parser.toMagnetURI(parsed), (torrent) => {
|
client.add(toMagnetURI(parsed), (torrent) => {
|
||||||
parsed.info = Object.assign({}, torrent.info); // clone object
|
parsed.info = Object.assign({}, torrent.info); // clone object
|
||||||
parsed.files = torrent.files;
|
parsed.files = torrent.files;
|
||||||
parsed.infoBuffer = torrent.infoBuffer;
|
parsed.infoBuffer = torrent.infoBuffer;
|
||||||
@@ -519,12 +525,11 @@ function getFilesFromPeers() {
|
|||||||
|
|
||||||
// https://stackoverflow.com/a/36899900/2700296
|
// https://stackoverflow.com/a/36899900/2700296
|
||||||
function saveTorrent() {
|
function saveTorrent() {
|
||||||
let data = parser.toTorrentFile(parsed);
|
let data = toTorrentFile(parsed);
|
||||||
if (data !== null && navigator.msSaveBlob)
|
if (data !== null && navigator.msSaveBlob) return navigator.msSaveBlob(new Blob([data], { type: 'application/x-bittorrent' }), parsed.name + '.torrent');
|
||||||
return navigator.msSaveBlob(new Blob([data], { "type": "application/x-bittorrent" }), parsed.name + '.torrent');
|
|
||||||
let a = document.createElement('a');
|
let a = document.createElement('a');
|
||||||
a.style.display = 'none';
|
a.style.display = 'none';
|
||||||
let url = window.URL.createObjectURL(new Blob([data], { "type": "application/x-bittorrent" }));
|
let url = window.URL.createObjectURL(new Blob([data], { type: 'application/x-bittorrent' }));
|
||||||
a.setAttribute('href', url);
|
a.setAttribute('href', url);
|
||||||
a.setAttribute('download', parsed.name + '.torrent');
|
a.setAttribute('download', parsed.name + '.torrent');
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
81
src/sw.js
81
src/sw.js
@@ -1,33 +1,84 @@
|
|||||||
const assets = [
|
const cache_name = 'torrent-parts-v1';
|
||||||
'/',
|
const assets = ['/', '/index.html', '/src/parse.js', '/src/style.css', '/ext/alata-v9-latin-regular.woff2', '/ext/alata-v9-latin-regular.ttf', '/ext/fa.min.js', '/ext/jj2008-06-14.mk4_archive.torrent', '/favicon.ico', '/manifest.webmanifest'];
|
||||||
'/index.html',
|
|
||||||
'/bin/bundle.min.js',
|
|
||||||
'/src/style.css',
|
|
||||||
'/ext/alata-latin-400.woff2',
|
|
||||||
'/ext/alata-latin-400.woff',
|
|
||||||
'/ext/fa.min.js',
|
|
||||||
'/ext/notyf.min.js',
|
|
||||||
'/ext/jj2008-06-14.mk4_archive.torrent'
|
|
||||||
];
|
|
||||||
|
|
||||||
self.addEventListener('install', function (event) {
|
self.addEventListener('install', function (event) {
|
||||||
|
self.skipWaiting(); // Force activate new SW immediately
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
caches.open('assets')
|
caches
|
||||||
|
.open(cache_name)
|
||||||
.then(function (cache) {
|
.then(function (cache) {
|
||||||
return cache.addAll(assets);
|
return cache.addAll(assets);
|
||||||
})
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
console.error('Service worker install failed:', error);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener('activate', function (event) {
|
||||||
|
event.waitUntil(
|
||||||
|
Promise.all([
|
||||||
|
// Take control of all clients immediately
|
||||||
|
self.clients.claim(),
|
||||||
|
// Clean up old caches
|
||||||
|
caches.keys().then(function (cacheNames) {
|
||||||
|
return Promise.all(
|
||||||
|
cacheNames.map(function (cacheName) {
|
||||||
|
if (cacheName !== cache_name) {
|
||||||
|
console.log('Deleting old cache:', cacheName);
|
||||||
|
return caches.delete(cacheName);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
])
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('fetch', function (event) {
|
self.addEventListener('fetch', function (event) {
|
||||||
|
// Only cache GET requests
|
||||||
|
if (event.request.method !== 'GET') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Network-first strategy for external requests
|
||||||
|
const requestUrl = new URL(event.request.url);
|
||||||
|
if (requestUrl.origin !== self.location.origin) {
|
||||||
event.respondWith(
|
event.respondWith(
|
||||||
caches.match(event.request)
|
fetch(event.request)
|
||||||
|
.then(function (response) {
|
||||||
|
return response;
|
||||||
|
})
|
||||||
|
.catch(function () {
|
||||||
|
console.log('Network request failed, trying cache:', event.request.url);
|
||||||
|
return caches.match(event.request);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cache-first strategy for app assets
|
||||||
|
event.respondWith(
|
||||||
|
caches
|
||||||
|
.match(event.request)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
if (response) {
|
if (response) {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
return fetch(event.request);
|
return fetch(event.request).then(function (response) {
|
||||||
|
// Cache successful responses for future use
|
||||||
|
if (response && response.status === 200) {
|
||||||
|
const responseClone = response.clone();
|
||||||
|
caches.open(cache_name).then(function (cache) {
|
||||||
|
cache.put(event.request, responseClone);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
)
|
return response;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
console.error('Service worker fetch failed:', error);
|
||||||
|
// Could return offline fallback page here if needed
|
||||||
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user