migrate to axios from needle

This commit is contained in:
TheBeastLT
2021-09-18 12:47:38 +02:00
parent a617820fab
commit f2ce9b0543
27 changed files with 1131 additions and 1189 deletions

View File

@@ -1,4 +1,4 @@
const needle = require('needle');
const axios = require('axios');
const magnet = require('magnet-uri');
const { getRandomUserAgent } = require('../lib/requestHelper');
const { getTorrent } = require('../lib/repository');
@@ -48,8 +48,8 @@ async function initBestTrackers() {
async function getBestTrackers(retry = 2) {
const options = { timeout: 30000, headers: { 'User-Agent': getRandomUserAgent() } };
return needle('get', TRACKERS_URL, options)
.then(response => response.body && response.body.trim())
return axios.get(TRACKERS_URL, options)
.then(response => response.data && response.data.trim())
.then(body => body && body.split('\n\n') || [])
.catch(error => {
if (retry === 0) {

887
addon/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,6 +10,7 @@
"dependencies": {
"@putdotio/api-client": "^8.16.0",
"all-debrid-api": "^1.1.0",
"axios": "^0.21.4",
"bottleneck": "^2.19.5",
"cache-manager": "^3.4.4",
"cache-manager-mongodb": "^0.3.0",
@@ -18,7 +19,6 @@
"https-proxy-agent": "^5.0.0",
"magnet-uri": "^6.2.0",
"named-queue": "^2.2.1",
"needle": "^2.2.4",
"parse-torrent-title": "git://github.com/TheBeastLT/parse-torrent-title.git#8fd87b3bfc7aa04143edcd4f0112868bb77dce0f",
"pg": "^8.7.1",
"pg-hstore": "^2.3.4",