8 Commits

Author SHA1 Message Date
Leo
09f885238e Update to ESM Modules
- Remove compiling/bundling with Browserify
- Upgrade to latest parse-torrent and webtorrent
- Switch to dynamically updating dependencies from jsDelivr
2023-11-17 16:31:23 +00:00
Leo
fdcf397f64 Update Dependencies 2023-11-17 14:43:11 +00:00
Leo
6d6f53d288 Style Tweaks 2023-11-17 14:41:15 +00:00
Leo
b477e9c8c9 Update Dependencies 2023-08-23 15:54:07 +00:00
Leo
1ad87324d2 Add RTL Language Support 2023-08-23 15:49:18 +00:00
Leo
418cb0c6b7 Update Dependencies 2023-04-17 18:46:52 +00:00
Leo
2d908ecf02 Revert to WebTorrent 1.x 2023-03-13 18:05:49 +00:00
Leo
a1296b456d Bump Version 2023-01-14 16:16:05 +00:00
7 changed files with 44 additions and 63253 deletions

File diff suppressed because one or more lines are too long

108
bin/bundle.min.js vendored

File diff suppressed because one or more lines are too long

2
ext/notyf.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -36,12 +36,14 @@
<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.woff2" rel="preload" as="style" />
<link href="/ext/alata-latin-400.woff" 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 +53,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 +126,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 +153,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 +218,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.0</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) {

View File

@@ -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"
}

View File

@@ -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');
@@ -201,11 +202,11 @@ function start() {
} }
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');
@@ -224,22 +225,29 @@ function parse(toLoad) {
} }
} }
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);
@@ -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,13 +349,13 @@ 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;
@@ -419,7 +427,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();
} }
@@ -503,7 +511,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,7 +527,7 @@ 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');

File diff suppressed because one or more lines are too long