Skip to content

Commit

Permalink
PixivComics : get salt from chapter JSON (#7402)
Browse files Browse the repository at this point in the history
😞
  • Loading branch information
MikeZeDev authored Sep 24, 2024
1 parent 2539ae9 commit 909b5d4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/web/mjs/connectors/PixivComics.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ export default class PixivComics extends Connector {
this.apiURL = 'https://comic.pixiv.net/api/app/';
this.requestOptions.headers.set('x-referer', this.url);
this.requestOptions.headers.set('x-requested-with', 'pixivcomic');
this.salt = 'M7w5HORvvX-VP4tRj2CFQOQFPocBqLvHTIbhTU36UCo';
this.nextBuild = 'qLzb8dhGOIox-xYNKI0tH';
}

async _initializeConnector() {
const request = new Request(new URL('viewer/stories/0', this.url), this.requestOptions);
this.salt = await Engine.Request.fetchUI(request, `JSON.parse(document.querySelector('#__NEXT_DATA__').text).props.pageProps.salt`);
const request = new Request(new URL(this.url), this.requestOptions);
const build = await Engine.Request.fetchUI(request, `__NEXT_DATA__.buildId`);
this.nextBuild = build ? build : this.nextBuild; //linter doesnt support ?? syntax
}

async _getMangaFromURI(uri) {
Expand Down Expand Up @@ -81,8 +82,11 @@ export default class PixivComics extends Connector {
}

async _getPages(chapter) {

const { pageProps: { salt } } = await this.fetchJSON(new Request(new URL(`/_next/data/${this.nextBuild}/viewer/stories/${chapter.id}.json?id=${chapter.id}`, this.url)));

const timestamp = new Date().toISOString().replace(/\.\d+Z$/, 'Z');
const hash = CryptoJS.SHA256(timestamp + this.salt).toString(CryptoJS.enc.Hex);
const hash = CryptoJS.SHA256(timestamp + salt).toString(CryptoJS.enc.Hex);
const uri = new URL(`episodes/${chapter.id}/read_v4`, this.apiURL);
const request = new Request(uri, this.requestOptions);
request.headers.set('x-requested-with', 'pixivcomic');
Expand Down

0 comments on commit 909b5d4

Please sign in to comment.