diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 6131604..1a6ab0d 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -26,7 +26,7 @@ jobs: - name: Install dependencies run: npm ci --fund=false - name: Type checking - run: npx tsc -p jsconfig.json + run: npm run lint - name: Test project run: npm test env: diff --git a/.gitignore b/.gitignore index 51b002e..13101b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.vscode node_modules output tests/* diff --git a/package-lock.json b/package-lock.json index 4a5bc7d..0abba73 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "insta-downloader", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "insta-downloader", - "version": "2.0.0", + "version": "2.0.1", "dependencies": { "axios": "^1.4.0", "chalk": "^5.3.0", diff --git a/package.json b/package.json index 82ccaf2..fe029a8 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "author": "Alphka", "name": "insta-downloader", - "version": "2.0.0", + "version": "2.0.1", "description": "An application to download content of Instagram with the correct modified date", "main": "src/index.js", "scripts": { "start": "node --no-warnings .", "test": "node --no-warnings --test tests/", - "test:watch": "node --no-warnings --test --watch tests/" + "test:watch": "node --no-warnings --test --watch tests/", + "lint": "tsc -p jsconfig.json" }, "keywords": [ "instagram", diff --git a/src/Downloader.js b/src/Downloader.js index 0543612..26cc04d 100644 --- a/src/Downloader.js +++ b/src/Downloader.js @@ -415,7 +415,7 @@ export default class Downloader { Object.assign(config, { responseType: "arraybuffer" }) /** @type {import("axios").AxiosResponse} */ - const { data } = await axios.get(url, config) + const { data } = await this.Request(url, "GET", config) const { format } = await sharp(data).metadata() const path = join(folder, `${name}.${format === "jpeg" ? "jpg" : format}`) @@ -428,7 +428,7 @@ export default class Downloader { Object.assign(config, { responseType: "stream" }) /** @type {import("axios").AxiosResponse} */ - const { data } = await axios.get(url, config) + const { data } = await this.Request(url, "GET", config) const path = join(folder, filename) const file = createWriteStream(path) @@ -494,7 +494,7 @@ export default class Downloader { if(config.app_id && config.queryHash) return const response = await this.Request(new URL(usernames[0], BASE_URL), "GET", { responseType: "text" }) - const appId = response.data.match(/X-IG-App-ID":"(\d+)"/)?.[1] + const appId = response.data.match(/"X-IG-App-ID":"(\d+)"/)?.[1] const queryHash = response.data.match(/"query_hash":"([a-z0-9]+)"/)?.[1] config.queryHash = queryHash diff --git a/tests/index.test.js b/tests/index.test.js index 8c666f3..d15bf40 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -55,6 +55,7 @@ test("Instagram API", async t => { await t.test("should get app id", async () => { await downloader.CheckServerConfig() + downloader.UpdateHeaders() const { app_id, queryHash } = downloader.config