mirror of
https://github.com/venera-app/venera-configs.git
synced 2025-09-27 08:27:24 +00:00
[ehentai] add onLoadFailed;
update template
This commit is contained in:
@@ -560,74 +560,20 @@ class NewComicSource extends ComicSource {
|
|||||||
* @param url
|
* @param url
|
||||||
* @param comicId
|
* @param comicId
|
||||||
* @param epId
|
* @param epId
|
||||||
* @returns {{} | Promise<{}>}
|
* @returns {ImageLoadingConfig | Promise<ImageLoadingConfig>}
|
||||||
*/
|
*/
|
||||||
onImageLoad: (url, comicId, epId) => {
|
onImageLoad: (url, comicId, epId) => {
|
||||||
/*
|
|
||||||
```
|
|
||||||
return {
|
|
||||||
url: `${url}?id=comicId`,
|
|
||||||
// http method
|
|
||||||
method: 'GET',
|
|
||||||
// any
|
|
||||||
data: null,
|
|
||||||
headers: {
|
|
||||||
'user-agent': 'pica_comic/v3.1.0',
|
|
||||||
},
|
|
||||||
// * modify response data
|
|
||||||
// * @param data {ArrayBuffer}
|
|
||||||
// * @returns {ArrayBuffer}
|
|
||||||
onResponse: (data) => {
|
|
||||||
return data
|
|
||||||
},
|
|
||||||
// {string | null} a js script. The script will be executed in a new Isolate.
|
|
||||||
// The script should contain a function named `modifyImage`, which receives an [Image] as the only argument, and returns an [Image].
|
|
||||||
// Only [Image] api is available in the script.
|
|
||||||
// Do not use this field if it is not necessary.
|
|
||||||
modifyImage: `
|
|
||||||
function modifyImage(buffer) {
|
|
||||||
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* [Optional] provide configs for a thumbnail loading
|
* [Optional] provide configs for a thumbnail loading
|
||||||
* @param url {string}
|
* @param url {string}
|
||||||
* @returns {{}}
|
* @returns {ImageLoadingConfig | Promise<ImageLoadingConfig>}
|
||||||
|
*
|
||||||
|
* `ImageLoadingConfig.modifyImage` and `ImageLoadingConfig.onLoadFailed` will be ignored.
|
||||||
|
* They are not supported for thumbnails.
|
||||||
*/
|
*/
|
||||||
onThumbnailLoad: (url) => {
|
onThumbnailLoad: (url) => {
|
||||||
/*
|
|
||||||
```
|
|
||||||
return {
|
|
||||||
url: `${url}?id=comicId`,
|
|
||||||
// http method
|
|
||||||
method: 'GET',
|
|
||||||
// {any}
|
|
||||||
data: null,
|
|
||||||
headers: {
|
|
||||||
'user-agent': 'pica_comic/v3.1.0',
|
|
||||||
},
|
|
||||||
// modify response data
|
|
||||||
onResponse: (data) => {
|
|
||||||
return data
|
|
||||||
},
|
|
||||||
// {string | null} a js script. The script will be executed in a new Isolate.
|
|
||||||
// The script should contain a function named `modifyImage`, which receives an [Image] as the only argument, and returns an [Image].
|
|
||||||
// Only [Image] api is available in the script.
|
|
||||||
// Do not use this field if it is not necessary.
|
|
||||||
modifyImage: `
|
|
||||||
function modifyImage(image) {
|
|
||||||
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
27
_venera_.js
27
_venera_.js
@@ -940,6 +940,33 @@ function Comment({userName, avatar, content, time, replyCount, id, isLiked, scor
|
|||||||
this.voteStatus = voteStatus;
|
this.voteStatus = voteStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create image loading config
|
||||||
|
* @param url {string?}
|
||||||
|
* @param method {string?} - http method, uppercase
|
||||||
|
* @param data {any} - request data, may be null
|
||||||
|
* @param headers {Object?} - request headers
|
||||||
|
* @param onResponse {((ArrayBuffer) => ArrayBuffer)?} - modify response data
|
||||||
|
* @param modifyImage {string?}
|
||||||
|
* A js script string.
|
||||||
|
* The script will be executed in a new Isolate.
|
||||||
|
* A function named `modifyImage` should be defined in the script, which receives an [Image] as the only argument, and returns an [Image]..
|
||||||
|
* @param onLoadFailed {(() => ImageLoadingConfig)?} - called when the image loading failed
|
||||||
|
* @constructor
|
||||||
|
* @since 1.0.5
|
||||||
|
*
|
||||||
|
* To keep the compatibility with the old version, do not use the constructor. Consider creating a new object with the properties directly.
|
||||||
|
*/
|
||||||
|
function ImageLoadingConfig({url, method, data, headers, onResponse, modifyImage, onLoadFailed}) {
|
||||||
|
this.url = url;
|
||||||
|
this.method = method;
|
||||||
|
this.data = data;
|
||||||
|
this.headers = headers;
|
||||||
|
this.onResponse = onResponse;
|
||||||
|
this.modifyImage = modifyImage;
|
||||||
|
this.onLoadFailed = onLoadFailed;
|
||||||
|
}
|
||||||
|
|
||||||
class ComicSource {
|
class ComicSource {
|
||||||
name = ""
|
name = ""
|
||||||
|
|
||||||
|
20
ehentai.js
20
ehentai.js
@@ -7,7 +7,7 @@ class Ehentai extends ComicSource {
|
|||||||
// unique id of the source
|
// unique id of the source
|
||||||
key = "ehentai"
|
key = "ehentai"
|
||||||
|
|
||||||
version = "1.0.5"
|
version = "1.0.6"
|
||||||
|
|
||||||
minAppVersion = "1.0.0"
|
minAppVersion = "1.0.0"
|
||||||
|
|
||||||
@@ -837,16 +837,15 @@ class Ehentai extends ComicSource {
|
|||||||
* @param image
|
* @param image
|
||||||
* @param comicId
|
* @param comicId
|
||||||
* @param epId
|
* @param epId
|
||||||
|
* @param nl
|
||||||
* @returns {{}}
|
* @returns {{}}
|
||||||
*/
|
*/
|
||||||
onImageLoad: async (image, comicId, epId) => {
|
onImageLoad: async (image, comicId, epId, nl) => {
|
||||||
let first = await this.comic.loadThumbnails(comicId)
|
let first = await this.comic.loadThumbnails(comicId)
|
||||||
console.log(first)
|
console.log(first)
|
||||||
let key = await this.comic.getKey(first.urls[0])
|
let key = await this.comic.getKey(first.urls[0])
|
||||||
let page = Number(image)
|
let page = Number(image)
|
||||||
|
|
||||||
console.log(key)
|
|
||||||
|
|
||||||
let getImageFromApi = async (nl) => {
|
let getImageFromApi = async (nl) => {
|
||||||
if(key.mpvkey) {
|
if(key.mpvkey) {
|
||||||
let res = await Network.post(this.apiUrl, {
|
let res = await Network.post(this.apiUrl, {
|
||||||
@@ -904,13 +903,22 @@ class Ehentai extends ComicSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = await getImageFromApi()
|
let res = await getImageFromApi(nl)
|
||||||
|
|
||||||
|
let onLoadFailed = null
|
||||||
|
|
||||||
|
if(res.nl) {
|
||||||
|
onLoadFailed = async () => {
|
||||||
|
return this.comic.onImageLoad(image, comicId, epId, res.nl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: res.url,
|
url: res.url,
|
||||||
headers: {
|
headers: {
|
||||||
'referer': this.baseUrl,
|
'referer': this.baseUrl,
|
||||||
}
|
},
|
||||||
|
onLoadFailed: onLoadFailed,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@@ -45,7 +45,7 @@
|
|||||||
"name": "ehentai",
|
"name": "ehentai",
|
||||||
"fileName": "ehentai.js",
|
"fileName": "ehentai.js",
|
||||||
"key": "ehentai",
|
"key": "ehentai",
|
||||||
"version": "1.0.5"
|
"version": "1.0.6"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "禁漫天堂",
|
"name": "禁漫天堂",
|
||||||
|
Reference in New Issue
Block a user