diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..0049296 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,33 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/README.md b/README.md index 4376363..d5eaf35 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,4 @@ -

- -

- -

- NPM version - Build Status - XO code style - -

- -### A Instagram Private Web API client 🤳✨❤️ +### A Next Instagram Private Web API client 🤳✨❤️ Simple, easy and very complete implementation of the Instagram private web API. @@ -503,4 +492,4 @@ await client.getPhotosByHashtag({ hashtag: 'unicorn' }) ## License -MIT © [Jesús Lobos](https://jlobos.com/) +MIT © [Jesús Lobos](https://jlobos.com/) & [Fskhri](https://github.com/fskhri) diff --git a/lib/index.js b/lib/index.js index 9060571..03a5c79 100644 --- a/lib/index.js +++ b/lib/index.js @@ -106,9 +106,12 @@ class Instagram { async _getSharedData(url = '/') { return this.request(url) .then( - html => html.split('window._sharedData = ')[1].split(';')[0] + html => { + const sharedData = html.split('window._sharedData = ')[1]; + return sharedData ? sharedData.split(';')[0] : null; + } ) - .then(_sharedData => JSON.parse(_sharedData)) + .then(_sharedData => JSON.parse(_sharedData)); } async _getGis(path) {