Skip to content

Commit

Permalink
remove last usage of request
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan1986 committed Mar 20, 2024
1 parent a32b968 commit a4b3c63
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"patch-package": "^8.0",
"postinstall-postinstall": "^2.1.0",
"readdirp": "2.x.x",
"request": "2.88.x",
"rimraf": "^3.0.0",
"sanitizer": "0.x.x",
"semver": "^7.5",
Expand Down
1 change: 0 additions & 1 deletion src/app/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var _ = require('underscore'),
url = require('url'),
tls = require('tls'),
http = require('http'),
request = require('request'),
// Web
URI = require('urijs'),
Trakt = require('trakt.tv'),
Expand Down
23 changes: 11 additions & 12 deletions src/app/lib/streamer.js
Original file line number Diff line number Diff line change
Expand Up @@ -709,20 +709,19 @@ const FileServer = require("./lib/file-server");
}
},

saveCoverToFile: function (location) {
saveCoverToFile: async function (location) {
if (this.torrentModel && this.torrentModel.get('type') === 'movie' && this.torrentModel.get('cover') && this.torrentModel.get('torrent').name) {
const request = require('request');
let url = this.torrentModel.get('cover');
request({ url, encoding: null }, (err, resp, buffer) => {
if (err || buffer.length < 1000) {
return;
}
try {
fs.writeFileSync(path.join(location, this.torrentModel.get('torrent').name) + '/cover.jpg', buffer);
} catch (err) {
fs.writeFileSync(location + '/' + this.torrentModel.get('torrent').name + '_cover.jpg', buffer);
}
});
const res = await fetch(url);
const buffer = await res.arrayBuffer();
if (buffer.byteLength < 1000) {
return;
}
try {
fs.writeFileSync(path.join(location, this.torrentModel.get('torrent').name) + '/cover.jpg', Buffer.from(buffer));
} catch (err) {
fs.writeFileSync(location + '/' + this.torrentModel.get('torrent').name + '_cover.jpg', Buffer.from(buffer));
}
}
},

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6263,7 +6263,7 @@ replace-homedir@^1.0.0:
is-absolute "^1.0.0"
remove-trailing-separator "^1.1.0"

request@2.88.2, request@2.88.x:
request@2.88.2:
version "2.88.2"
resolved "https://registry.npmjs.org/request/-/request-2.88.2.tgz"
integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==
Expand Down

0 comments on commit a4b3c63

Please sign in to comment.