mirror of
https://github.com/leoherzog/TorrentParts.git
synced 2026-01-24 04:08:04 -08:00
Initial proof of concept
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
package-lock.json
|
||||||
24
index.html
Normal file
24
index.html
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<head></head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-form-label" for="magnet">Magnet URL</label>
|
||||||
|
<input id="magnet" type="text" class="form-control" placeholder="magnet:?xt=urn:btih…" />
|
||||||
|
<div>or</div>
|
||||||
|
<label class="col-form-label" for="torrent">Upload Torrent</label>
|
||||||
|
<input id="torrent" type="file" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-form-label" for="name">Torrent Name</label>
|
||||||
|
<input id="name" type="text" class="form-control" value="" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="bundle.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
26
package.json
Normal file
26
package.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "torrentparts",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "🗃️ A website to inspect and edit Torrent files and Magnet URLs",
|
||||||
|
"main": "bundle.js",
|
||||||
|
"dependencies": {
|
||||||
|
"browserify": "latest",
|
||||||
|
"Buffer": "latest",
|
||||||
|
"dropzone": "latest",
|
||||||
|
"filesize": "latest",
|
||||||
|
"parse-torrent": "latest"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"watchify": "latest"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/leoherzog/TorrentParts.git"
|
||||||
|
},
|
||||||
|
"author": "Leo Herzog",
|
||||||
|
"license": "CC BY-SA 4.0",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/leoherzog/TorrentParts/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/leoherzog/TorrentParts"
|
||||||
|
}
|
||||||
44
parse.js
Normal file
44
parse.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
const parser = require('parse-torrent');
|
||||||
|
const Buffer = require('Buffer');
|
||||||
|
const size = require('filesize');
|
||||||
|
|
||||||
|
var name = document.getElementById('name');
|
||||||
|
var parsed;
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', start);
|
||||||
|
|
||||||
|
function start() {
|
||||||
|
|
||||||
|
document.getElementById('magnet').addEventListener('keyup', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (event.keyCode === 13) {
|
||||||
|
parse(magnet.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('torrent').addEventListener('change', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.target.files[0].arrayBuffer().then(arrayBuffer => parse(Buffer.from(arrayBuffer)));
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function parse(toLoad) {
|
||||||
|
console.info(toLoad);
|
||||||
|
if (typeof toLoad === "string" && toLoad.toLowerCase().trim().startsWith("http")) {
|
||||||
|
parser.remote(toLoad, handleRemote);
|
||||||
|
} else {
|
||||||
|
parsed = parser(toLoad);
|
||||||
|
display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRemote(err, result) {
|
||||||
|
parsed = result;
|
||||||
|
display();
|
||||||
|
}
|
||||||
|
|
||||||
|
function display() {
|
||||||
|
console.log(parsed);
|
||||||
|
name.value = parsed.name;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user