mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
try to fix putio
This commit is contained in:
@@ -151,14 +151,10 @@ async function _unrestrictLink(Putio, torrent, encodedFileName, fileIndex) {
|
||||
}
|
||||
|
||||
async function _unrestrictVideo(Putio, videoId) {
|
||||
const publicToken = await _getPublicToken(Putio, videoId);
|
||||
const publicFile = await Putio.File.Public(publicToken).then(response => response.data.parent);
|
||||
|
||||
if (!publicFile?.stream_url?.length) {
|
||||
return Promise.reject(`No Putio links found for [${videoId}]`);
|
||||
}
|
||||
console.log(`Unrestricted Putio [${videoId}] to ${publicFile.stream_url}`);
|
||||
return publicFile.stream_url;
|
||||
const response = await Putio.File.GetStorageURL(videoId);
|
||||
const downloadUrl = response.data.url
|
||||
console.log(`Unrestricted Putio [${videoId}] to ${downloadUrl}`);
|
||||
return downloadUrl;
|
||||
}
|
||||
|
||||
async function _getTargetFile(Putio, torrent, encodedFileName, fileIndex) {
|
||||
@@ -174,7 +170,7 @@ async function _getTargetFile(Putio, torrent, encodedFileName, fileIndex) {
|
||||
// when it's not defined find all videos and take the largest one
|
||||
targetFile = Number.isInteger(fileIndex)
|
||||
? videos.find(video => sameFilename(targetFileName, video.name))
|
||||
: !folders.length && videos.toSorted((a, b) => b.size - a.size)[0];
|
||||
: !folders.length && videos.sort((a, b) => b.size - a.size)[0];
|
||||
files = !targetFile
|
||||
? await Promise.all(folders.map(folder => _getFiles(Putio, folder.id)))
|
||||
.then(results => results.reduce((a, b) => a.concat(b), []))
|
||||
@@ -191,19 +187,6 @@ async function _getFiles(Putio, fileId) {
|
||||
: [response.data.parent];
|
||||
}
|
||||
|
||||
async function _getPublicToken(Putio, targetVideoId) {
|
||||
const publicLinks = await Putio.Files.PublicShares().then(response => response.data.links);
|
||||
const alreadySharedLink = publicLinks.find(link => link.user_file.id === targetVideoId);
|
||||
if (alreadySharedLink) {
|
||||
return alreadySharedLink.token;
|
||||
}
|
||||
if (publicLinks.length >= 10) {
|
||||
// maximum public shares reached, revoke last one;
|
||||
await Putio.File.RevokePublicLink(publicLinks[0].id);
|
||||
}
|
||||
return Putio.File.CreatePublicLink(targetVideoId).then(response => response.data.token);
|
||||
}
|
||||
|
||||
function createPutioAPI(apiKey) {
|
||||
const clientId = apiKey.replace(/@.*/, '');
|
||||
const token = apiKey.replace(/.*@/, '');
|
||||
|
||||
8
addon/package-lock.json
generated
8
addon/package-lock.json
generated
@@ -9,7 +9,7 @@
|
||||
"version": "1.0.14",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@putdotio/api-client": "^8.39.0",
|
||||
"@putdotio/api-client": "^8.42.0",
|
||||
"all-debrid-api": "^1.1.0",
|
||||
"axios": "^1.6.1",
|
||||
"bottleneck": "^2.19.5",
|
||||
@@ -37,9 +37,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@putdotio/api-client": {
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@putdotio/api-client/-/api-client-8.39.0.tgz",
|
||||
"integrity": "sha512-xQJ+tuKmTo/gy+WFat86Avhqy8mlIZF2ZpbzBQc8173LTvRcrf9E7B8dKqz/P0pjLn+kM/IkiKwmudV9Q8NXdw==",
|
||||
"version": "8.42.0",
|
||||
"resolved": "https://registry.npmjs.org/@putdotio/api-client/-/api-client-8.42.0.tgz",
|
||||
"integrity": "sha512-LaFaPMOO8WbvwzUlvuzBcBH9aSpqZIkA6MuoKJPNZ293kFSMZPyXkE/VddVXPNq0f5sp7HzdueCMIPOxcom9hg==",
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"event-emitter": "^0.3.5",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"author": "TheBeastLT <pauliox@beyond.lt>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@putdotio/api-client": "^8.39.0",
|
||||
"@putdotio/api-client": "^8.42.0",
|
||||
"all-debrid-api": "^1.1.0",
|
||||
"axios": "^1.6.1",
|
||||
"bottleneck": "^2.19.5",
|
||||
|
||||
Reference in New Issue
Block a user