Skip to content

Commit

Permalink
FIX : SushiScans : cloudflare workaround (#5939)
Browse files Browse the repository at this point in the history
Somehow, using the updated HeaderGenerator (#5938) and  setting the useragent and stuff give good results, like being able to download an anetire volume, or update manga list. 

We still got errors 403 but not lire before, its still an improvement

OFC this needs #5938 to work properly
  • Loading branch information
MikeZeDev authored and Sheepux committed Jan 2, 2024
1 parent b74754a commit 97213c0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/web/mjs/connectors/SushiScans.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import WordPressMangastream from './templates/WordPressMangastream.mjs';
import HeaderGenerator from '../engine/HeaderGenerator.mjs';

export default class SushiScans extends WordPressMangastream {

Expand All @@ -9,6 +10,7 @@ export default class SushiScans extends WordPressMangastream {
this.tags = [ 'manga', 'french' ];
this.url = 'https://sushiscan.net';
this.path = '/manga/list-mode/';
this.requestOptions.headers.set('x-referer', this.url);
}

async _getPages(chapter) {
Expand All @@ -26,7 +28,21 @@ export default class SushiScans extends WordPressMangastream {
const uri = new URL(chapter.id, this.url);
let request = new Request(uri, this.requestOptions);
let data = await Engine.Request.fetchUI(request, script);
data = data.filter(link => !link.includes('histats.com'));

// HACK: bypass 'i0.wp.com' image CDN to ensure original images are loaded directly from host
return data.map(link => this.getAbsolutePath(link, request.url).replace(/\/i\d+\.wp\.com/, '')).filter(link => !link.includes('histats.com'));
return data.map(link => this.createConnectorURI(this.getAbsolutePath(link, request.url).replace(/\/i\d+\.wp\.com/, '')));
}

async _handleConnectorURI(payload) {
await this.wait(1500);
let request = new Request(payload, this.requestOptions);
request.headers.set('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8');
request.headers.set('x-user-agent', HeaderGenerator.randomUA());
let response = await fetch(request);
let data = await response.blob();
data = await this._blobToBuffer(data);
this._applyRealMime(data);
return data;
}
}

0 comments on commit 97213c0

Please sign in to comment.