dl-librescore
Advanced tools
Comparing version 0.34.62 to 0.35.1
{ | ||
"name": "dl-librescore", | ||
"version": "0.34.62", | ||
"version": "0.35.1", | ||
"description": "Download sheet music", | ||
@@ -40,2 +40,3 @@ "main": "dist/main.user.js", | ||
"inquirer": "^8.2.4", | ||
"md5": "^2.3.0", | ||
"node-fetch": "^2.6.7", | ||
@@ -52,2 +53,3 @@ "ora": "^5.4.1", | ||
"@types/inquirer": "^8.2.1", | ||
"@types/md5": "^2.3.5", | ||
"@types/pdfkit": "^0.12.6", | ||
@@ -54,0 +56,0 @@ "@types/yargs": "^17.0.10", |
/* eslint-disable no-extend-native */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-return */ | ||
import isNodeJs from "detect-node"; | ||
import md5 from "md5"; | ||
import { getFetch } from "./utils"; | ||
@@ -14,10 +14,14 @@ import { auths } from "./file-magics"; | ||
const getApiAuth = (id: number, type: FileType, index: number): string => { | ||
const suffix = "et"; | ||
const code = `${id}${type}${index}${suffix}`; | ||
return md5(code).slice(0, 4); | ||
}; | ||
let imgInProgress = false; | ||
const getApiAuth = async (type: FileType, index: number): Promise<string> => { | ||
if (isNodeJs) { | ||
// fix later | ||
throw Error; | ||
} | ||
const getApiAuthNetwork = async ( | ||
type: FileType, | ||
index: number | ||
): Promise<string> => { | ||
let numPages = 0; | ||
@@ -122,17 +126,27 @@ let pageCooldown = 25; | ||
): Promise<string> => { | ||
let r; | ||
const url = getApiUrl(id, type, index); | ||
const auth = await getApiAuth(type, index); | ||
if (type === "img" && index === 0) { | ||
// auth is the URL for the first page | ||
r = await _fetch(auth); | ||
} else { | ||
r = await _fetch(url, { | ||
headers: { | ||
Authorization: auth, | ||
}, | ||
}); | ||
let auth = getApiAuth(id, type, index); | ||
let r = await _fetch(url, { | ||
headers: { | ||
Authorization: auth, | ||
}, | ||
}); | ||
if (!r.ok) { | ||
auth = await getApiAuthNetwork(type, index); | ||
if (type === "img" && index === 0) { | ||
// auth is the URL for the first page | ||
r = await _fetch(auth); | ||
} else { | ||
r = await _fetch(url, { | ||
headers: { | ||
Authorization: auth, | ||
}, | ||
}); | ||
} | ||
} | ||
const { info } = await r.json(); | ||
return info.url as string; | ||
}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Telemetry
Supply chain riskThis package contains telemetry which tracks how it is used.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Telemetry
Supply chain riskThis package contains telemetry which tracks how it is used.
Found 1 instance in 1 package
3661864
82987
11
17
+ Addedmd5@^2.3.0
+ Addedcharenc@0.0.2(transitive)
+ Addedcrypt@0.0.2(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedmd5@2.3.0(transitive)