mirror of
https://github.com/leoherzog/TorrentParts.git
synced 2026-01-24 04:08:04 -08:00
Merge branch 'v1.1' of https://github.com/leoherzog/TorrentParts into v1.1
This commit is contained in:
@@ -23810,11 +23810,10 @@ function parseTorrent (torrentId) {
|
||||
}
|
||||
}
|
||||
|
||||
function parseTorrentRemote (torrentId, opts, cb) {
|
||||
if (typeof opts === 'function') return parseTorrentRemote(torrentId, {}, opts)
|
||||
function parseTorrentRemote (torrentId, cb) {
|
||||
let parsedTorrent
|
||||
if (typeof cb !== 'function') throw new Error('second argument must be a Function')
|
||||
|
||||
let parsedTorrent
|
||||
try {
|
||||
parsedTorrent = parseTorrent(torrentId)
|
||||
} catch (err) {
|
||||
@@ -23833,12 +23832,11 @@ function parseTorrentRemote (torrentId, opts, cb) {
|
||||
})
|
||||
} else if (typeof get === 'function' && /^https?:/.test(torrentId)) {
|
||||
// http, or https url to torrent file
|
||||
opts = Object.assign({
|
||||
get.concat({
|
||||
url: torrentId,
|
||||
timeout: 30 * 1000,
|
||||
headers: { 'user-agent': 'WebTorrent (https://webtorrent.io)' }
|
||||
}, opts)
|
||||
get.concat(opts, (err, res, torrentBuf) => {
|
||||
}, (err, res, torrentBuf) => {
|
||||
if (err) return cb(new Error(`Error downloading torrent: ${err.message}`))
|
||||
parseOrThrow(torrentBuf)
|
||||
})
|
||||
@@ -37957,6 +37955,7 @@ document.addEventListener('DOMContentLoaded', start);
|
||||
|
||||
function start() {
|
||||
|
||||
// magnet input
|
||||
document.getElementById('magnet').addEventListener('keyup', function(event) {
|
||||
event.preventDefault();
|
||||
if (event.key === "Enter") {
|
||||
@@ -37967,6 +37966,7 @@ function start() {
|
||||
}
|
||||
});
|
||||
|
||||
// torrent select button
|
||||
document.getElementById('torrent').addEventListener('change', function(event) {
|
||||
event.preventDefault();
|
||||
event.target.files[0].arrayBuffer().then(function(arrayBuffer) {
|
||||
@@ -37977,6 +37977,22 @@ function start() {
|
||||
});
|
||||
});
|
||||
|
||||
// body drag-and-drop torrent file support
|
||||
document.addEventListener('dragover', function(event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
document.addEventListener('drop', function(event) {
|
||||
event.preventDefault();
|
||||
event.dataTransfer.items[0].getAsFile().arrayBuffer().then(function(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));
|
||||
});
|
||||
});
|
||||
|
||||
// example buttons
|
||||
example1.addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
notyf.success("Parsing Ubuntu 20.04 Magnet URL");
|
||||
@@ -37997,6 +38013,7 @@ function start() {
|
||||
parse(Buffer.from(arrayBuffer));
|
||||
});
|
||||
|
||||
// share buttons
|
||||
let copyurl = new clipboard('#copyURL');
|
||||
copyurl.on('success', function(e) {
|
||||
notyf.success('Copied site URL to clipboard!');
|
||||
@@ -38024,6 +38041,7 @@ function start() {
|
||||
console.warn(e);
|
||||
});
|
||||
|
||||
// details field listeners
|
||||
name.addEventListener('input', propertyChange);
|
||||
name.addEventListener('change', propertyChange);
|
||||
name.addEventListener('reset', propertyChange);
|
||||
|
||||
4
bin/bundle.min.js
vendored
4
bin/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
24
package.json
24
package.json
@@ -4,20 +4,20 @@
|
||||
"description": "📑 A website to inspect and edit Torrent files and Magnet URLs",
|
||||
"main": "bin/bundle.js",
|
||||
"dependencies": {
|
||||
"browserify": "latest",
|
||||
"Buffer": "latest",
|
||||
"bytes": "latest",
|
||||
"clipboard": "latest",
|
||||
"dropzone": "latest",
|
||||
"mime-types": "latest",
|
||||
"parse-torrent": "latest",
|
||||
"tippy.js": "latest",
|
||||
"webtorrent": "latest"
|
||||
"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"
|
||||
},
|
||||
"devDependencies": {
|
||||
"notyf": "latest",
|
||||
"terser": "latest",
|
||||
"watchify": "latest"
|
||||
"buffer": "^5.2.1",
|
||||
"Buffer": "^0.0.0",
|
||||
"notyf": "^3.9.0",
|
||||
"terser": "^5.3.8",
|
||||
"watchify": "^3.11.1"
|
||||
},
|
||||
"scripts": {
|
||||
"watch": "watchify src/parse.js -o bin/bundle.js",
|
||||
|
||||
20
src/parse.js
20
src/parse.js
@@ -79,6 +79,7 @@ document.addEventListener('DOMContentLoaded', start);
|
||||
|
||||
function start() {
|
||||
|
||||
// magnet input
|
||||
document.getElementById('magnet').addEventListener('keyup', function(event) {
|
||||
event.preventDefault();
|
||||
if (event.key === "Enter") {
|
||||
@@ -89,6 +90,7 @@ function start() {
|
||||
}
|
||||
});
|
||||
|
||||
// torrent select button
|
||||
document.getElementById('torrent').addEventListener('change', function(event) {
|
||||
event.preventDefault();
|
||||
event.target.files[0].arrayBuffer().then(function(arrayBuffer) {
|
||||
@@ -99,6 +101,22 @@ function start() {
|
||||
});
|
||||
});
|
||||
|
||||
// body drag-and-drop torrent file support
|
||||
document.addEventListener('dragover', function(event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
document.addEventListener('drop', function(event) {
|
||||
event.preventDefault();
|
||||
event.dataTransfer.items[0].getAsFile().arrayBuffer().then(function(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));
|
||||
});
|
||||
});
|
||||
|
||||
// example buttons
|
||||
example1.addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
notyf.success("Parsing Ubuntu 20.04 Magnet URL");
|
||||
@@ -119,6 +137,7 @@ function start() {
|
||||
parse(Buffer.from(arrayBuffer));
|
||||
});
|
||||
|
||||
// share buttons
|
||||
let copyurl = new clipboard('#copyURL');
|
||||
copyurl.on('success', function(e) {
|
||||
notyf.success('Copied site URL to clipboard!');
|
||||
@@ -146,6 +165,7 @@ function start() {
|
||||
console.warn(e);
|
||||
});
|
||||
|
||||
// details field listeners
|
||||
name.addEventListener('input', propertyChange);
|
||||
name.addEventListener('change', propertyChange);
|
||||
name.addEventListener('reset', propertyChange);
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user