fix(torrent): fix search by magnet

This commit is contained in:
Alexey Kasyanchuk 2022-06-06 15:03:36 +03:00
parent 8ecbe329c7
commit bf6b88aaaa
3 changed files with 48 additions and 32 deletions

63
package-lock.json generated
View File

@ -11,8 +11,8 @@
"dependencies": { "dependencies": {
"@electron/remote": "^2.0.4", "@electron/remote": "^2.0.4",
"ansi-256-colors": "^1.1.0", "ansi-256-colors": "^1.1.0",
"bencode": "^2.0.2", "bencode": "2.0.1",
"bitfield": "^4.0.0", "bitfield": "3.0.0",
"cheerio": "^1.0.0-rc.10", "cheerio": "^1.0.0-rc.10",
"compare-versions": "^4.1.3", "compare-versions": "^4.1.3",
"create-torrent": "3.33.0", "create-torrent": "3.33.0",
@ -4078,9 +4078,12 @@
"peer": true "peer": true
}, },
"node_modules/bencode": { "node_modules/bencode": {
"version": "2.0.2", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/bencode/-/bencode-2.0.2.tgz", "resolved": "https://registry.npmjs.org/bencode/-/bencode-2.0.1.tgz",
"integrity": "sha512-0ilVjnE2diLdbec/3KN14SP0KE85wh8v/FceNRMbAB2ioc3yTj9tgqdoK9tFEH++TZ10JreTS29qTwg7+SpTiQ==" "integrity": "sha512-2uhEl8FdjSBUyb69qDTgOEeeqDTa+n3yMQzLW0cOzNf1Ow5bwcg3idf+qsWisIKRH8Bk8oC7UXL8irRcPA8ZEQ==",
"dependencies": {
"safe-buffer": "^5.1.1"
}
}, },
"node_modules/bep53-range": { "node_modules/bep53-range": {
"version": "1.1.1", "version": "1.1.1",
@ -4142,14 +4145,11 @@
"integrity": "sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA==" "integrity": "sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA=="
}, },
"node_modules/bitfield": { "node_modules/bitfield": {
"version": "4.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/bitfield/-/bitfield-4.0.0.tgz", "resolved": "https://registry.npmjs.org/bitfield/-/bitfield-3.0.0.tgz",
"integrity": "sha512-jtuSG9CQr5yoHFuvhgf50+DH8Aezl3C/mMSfqdG4DqP7Kqe34uBUtCEHPN9oWaldTm96/i7y5e778SnM5ES4rw==", "integrity": "sha512-hJmWKucJQfdSkQPDPBKmWogM9s8+NOSzDT9QVbJbjinXaQ0bJKPu/cn98qRWy3PDNWtKw4XaoUP3XruGRIKEgg==",
"engines": { "engines": {
"node": ">=8" "node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/fb55"
} }
}, },
"node_modules/bittorrent-dht": { "node_modules/bittorrent-dht": {
@ -15314,6 +15314,11 @@
"parse-torrent": "bin/cmd.js" "parse-torrent": "bin/cmd.js"
} }
}, },
"node_modules/parse-torrent/node_modules/bencode": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/bencode/-/bencode-2.0.3.tgz",
"integrity": "sha512-D/vrAD4dLVX23NalHwb8dSvsUsxeRPO8Y7ToKA015JQYq69MLDOMkC0uGZYA/MPpltLO8rt8eqFC2j8DxjTZ/w=="
},
"node_modules/parse-torrent/node_modules/simple-sha1": { "node_modules/parse-torrent/node_modules/simple-sha1": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/simple-sha1/-/simple-sha1-3.1.0.tgz", "resolved": "https://registry.npmjs.org/simple-sha1/-/simple-sha1-3.1.0.tgz",
@ -20517,6 +20522,17 @@
"simple-sha1": "^3.0.1" "simple-sha1": "^3.0.1"
} }
}, },
"node_modules/ut_metadata/node_modules/bitfield": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/bitfield/-/bitfield-4.1.0.tgz",
"integrity": "sha512-6cEDG3K+PK9f+B7WyhWYjp09bqSa+uaAaecVA7Y5giFixyVe1s6HKGnvOqYNR4Mi4fBMjfDPLBpHkKvzzgP7kg==",
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/fb55"
}
},
"node_modules/ut_metadata/node_modules/simple-sha1": { "node_modules/ut_metadata/node_modules/simple-sha1": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/simple-sha1/-/simple-sha1-3.1.0.tgz", "resolved": "https://registry.npmjs.org/simple-sha1/-/simple-sha1-3.1.0.tgz",
@ -24790,9 +24806,12 @@
"peer": true "peer": true
}, },
"bencode": { "bencode": {
"version": "2.0.2", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/bencode/-/bencode-2.0.2.tgz", "resolved": "https://registry.npmjs.org/bencode/-/bencode-2.0.1.tgz",
"integrity": "sha512-0ilVjnE2diLdbec/3KN14SP0KE85wh8v/FceNRMbAB2ioc3yTj9tgqdoK9tFEH++TZ10JreTS29qTwg7+SpTiQ==" "integrity": "sha512-2uhEl8FdjSBUyb69qDTgOEeeqDTa+n3yMQzLW0cOzNf1Ow5bwcg3idf+qsWisIKRH8Bk8oC7UXL8irRcPA8ZEQ==",
"requires": {
"safe-buffer": "^5.1.1"
}
}, },
"bep53-range": { "bep53-range": {
"version": "1.1.1", "version": "1.1.1",
@ -24841,9 +24860,9 @@
"integrity": "sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA==" "integrity": "sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA=="
}, },
"bitfield": { "bitfield": {
"version": "4.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/bitfield/-/bitfield-4.0.0.tgz", "resolved": "https://registry.npmjs.org/bitfield/-/bitfield-3.0.0.tgz",
"integrity": "sha512-jtuSG9CQr5yoHFuvhgf50+DH8Aezl3C/mMSfqdG4DqP7Kqe34uBUtCEHPN9oWaldTm96/i7y5e778SnM5ES4rw==" "integrity": "sha512-hJmWKucJQfdSkQPDPBKmWogM9s8+NOSzDT9QVbJbjinXaQ0bJKPu/cn98qRWy3PDNWtKw4XaoUP3XruGRIKEgg=="
}, },
"bittorrent-dht": { "bittorrent-dht": {
"version": "8.4.0", "version": "8.4.0",
@ -33284,6 +33303,11 @@
"simple-sha1": "^3.1.0" "simple-sha1": "^3.1.0"
}, },
"dependencies": { "dependencies": {
"bencode": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/bencode/-/bencode-2.0.3.tgz",
"integrity": "sha512-D/vrAD4dLVX23NalHwb8dSvsUsxeRPO8Y7ToKA015JQYq69MLDOMkC0uGZYA/MPpltLO8rt8eqFC2j8DxjTZ/w=="
},
"simple-sha1": { "simple-sha1": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/simple-sha1/-/simple-sha1-3.1.0.tgz", "resolved": "https://registry.npmjs.org/simple-sha1/-/simple-sha1-3.1.0.tgz",
@ -37179,6 +37203,11 @@
"simple-sha1": "^3.0.1" "simple-sha1": "^3.0.1"
}, },
"dependencies": { "dependencies": {
"bitfield": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/bitfield/-/bitfield-4.1.0.tgz",
"integrity": "sha512-6cEDG3K+PK9f+B7WyhWYjp09bqSa+uaAaecVA7Y5giFixyVe1s6HKGnvOqYNR4Mi4fBMjfDPLBpHkKvzzgP7kg=="
},
"simple-sha1": { "simple-sha1": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/simple-sha1/-/simple-sha1-3.1.0.tgz", "resolved": "https://registry.npmjs.org/simple-sha1/-/simple-sha1-3.1.0.tgz",

View File

@ -107,8 +107,8 @@
"dependencies": { "dependencies": {
"@electron/remote": "^2.0.4", "@electron/remote": "^2.0.4",
"ansi-256-colors": "^1.1.0", "ansi-256-colors": "^1.1.0",
"bencode": "^2.0.2", "bencode": "2.0.1",
"bitfield": "^4.0.0", "bitfield": "3.0.0",
"cheerio": "^1.0.0-rc.10", "cheerio": "^1.0.0-rc.10",
"compare-versions": "^4.1.3", "compare-versions": "^4.1.3",
"create-torrent": "3.33.0", "create-torrent": "3.33.0",

View File

@ -370,19 +370,6 @@ module.exports = async ({
}) })
} }
getTorrentMetadata(); getTorrentMetadata();
// double check torrent magnet
let secondTry = false;
const doubleCheckTimeout = setTimeout(() => {
secondTry = true;
logT('search', 'second try search by dht')
torrentClient.getMetadata(text, (torrent) => {
logT('search', 'dht search found something')
searchList.push(baseRowData(torrent));
callback(searchList);
})
}, 8000)
} }
else else
{ {