Skip to content

Commit

Permalink
Zebrack changes (#234)
Browse files Browse the repository at this point in the history
* Add Zebrack

protobuf based

* Update Zebrack.ts

* zebrack requested changes
  • Loading branch information
MikeZeDev authored Oct 6, 2023
1 parent 7a65610 commit 8af0baa
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 13 deletions.
12 changes: 4 additions & 8 deletions web/src/engine/websites/Zebrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,9 @@ export default class extends DecoratableMangaScraper {
}

public override ValidateMangaURL(url: string): boolean {
return /https?:\/\/zebrack-comic\.shueisha\.co\.jp\/(title|gravure|magazine)\/\d+(\/(issue|volume)\/\d+)?/.test(url);
return /https?:\/\/zebrack-comic\.shueisha\.co\.jp\/(title|gravure|magazine)\/\d+(\/(issue|volume|volume_list)\/\d+)?/.test(url);
}

//title : https://zebrack-comic.shueisha.co.jp/title/5123
///gravure : https://zebrack-comic.shueisha.co.jp/gravure/2188
//Magazine : https://zebrack-comic.shueisha.co.jp/magazine/1/issue/14486/detail
//Volume : https://zebrack-comic.shueisha.co.jp/title/46119/volume/178046

public override async FetchManga(provider: MangaPlugin, url: string): Promise<Manga> {
const uri = new URL(url);
if (/^\/magazine\//.test(uri.pathname)) {
Expand Down Expand Up @@ -216,7 +211,8 @@ export default class extends DecoratableMangaScraper {
public override async FetchPages(chapter: Chapter): Promise<Page[]> {
const [type, titleId, chapterId] = chapter.Identifier.split('/');
const request = new FetchRequest(this.URI.href);
const secretKey = await FetchWindowScript<string>(request, 'localStorage.getItem("device_secret_key") || ""');
const secretKey = await FetchWindowScript<string>(request, `localStorage.getItem('device_secret_key') || ''`);

if (type === 'chapter') {
const data = await this.fetchChapterViewer(titleId, chapterId, secretKey);
if (data.pages) {
Expand Down Expand Up @@ -324,7 +320,7 @@ export default class extends DecoratableMangaScraper {

public override async FetchImage(page: Page, priority: Priority, signal: AbortSignal): Promise<Blob> {
const data = await Common.FetchImageAjax.call(this, page, priority, signal);
const key: string = page.Parameters ? page.Parameters['encryptionKey'] as string : undefined;
const key: string = page.Parameters['encryptionKey'] as string;
if (!key) return data;
const encrypted = await new Response(data).arrayBuffer();
const decrypted = XORDecrypt(new Uint8Array(encrypted), key);
Expand Down
78 changes: 73 additions & 5 deletions web/src/engine/websites/Zebrack_e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TestFixture, type Config } from '../../../test/WebsitesFixture';
import { TestFixture } from '../../../test/WebsitesFixture';

const fixtureMagazine = new TestFixture ({

const config: Config = {
plugin: {
id: 'zebrack',
title: 'Zebrack(ゼブラック)'
Expand All @@ -19,7 +20,74 @@ const config: Config = {
size: 485_738,
type: 'image/jpeg'
}
};
});
describe(fixtureMagazine.Name, () => fixtureMagazine.AssertWebsite());

const fixtureTitle = new TestFixture({
plugin: {
id: 'zebrack',
title: 'Zebrack(ゼブラック)'
},
container: {
url: 'https://zebrack-comic.shueisha.co.jp/title/5123',
id: '/title/5123',
title: 'アオのハコ'
},
child: {
id: 'chapter/5123/132107',
title: '#1 千夏先輩'
},
entry: {
index: 0,
size: 88_836,
type: 'image/jpeg'
}

});
describe(fixtureTitle.Name, () => fixtureTitle.AssertWebsite());

const fixtureGravure = new TestFixture({
plugin: {
id: 'zebrack',
title: 'Zebrack(ゼブラック)'
},
container: {
url: 'https://zebrack-comic.shueisha.co.jp/gravure/2188',
id: '/gravure/2188',
title: '馬場ふみか 「Asian Rendez-Vous」'
},
child: {
id: 'gravure/2188',
title: '馬場ふみか 「Asian Rendez-Vous」'
},
entry: {
index: 0,
size: 197_698,
type: 'image/jpeg'
}

});
describe(fixtureGravure.Name, () => fixtureGravure.AssertWebsite());

const fixtureVolume = new TestFixture({
plugin: {
id: 'zebrack',
title: 'Zebrack(ゼブラック)'
},
container: {
url: 'https://zebrack-comic.shueisha.co.jp/title/46119/volume/178046',
id: '/title/46119/volume/178046',
title: ''
},
child: {
id: 'volume/46119/178046',
title: 'テンマクキネマ 1'
},
entry: {
index: 0,
size: 276_381,
type: 'image/jpeg'
}

const fixture = new TestFixture(config);
describe(fixture.Name, () => fixture.AssertWebsite());
});
describe(fixtureVolume.Name, () => fixtureGravure.AssertWebsite());

0 comments on commit 8af0baa

Please sign in to comment.