38 Commits

Author SHA1 Message Date
Leo
ddb4a7da06 Add "Open in Torrent Client" Button 2023-01-14 16:15:31 +00:00
Leo
8d81259d1a Update Dependencies 2023-01-14 15:40:59 +00:00
Leo
1440ac69a1 Bump Version 2022-08-02 13:41:53 +00:00
Leo
0651975b13 Update to FontAwesome 6 2022-08-02 13:39:56 +00:00
Leo
a94258296c Update Dependencies 2022-08-02 13:22:53 +00:00
Leo
66cb2914a1 Clearer Piece Size Help Text 2022-08-02 13:16:51 +00:00
Leo
de3c73f3c1 Remove Redundant Hidden Label 2022-08-02 13:16:04 +00:00
Leo
b1794f000b Add Piece Size and Length 2022-08-02 13:15:00 +00:00
Leo
013318d258 Update Ubuntu Magnet Example 2022-06-18 02:27:57 +00:00
Leo
93ef3186f2 Update Dependencies 2022-06-18 02:24:36 +00:00
Leo
7d2871abcb Update Dependencies 2022-05-19 13:46:08 +00:00
Leo
6e748cde77 Add Update Script 2022-05-19 13:42:24 +00:00
Leo
2c728a61c2 Remove Google Analytics and Update Dependencies 2022-04-25 20:46:57 +00:00
Leo
7a9aa3bb10 Switch to only the Global Buffer and feross/buffer 2022-03-24 20:15:57 +00:00
Leo
aac24cfdd3 Update Dependencies 2022-03-24 20:05:20 +00:00
Leo
25eb970141 Yuck! 2022-03-24 19:46:27 +00:00
Leo
5244cd3710 Update Dependencies 2022-02-26 01:07:19 +00:00
Leo
28c2d03f55 Update Dependencies 2022-01-04 14:35:28 +00:00
Leo
cda94dd48a Remove Firefox Clear Button in Creation Time 2022-01-04 14:32:50 +00:00
Leo
03c6ae0e17 Update Dependencies 2021-12-17 16:21:24 +00:00
Leo
006c8db5e6 Standardize Quotes 2021-11-10 03:26:44 +00:00
Leo
43f63d8f22 Add Source Setting to Example Button 2021-11-10 03:14:47 +00:00
Leo
9f26fb2384 Update Dependencies 2021-11-10 02:42:54 +00:00
Leo
92f5abdb96 Update Dependencies 2021-10-29 18:03:52 +00:00
Leo
8813e819c4 Add Static Site Notation 2021-08-24 13:05:30 -04:00
Leo Herzog
fa23c0ff3f Tweak newTrackOn and Update Dependencies 2021-08-17 14:10:13 -04:00
Leo Herzog
a4152d0542 Update Dependencies 2021-07-19 13:13:01 -04:00
Leo Herzog
855e4140a0 Update Dependencies 2021-05-24 13:45:43 -04:00
Leo Herzog
c512101c4e Initial Support for v2 Magnet Links 2021-05-12 12:01:21 -04:00
Leo
e754ee965f Create robots.txt
Apparently Lighthouse scores go up with one, even if you're an SPA
2021-05-03 11:27:59 -04:00
Leo Herzog
5298bab66c Update Dependencies 2021-04-22 14:24:44 -04:00
Leo Herzog
acc6c5ba8c Note Switch to Cloudflare Pages 2021-03-24 13:22:09 -04:00
Leo Herzog
b150a2770a Update Dependencies 2021-03-22 13:45:01 -04:00
Leo Herzog
397d398f36 Update Dependencies 2021-03-04 22:23:58 -05:00
Leo Herzog
3ad1488a21 Update Dependencies 2021-02-08 11:27:46 -05:00
Leo Herzog
a47bd05d12 Update Dependencies 2021-01-18 16:05:41 -05:00
Leo Herzog
3daf51acca Update Dependencies 2020-12-17 08:51:15 -05:00
Leo
ad09499db9 Typo 2020-12-04 16:23:51 -05:00
11 changed files with 28816 additions and 4148 deletions

View File

@@ -2,7 +2,7 @@
## What is this?
[BitTorrent](https://bittorrent.com/) is a ubiquitus and powerful way to transfer files peer-to-peer. To specify what file(s) to download with your client, you need to input either a Torrent file or Magnet URL. [Torrent Parts](https://torrent.parts/) is a client-side static web app to read and edit the metadata of a Torrent file or Magnet URL so you know what you're downloading, before you add it to your Torrent client.
[BitTorrent](https://bittorrent.com/) is a ubiquitous and powerful way to transfer files peer-to-peer. To specify what file(s) to download with your client, you need to input either a Torrent file or Magnet URL. [Torrent Parts](https://torrent.parts/) is a client-side static web app to read and edit the metadata of a Torrent file or Magnet URL so you know what you're downloading, before you add it to your Torrent client.
### Features
@@ -25,7 +25,7 @@ This project wouldn't be possible without the fantastic work of:
- [@cvisuri](https://github.com/cvisuri), for design work
- [@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)
- [Github Pages](https://pages.github.com/) hosting
- [Cloudflare Pages](https://pages.cloudflare.com/) hosting
## License
@@ -47,9 +47,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
<a href="https://twitter.com/xd1936" target="_blank">
<img src="https://herzog.tech/signature/twitter.svg.png" width="32px" />
</a>
<a href="https://facebook.com/xd1936" target="_blank">
<img src="https://herzog.tech/signature/facebook.svg.png" width="32px" />
</a>
<a href="https://github.com/leoherzog" target="_blank">
<img src="https://herzog.tech/signature/github.svg.png" width="32px" />
</a>

File diff suppressed because one or more lines are too long

91
bin/bundle.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,22 +1,23 @@
projectName: 'C:\Users\herzog\Desktop\TorrentPartsFASubset'
version: 5.15.1
projectName: 'C:\Users\Leo\Desktop\TorrentPartsFASubset'
version: 6.2.1
icons:
- magnet:
- light
- solid
- duotone
- file-alt:
- file-lines:
- light
- regular
- duotone
- cloud-upload:
- cloud-arrow-up:
- solid
- link:
- light
- duotone
- share-alt:
- solid
- file-download:
- duotone
- file-arrow-down:
- solid
- arrow-up-right-from-square:
- solid
- file:
- regular
@@ -26,7 +27,7 @@ icons:
- regular
- file-excel:
- regular
- file-archive:
- file-zipper:
- regular
- file-csv:
- regular
@@ -44,9 +45,9 @@ icons:
- regular
- trash:
- regular
- times:
- xmark:
- regular
- info-circle:
- circle-info:
- regular
- plus-circle:
- circle-plus:
- regular

5
ext/fa.min.js vendored

File diff suppressed because one or more lines are too long

4
ext/notyf.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -43,14 +43,6 @@
<script async defer src="https://buttons.github.io/buttons.js"></script>
<script src="/ext/notyf.min.js"></script>
<script async defer src="https://www.googletagmanager.com/gtag/js?id=G-VT4953Z89H"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-VT4953Z89H');
</script>
<script async defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "6f97f49b4c384ee197a2f319cebec274"}'></script>
</head>
@@ -90,9 +82,14 @@
</button>
<div id="share">
<a id="openURLWrapper" target="_blank">
<button id="openURL" aria-label="Open this Magnet URL in your Torrent client">
<span class="fas fa-arrow-up-right-from-square fa-2x"></span>
</button>
</a>
<div>
<button id="copyURL" aria-label="Copy this torrent.parts link to the clipboard">
<span class="fas fa-share-alt fa-2x" data-fa-transform="left-1"></span>
<span class="fas fa-link fa-2x"></span>
</button>
</div>
<div>
@@ -140,7 +137,7 @@
<label for="createdBy" style="display:none">Created By</label>
</div>
<div class="content">
<input id="created" type="text" placeholder="Creation time unspecified" aria-label="Creation time" disabled />
<input id="created" type="text" placeholder="Creation time unspecified" aria-label="Creation time" disabled required />
<br />
<input id="createdBy" type="text" placeholder="Creation client unspecified" aria-label="Creation client" disabled />
</div>
@@ -191,6 +188,18 @@
</div>
</div>
<div class="property">
<div class="labels">
<div>
<span class="info" data-tippy-content="Torrents take files and split them into equal size pieces to make them easy to share. Piece size is configurable when a Torrent file is made."><span class="far fa-info-circle"></span></span>
<label for="pieces">Pieces</label>
</div>
</div>
<div class="content">
<input id="pieces" type="text" placeholder="Not included in the URL/File provided" aria-label="Piece size and length" disabled required />
</div>
</div>
<div class="property">
<div class="labels">
<div>
@@ -207,7 +216,7 @@
</div>
<footer>
<a href="https://github.com/leoherzog/TorrentParts/releases" target="_blank" rel="noopener">v1.1.1</a>
<a href="https://github.com/leoherzog/TorrentParts/releases" target="_blank" rel="noopener">v1.2</a>
</footer>
<script src="/bin/bundle.min.js"></script>

View File

@@ -1,34 +1,38 @@
{
"name": "torrentparts",
"version": "1.1.1",
"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.0",
"clipboard": "^2.0.6",
"mime-types": "^2.1.27",
"parse-torrent": "^9.0.0",
"tippy.js": "^6.2.7",
"webtorrent": "^0.110.1"
"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": "^5.2.1",
"Buffer": "^0.0.0",
"notyf": "^3.9.0",
"terser": "^5.3.8",
"watchify": "^3.11.1"
"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"
"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": {

2
robots.txt Normal file
View File

@@ -0,0 +1,2 @@
User-agent: *
Allow: /

View File

@@ -1,6 +1,6 @@
require('buffer');
const clipboard = require('clipboard');
const parser = require('parse-torrent');
const Buffer = require('Buffer');
const bytes = require('bytes');
const mime = require('mime-types');
const WebTorrent = require('webtorrent');
@@ -27,12 +27,16 @@ var announce = document.getElementById('announce');
var urlList = document.getElementById('urlList');
var addWebseed = document.getElementById('addWebseed');
var removeWebseeds = document.getElementById('removeWebseeds');
var pieces = document.getElementById('pieces');
var files = document.getElementById('filesBody');
var getFiles = document.getElementById('getFiles');
var openURLWrapper = document.getElementById('openURLWrapper');
var openURL = document.getElementById('openURL');
var copyURL = document.getElementById('copyURL');
var copyMagnet = document.getElementById('copyMagnet');
var downloadTorrentWrapper = document.getElementById('downloadTorrentWrapper');
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 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 downloadTorrentTooltip = tippy(downloadTorrentWrapper, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Download Torrent file"});
@@ -62,10 +66,12 @@ var notyf = new Notyf({
function placeDownloadTooltips(e) {
if (window.innerWidth > 1080) {
openURLTooltip.setProps({"placement": "right"});
copyURLTooltip.setProps({"placement": "right"});
copyMagnetTooltip.setProps({"placement": "right"});
downloadTorrentTooltip.setProps({"placement": "right"});
} else {
openURLTooltip.setProps({"placement": "top"});
copyURLTooltip.setProps({"placement": "top"});
copyMagnetTooltip.setProps({"placement": "top"});
downloadTorrentTooltip.setProps({"placement": "top"});
@@ -82,10 +88,10 @@ function start() {
// magnet input
document.getElementById('magnet').addEventListener('keyup', function(event) {
event.preventDefault();
if (event.key === "Enter") {
source = "magnet";
if (event.key === 'Enter') {
source = 'magnet';
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);
}
});
@@ -94,9 +100,9 @@ function start() {
document.getElementById('torrent').addEventListener('change', function(event) {
event.preventDefault();
event.target.files[0].arrayBuffer().then(function(arrayBuffer) {
source = "torrent-file";
source = 'torrent-file';
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');
parse(Buffer.from(arrayBuffer));
});
});
@@ -109,9 +115,9 @@ function start() {
document.addEventListener('drop', function(event) {
event.preventDefault();
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>';
sourceTooltip.setContent("Currently loaded information sourced from Torrent file");
sourceTooltip.setContent('Currently loaded information sourced from Torrent file');
parse(Buffer.from(arrayBuffer));
});
});
@@ -119,21 +125,30 @@ function start() {
// example buttons
example1.addEventListener('click', function(event) {
event.preventDefault();
notyf.success("Parsing Ubuntu 20.04 Magnet URL");
parse("magnet:?xt=urn:btih:9fc20b9e98ea98b4a35e6223041a5ef94ea27809&dn=ubuntu-20.04-desktop-amd64.iso&tr=https%3A%2F%2Ftorrent.ubuntu.com%2Fannounce&tr=https%3A%2F%2Fipv6.torrent.ubuntu.com%2Fannounce");
notyf.success('Parsing Ubuntu 22.04 Magnet URL');
source = 'magnet';
originalSourceIcon.innerHTML = '<span class="fad fa-magnet fa-fw"></span>';
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');
});
example2.addEventListener('click', async function(event) {
event.preventDefault();
notyf.success("Fetching and Parsing &ldquo;The WIRED CD&rdquo; Torrent File...");
parseRemote("https://webtorrent.io/torrents/wired-cd.torrent");
notyf.success('Fetching and Parsing &ldquo;The WIRED CD&rdquo; Torrent File...');
source = 'remote-torrent-file';
originalSourceIcon.innerHTML = '<span class="fad fa-file-alt fa-fw"></span>';
sourceTooltip.setContent('Currently loaded information sourced from remotely fetched Torrent file');
parseRemote('https://webtorrent.io/torrents/wired-cd.torrent');
});
example3.addEventListener('click', async function(event) {
event.preventDefault();
notyf.success("Parsing Jack Johnson Archive.org Torrent File");
let response = await fetch("/ext/jj2008-06-14.mk4_archive.torrent");
notyf.success('Parsing Jack Johnson Archive.org Torrent File');
let response = await fetch('/ext/jj2008-06-14.mk4_archive.torrent');
let arrayBuffer = await response.arrayBuffer();
source = 'torrent-file';
originalSourceIcon.innerHTML = '<span class="fad fa-file-alt fa-fw"></span>';
sourceTooltip.setContent('Currently loaded information sourced from Torrent file');
parse(Buffer.from(arrayBuffer));
});
@@ -142,10 +157,6 @@ function start() {
copyurl.on('success', function(e) {
notyf.success('Copied site URL to clipboard!');
console.info(e);
gtag('event', 'share', {
"method": "Copy URL",
"content_id": e.text,
});
});
copyurl.on('failure', function(e) {
notyf.error('Problem copying to clipboard');
@@ -155,10 +166,6 @@ function start() {
let copymagnet = new clipboard('#copyMagnet');
copymagnet.on('success', function(e) {
notyf.success('Copied Magnet URL to clipboard!');
gtag('event', 'share', {
"method": "Copy Magnet",
"content_id": e.text,
});
});
copymagnet.on('failure', function(e) {
notyf.error('Problem copying to clipboard');
@@ -186,9 +193,9 @@ function start() {
sourceTooltip.disable();
if (window.location.hash) {
source = "shared-url";
source = 'shared-url';
originalSourceIcon.innerHTML = '<span class="fad fa-link fa-fw"></span>';
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]);
}
@@ -197,18 +204,18 @@ function start() {
function parse(toLoad) {
resetProperties();
try {
console.info("Attempting parse");
console.info('Attempting parse');
parsed = parser(toLoad);
display();
if (parsed.xs) {
console.info("Magnet includes xs, attempting remote parse");
console.info('Magnet includes xs, attempting remote parse');
parseRemote(parsed.xs);
}
}
catch(e) { // maybe they put a URL to a torrent file in the magnet box?
console.warn(e);
if (source == "magnet") {
console.info("Attempting remote parse");
if (source == 'magnet') {
console.info('Attempting remote parse');
parseRemote(toLoad);
} else { // probably not. Just a bad file.
notyf.error('Problem parsing input. Is this a .torrent file?');
@@ -225,9 +232,9 @@ function parseRemote(toLoad) {
resetProperties();
return;
}
source = "remote-torrent-file";
source = 'remote-torrent-file';
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();
});
@@ -238,17 +245,18 @@ function display() {
console.log(parsed);
hash.value = parsed.infoHash;
name.value = parsed.name ? parsed.name : "";
name.value = parsed.name ? parsed.name : '';
if (parsed.created) {
created.value = parsed.created.toISOString().slice(0, 19);
created.type = "datetime-local";
created.type = 'datetime-local';
} else {
created.type = "text";
created.type = 'text';
}
createdBy.value = parsed.createdBy ? "by " + parsed.createdBy : "";
comment.value = parsed.comment ? parsed.comment : "";
createdBy.value = parsed.createdBy ? ' by ' + parsed.createdBy : '';
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": " "}) + ')' : '';
announce.innerHTML = "";
announce.innerHTML = '';
if (parsed.announce && parsed.announce.length) {
for (let i = 0; i < parsed.announce.length; i++) {
let row = document.createElement('div');
@@ -271,10 +279,10 @@ function display() {
announce.appendChild(row);
}
// } else {
// announce.innerHTML = "<em>No trackers specified in the URL/File provided</em>";
// announce.innerHTML = '<em>No trackers specified in the URL/File provided</em>';
}
urlList.innerHTML = "";
urlList.innerHTML = '';
if (parsed.urlList && parsed.urlList.length) {
for (let i = 0; i < parsed.urlList.length; i++) {
let row = document.createElement('div');
@@ -297,12 +305,12 @@ function display() {
urlList.appendChild(row);
}
// } else {
// urlList.innerHTML = "<em>No webseed URLs in the URL/File provided</em>";
// urlList.innerHTML = '<em>No webseed URLs in the URL/File provided</em>';
}
files.innerHTML = "";
files.innerHTML = '';
if (parsed.files && parsed.files.length) {
getFiles.style.display = "none";
getFiles.style.display = 'none';
if (parsed.files.length < 100) {
for (let file of parsed.files) {
let icon = getFontAwesomeIconForMimetype(mime.lookup(file.name));
@@ -316,15 +324,16 @@ function display() {
files.appendChild(createFileRow('', '...and another ' + (parsed.files.length - 100) + ' more files', ''));
}
files.appendChild(createFileRow('folder-tree', '', parsed.length));
openURLWrapper.href = parser.toMagnetURI(parsed);
downloadTorrentTooltip.setContent('Download Torrent file');
downloadTorrent.addEventListener('click', saveTorrent);
downloadTorrent.disabled = false;
} else {
if (client.torrents.length > 0) {
getFiles.style.display = "none";
getFiles.style.display = 'none';
files.innerHTML = '<input type="text" placeholder="Attempting fetching of files from Webtorrent..." aria-label="Attempting fetching of files from Webtorrent..." disabled>';
} else {
getFiles.style.display = "block";
getFiles.style.display = 'block';
files.innerHTML = '<input type="text" placeholder="Not included in the URL/File provided" aria-label="Files information not included in the URL/File provided" disabled>';
}
downloadTorrentTooltip.setContent('Files metadata is required to generate a Torrent file. Try fetching files list from WebTorrent.');
@@ -332,7 +341,7 @@ function display() {
downloadTorrent.disabled = true;
}
copyURL.setAttribute('data-clipboard-text', window.location.origin + "#" + parser.toMagnetURI(parsed));
copyURL.setAttribute('data-clipboard-text', window.location.origin + '#' + parser.toMagnetURI(parsed));
copyMagnet.setAttribute('data-clipboard-text', parser.toMagnetURI(parsed));
examples.style.display = 'none';
@@ -341,21 +350,13 @@ function display() {
window.location.hash = parser.toMagnetURI(parsed);
if (parsed.name) {
document.title = "Torrent Parts | " + parsed.name;
document.title = 'Torrent Parts | ' + parsed.name;
} 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();
gtag('event', 'view_item', {
items: [{
"item_id": parsed.infoHash,
"item_name": parsed.name,
"item_category": source
}]
});
}
function createFileRow(icon, name, size) {
@@ -375,37 +376,37 @@ function createFileRow(icon, name, size) {
function getFontAwesomeIconForMimetype(mimetype) {
if (!mimetype) return 'file';
switch (true) {
case mimetype.includes("msword"):
case mimetype.includes("wordprocessingml"):
case mimetype.includes("opendocument.text"):
case mimetype.includes("abiword"):
case mimetype.includes('msword'):
case mimetype.includes('wordprocessingml'):
case mimetype.includes('opendocument.text'):
case mimetype.includes('abiword'):
return 'file-word';
case mimetype.includes("ms-excel"):
case mimetype.includes("spreadsheet"):
case mimetype.includes('ms-excel'):
case mimetype.includes('spreadsheet'):
return 'file-powerpoint';
case mimetype.includes("powerpoint"):
case mimetype.includes("presentation"):
case mimetype.includes('powerpoint'):
case mimetype.includes('presentation'):
return 'file-powerpoint';
case mimetype.includes("7z-"):
case mimetype.includes("iso9660"):
case mimetype.includes("zip"):
case mimetype.includes("octet-stream"):
case mimetype.includes('7z-'):
case mimetype.includes('iso9660'):
case mimetype.includes('zip'):
case mimetype.includes('octet-stream'):
return 'file-archive';
case mimetype.includes("csv"):
case mimetype.includes('csv'):
return 'file-csv';
case mimetype.includes("pdf"):
case mimetype.includes('pdf'):
return 'file-pdf';
case mimetype.includes("font"):
case mimetype.includes('font'):
return 'file-contract';
case mimetype.includes("text"):
case mimetype.includes("subrip"):
case mimetype.includes("vtt"):
case mimetype.includes('text'):
case mimetype.includes('subrip'):
case mimetype.includes('vtt'):
return 'file-alt';
case mimetype.includes("audio"):
case mimetype.includes('audio'):
return 'file-audio';
case mimetype.includes("image"):
case mimetype.includes('image'):
return 'file-image';
case mimetype.includes("video"):
case mimetype.includes('video'):
return 'file-video';
default:
return 'file';
@@ -414,46 +415,45 @@ function getFontAwesomeIconForMimetype(mimetype) {
function propertyChange(e) {
if (this.dataset.group) {
parsed[this.dataset.group][this.dataset.index] = this.value ? this.value : "";
parsed[this.dataset.group][this.dataset.index] = this.value ? this.value : '';
} else {
parsed[this.id] = this.value ? this.value : "";
parsed[this.id] = this.value ? this.value : '';
}
window.location.hash = parser.toMagnetURI(parsed);
updateModified();
}
function resetProperties() {
document.getElementById('magnet').value = "";
document.getElementById('torrent').value = "";
document.getElementById('magnet').value = '';
document.getElementById('torrent').value = '';
examples.style.display = 'flex';
properties.style.display = 'none';
name.value = "";
created.value = "";
createdBy.value = "";
comment.value = "";
hash.value = "";
announce.innerHTML = "";
urlList.innerHTML = "";
name.value = '';
created.value = '';
createdBy.value = '';
comment.value = '';
hash.value = '';
announce.innerHTML = '';
urlList.innerHTML = '';
client.torrents.forEach(torrent => torrent.destroy());
getFiles.style.display = "block";
files.innerHTML = "";
window.location.hash = "";
copyURL.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";
getFiles.style.display = 'block';
files.innerHTML = '';
window.location.hash = '';
copyURL.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';
sourceTooltip.disable();
gtag('event', 'reset');
}
async function addCurrentTrackers() {
addTrackers.className = 'disabled';
addTrackers.innerHTML = 'Adding...';
try {
let response = await fetch("https://newtrackon.com/api/100"); // get trackers with 100% uptime
let response = await fetch('https://newtrackon.com/api/stable'); // get trackers with 95% uptime
let trackers = await response.text();
parsed.announce = parsed.announce.concat(trackers.split('\n\n'));
parsed.announce.push("http://bt1.archive.org:6969/announce");
parsed.announce.push("http://bt2.archive.org:6969/announce");
parsed.announce.push('http://bt1.archive.org:6969/announce');
parsed.announce.push('http://bt2.archive.org:6969/announce');
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');
updateModified();
@@ -465,11 +465,10 @@ async function addCurrentTrackers() {
addTrackers.className = '';
addTrackers.innerHTML = 'Add Known Working Trackers';
display();
gtag('event', 'add_trackers');
}
function addRow() {
parsed[this.dataset.type].unshift("");
parsed[this.dataset.type].unshift('');
display();
}
@@ -486,23 +485,23 @@ function removeAllRows(type) {
function updateModified() {
parsed.created = new Date();
parsed.createdBy = "Torrent Parts <https://torrent.parts/>";
parsed.createdBy = 'Torrent Parts <https://torrent.parts/>';
if (parsed.created) {
created.value = parsed.created.toISOString().slice(0, 19);
created.type = "datetime-local";
created.type = 'datetime-local';
} else {
created.type = "text";
created.type = 'text';
}
createdBy.value = parsed.createdBy ? "by " + parsed.createdBy : "";
createdBy.value = parsed.createdBy ? ' by ' + parsed.createdBy : '';
}
function getFilesFromPeers() {
console.info("Attempting fetching files from Webtorrent...");
getFiles.style.display = "none";
parsed.announce.push("wss://tracker.webtorrent.io");
parsed.announce.push("wss://tracker.openwebtorrent.com");
parsed.announce.push("wss://tracker.btorrent.xyz");
parsed.announce.push("wss://tracker.fastcast.nz");
console.info('Attempting fetching files from Webtorrent...');
getFiles.style.display = 'none';
parsed.announce.push('wss://tracker.webtorrent.io');
parsed.announce.push('wss://tracker.openwebtorrent.com');
parsed.announce.push('wss://tracker.btorrent.xyz');
parsed.announce.push('wss://tracker.fastcast.nz');
parsed.announce = parsed.announce.filter((v,i) => v && parsed.announce.indexOf(v) === i); // remove duplicates and empties
client.add(parser.toMagnetURI(parsed), (torrent) => {
parsed.info = Object.assign({}, torrent.info); // clone object
@@ -516,7 +515,6 @@ function getFilesFromPeers() {
torrent.destroy();
});
display();
gtag('event', 'attempt_webtorrent_fetch');
}
// https://stackoverflow.com/a/36899900/2700296
@@ -527,14 +525,10 @@ function saveTorrent() {
let a = document.createElement('a');
a.style.display = 'none';
let url = window.URL.createObjectURL(new Blob([data], { "type": "application/x-bittorrent" }));
a.setAttribute("href", url);
a.setAttribute("download", parsed.name + '.torrent');
a.setAttribute('href', url);
a.setAttribute('download', parsed.name + '.torrent');
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
a.remove();
gtag('event', 'share', {
"method": "Torrent Download",
"content_id": parsed.name
});
}

File diff suppressed because one or more lines are too long