Added Cmoa (#4823)

* add cmoa

* resolve conversation
This commit is contained in:
jude 2022-07-18 06:01:01 +09:00 committed by GitHub
parent e3f5be49c4
commit 4c8ecb4105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 105 additions and 0 deletions

BIN
src/web/img/connectors/cmoa Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -0,0 +1,52 @@
import SpeedBinb from './templates/SpeedBinb.mjs';
import Manga from '../engine/Manga.mjs';
export default class Cmoa extends SpeedBinb {
constructor() {
super();
super.id = 'cmoa';
super.label = 'コミックシーモア (Cmoa)';
this.tags = ['manga', 'japanese'];
this.url = 'https://www.cmoa.jp';
}
async _getMangaFromURI(uri) {
const request = new Request(uri, this.requestOptions);
const dom = await this.fetchDOM(request);
const id = dom.querySelector('#GA_this_page_title_id').textContent.trim();
const title = dom.querySelector('#GA_this_page_title_name').textContent.trim();
return new Manga(this, `/title/${id}/`, title);
}
async _getMangas() {
let msg = 'This website does not provide a manga list, please copy and paste the URL containing the chapters directly from your browser into HakuNeko.';
throw new Error(msg);
}
async _getChapters(manga) {
const request = new Request(new URL(manga.id, this.url), this.requestOptions);
const pages = await this.fetchDOM(request, '#comic_list > .pagination:nth-child(1) li');
const chapters = [];
const totalPage = pages.length == 0 ? 1 : pages.length - 1;
for (let i = 0; i < totalPage; i++) {
const uri = new URL(manga.id, this.url);
uri.searchParams.set('page', i + 1);
const pageRequest = new Request(uri, this.requestOptions);
const data = await this.fetchDOM(pageRequest, '.title_vol_vox_vols .title_vol_vox_vols_i');
for (const element of data) {
const cartButton = element.querySelector('.cart_into_btn');
if (cartButton == null) {
continue;
}
const id = cartButton.getAttribute('_content_id').trim();
const title = element.querySelector('.title_details_title_name_h2').textContent.trim();
chapters.push({
id: `/bib/speedreader/?cid=${id.slice(1, 11)}_jp_${id.slice(11, 15)}&u0=1&u1=0`,
title: title.replace('NEW\n', '').trim(),
});
}
}
return chapters;
}
}

View File

@ -25,6 +25,9 @@ export default class SpeedBinb extends Connector {
uri.searchParams.set('cid', data.dataset['ptbinbCid']);
return this._getPageList_v016113(uri.pathname + uri.search, data.dataset.ptbinb);
}
if( data.dataset['ptbinb'] && data.dataset.ptbinb.includes( 'bibGetCntntInfo' ) && url.searchParams.get('u0') && url.searchParams.get('u1') ) {
return this._getPageList_v016452( chapter.id, data.dataset.ptbinb );
}
if( data.dataset['ptbinb'] && data.dataset.ptbinb.includes( 'bibGetCntntInfo' ) && url.searchParams.get('u1') ) {
return this._getPageList_v016201( chapter.id, data.dataset.ptbinb );
}
@ -197,6 +200,52 @@ export default class SpeedBinb extends Connector {
return Promise.resolve( pageLinks );
} );
}
/**
*************************
*** SpeedBinb v01.6452 ***
* ** Cmoa ***
*************************
*/
async _getPageList_v016452( chapterID, apiURL ) {
const cid = new URL( chapterID, this.baseURL ).searchParams.get( 'cid' );
const u0 = new URL( chapterID, this.baseURL ).searchParams.get( 'u0' );
const u1 = new URL( chapterID, this.baseURL ).searchParams.get( 'u1' );
const sharingKey = this._tt( cid );
let uri;
uri = new URL( apiURL, this.baseURL + '/' );
uri.searchParams.set( 'cid', cid );
uri.searchParams.set( 'dmytime', Date.now() );
uri.searchParams.set( 'k', sharingKey );
uri.searchParams.set( 'u0', u0 );
uri.searchParams.set( 'u1', u1 );
const request = new Request( uri.href, this.requestOptions );
const data = await this.fetchJSON( request );
const params = { cid, sharingKey, u0, u1 };
return this._getPageLinks_v016452( data.items[0], params);
}
_getPageLinks_v016452( configuration, params ) {
configuration.ctbl = this._pt( params.cid, params.sharingKey, configuration.ctbl );
configuration.ptbl = this._pt( params.cid, params.sharingKey, configuration.ptbl );
configuration.ServerType = parseInt(configuration.ServerType);
if( configuration['ServerType'] === 0 ) {
return this._getPageLinksSBC_v016452( configuration, params );
}
return Promise.reject( new Error( 'Content server type not supported!' ) );
}
_getPageLinksSBC_v016452( configuration, params ) {
let uri = new URL( configuration['ContentsServer'] + '/sbcGetCntnt.php', this.baseURL + '/' );
uri.searchParams.set( 'cid', params.cid );
uri.searchParams.set( 'p', configuration['p'] );
uri.searchParams.set( 'q', '1' );
uri.searchParams.set( 'vm', configuration['ViewMode'] );
uri.searchParams.set( 'dmytime', configuration['ContentDate'] );
uri.searchParams.set( 'u0', params.u0 );
uri.searchParams.set( 'u1', params.u1 );
return this._fetchSBC( uri, configuration );
}
/**
*************************
@ -267,6 +316,10 @@ export default class SpeedBinb extends Connector {
uri.searchParams.set( 'dmytime', configuration['ContentDate'] );
uri.searchParams.set( 'p', configuration['p'] );
uri.searchParams.set( 'vm', configuration['ViewMode'] );
return this._fetchSBC( uri, configuration );
}
_fetchSBC( uri, configuration ) {
return fetch( new Request( uri.href, this.requestOptions ) )
.then( response => response.json() )
.then( data => {