Compare commits

...

2 Commits

Author SHA1 Message Date
Cusox.
aafc7078ba Lanraragi ApiKey 鉴权支持 (#148)
* feat: auth with `apiKey`

* chore: revise version
2025-09-01 20:43:17 +08:00
Pacalini
edebc0c430 jm: fix domain api (#147) 2025-09-01 20:43:04 +08:00
3 changed files with 49 additions and 30 deletions

View File

@@ -46,7 +46,7 @@
"name": "禁漫天堂", "name": "禁漫天堂",
"fileName": "jm.js", "fileName": "jm.js",
"key": "jm", "key": "jm",
"version": "1.2.1", "version": "1.2.2",
"description": "禁漫天堂漫畫源, 不能使用時請嘗試切換分流" "description": "禁漫天堂漫畫源, 不能使用時請嘗試切換分流"
}, },
{ {

32
jm.js
View File

@@ -7,22 +7,22 @@ class JM extends ComicSource {
// unique id of the source // unique id of the source
key = "jm" key = "jm"
version = "1.2.1" version = "1.2.2"
minAppVersion = "1.2.5" minAppVersion = "1.2.5"
static jmVersion = "2.0.1" static jmVersion = "2.0.6"
static jmPkgName = "com.example.app" static jmPkgName = "com.example.app"
// update url // update url
url = "https://git.nyne.dev/nyne/venera-configs/raw/branch/main/jm.js" url = "https://git.nyne.dev/nyne/venera-configs/raw/branch/main/jm.js"
static apiDomains = [ static fallbackServers = [
"www.cdnaspa.vip", "www.cdntwice.org",
"www.cdnaspa.club", "www.cdnsha.org",
"www.cdnplaystation6.vip", "www.cdnaspa.cc",
"www.cdnplaystation6.cc" "www.cdnntr.cc",
]; ];
static imageUrl = "https://cdn-msp.jmapinodeudzn.net" static imageUrl = "https://cdn-msp.jmapinodeudzn.net"
@@ -121,11 +121,11 @@ class JM extends ComicSource {
* @param showConfirmDialog {boolean} * @param showConfirmDialog {boolean}
*/ */
async refreshApiDomains(showConfirmDialog) { async refreshApiDomains(showConfirmDialog) {
let url = "https://jmapp03-1308024008.cos.ap-jakarta.myqcloud.com/server-2024.txt" let url = "https://rup4a04-c02.tos-cn-hongkong.bytepluses.com/newsvr-2025.txt"
let domainSecret = "diosfjckwpqpdfjkvnqQjsik" let domainSecret = "diosfjckwpqpdfjkvnqQjsik"
let title = "" let title = ""
let message = "" let message = ""
let jm3_Server = [] let servers = []
let domains = [] let domains = []
let res = await fetch( let res = await fetch(
url, url,
@@ -134,20 +134,20 @@ class JM extends ComicSource {
if (res.status === 200) { if (res.status === 200) {
let data = this.convertData(await res.text(), domainSecret) let data = this.convertData(await res.text(), domainSecret)
let json = JSON.parse(data) let json = JSON.parse(data)
if (json["jm3_Server"]) { if (json["Server"]) {
title = "Update Success" title = "Update Success"
message = "\n" message = "\n"
jm3_Server = json["jm3_Server"] servers = json["Server"].slice(0, 4)
} }
} }
if (jm3_Server.length === 0) { if (servers.length === 0) {
title = "Update Failed" title = "Update Failed"
message = `Using built-in domains:\n\n` message = `Using built-in domains:\n\n`
domains = JM.apiDomains servers = JM.fallbackServers
} }
for (let [domain, index] of jm3_Server) { for (let i = 0; i < servers.length; i++) {
message = message + `${index}: ${domain}\n` message = message + `線路${i + 1}: ${servers[i]}\n\n`
domains.push(domain) domains.push(servers[i])
} }
if (showConfirmDialog) { if (showConfirmDialog) {
UI.showDialog( UI.showDialog(

View File

@@ -2,23 +2,34 @@
class Lanraragi extends ComicSource { class Lanraragi extends ComicSource {
name = "Lanraragi" name = "Lanraragi"
key = "lanraragi" key = "lanraragi"
version = "1.0.0" version = "1.1.0"
minAppVersion = "1.4.0" minAppVersion = "1.4.0"
url = "https://git.nyne.dev/nyne/venera-configs/raw/branch/main/lanraragi.js" url = "https://git.nyne.dev/nyne/venera-configs/raw/branch/main/lanraragi.js"
settings = { settings = {
api: { title: "API", type: "input", default: "http://lrr.tvc-16.science" } api: { title: "API", type: "input", default: "http://lrr.tvc-16.science" },
apiKey: { title: "APIKEY", type: "input", default: "" }
} }
get baseUrl() {
get baseUrl() {
const api = this.loadSetting('api') || this.settings.api.default const api = this.loadSetting('api') || this.settings.api.default
return api.replace(/\/$/, '') return api.replace(/\/$/, '')
} }
get headers() {
let apiKey = this.loadSetting('apiKey')
if (apiKey) apiKey = "Bearer " + Convert.encodeBase64(Convert.encodeUtf8(apiKey))
return {
"Authorization": `${apiKey}`,
}
}
async init() { async init() {
try { try {
const url = `${this.baseUrl}/api/categories` const url = `${this.baseUrl}/api/categories`
const res = await Network.get(url) const res = await Network.get(url, this.headers)
if (res.status !== 200) { this.saveData('categories', []); return } if (res.status !== 200) { this.saveData('categories', []); return }
let data = [] let data = []
try { data = JSON.parse(res.body) } catch (_) { data = [] } try { data = JSON.parse(res.body) } catch (_) { data = [] }
@@ -39,7 +50,7 @@ class Lanraragi extends ComicSource {
explore = [ explore = [
{ title: "Lanraragi", type: "multiPageComicList", load: async (page = 1) => { { title: "Lanraragi", type: "multiPageComicList", load: async (page = 1) => {
const url = `${this.baseUrl}/api/archives` const url = `${this.baseUrl}/api/archives`
const res = await Network.get(url) const res = await Network.get(url, this.headers)
if (res.status !== 200) throw `Invalid status code: ${res.status}` if (res.status !== 200) throw `Invalid status code: ${res.status}`
const data = JSON.parse(res.body) const data = JSON.parse(res.body)
const list = data.slice((page-1)*50, page*50) const list = data.slice((page-1)*50, page*50)
@@ -114,7 +125,7 @@ class Lanraragi extends ComicSource {
add('search[regex]', 'false') add('search[regex]', 'false')
const url = `${base}/search?${qp.join('&')}` const url = `${base}/search?${qp.join('&')}`
const res = await Network.get(url) const res = await Network.get(url, this.headers)
if (res.status !== 200) throw `Invalid status code: ${res.status}` if (res.status !== 200) throw `Invalid status code: ${res.status}`
const data = JSON.parse(res.body) const data = JSON.parse(res.body)
const list = Array.isArray(data.data) ? data.data : [] const list = Array.isArray(data.data) ? data.data : []
@@ -169,7 +180,7 @@ class Lanraragi extends ComicSource {
add('groupby_tanks', groupby) add('groupby_tanks', groupby)
const url = `${base}/api/search?${qp.join('&')}` const url = `${base}/api/search?${qp.join('&')}`
const res = await Network.get(url) const res = await Network.get(url, this.headers)
if (res.status !== 200) throw `Invalid status code: ${res.status}` if (res.status !== 200) throw `Invalid status code: ${res.status}`
const data = JSON.parse(res.body) const data = JSON.parse(res.body)
const all = Array.isArray(data.data) ? data.data : [] const all = Array.isArray(data.data) ? data.data : []
@@ -225,7 +236,7 @@ class Lanraragi extends ComicSource {
comic = { comic = {
loadInfo: async (id) => { loadInfo: async (id) => {
const url = `${this.baseUrl}/api/archives/${id}/metadata` const url = `${this.baseUrl}/api/archives/${id}/metadata`
const res = await Network.get(url) const res = await Network.get(url, this.headers)
if (res.status !== 200) throw `Invalid status code: ${res.status}` if (res.status !== 200) throw `Invalid status code: ${res.status}`
const data = JSON.parse(res.body) const data = JSON.parse(res.body)
const cover = `${this.baseUrl}/api/archives/${id}/thumbnail` const cover = `${this.baseUrl}/api/archives/${id}/thumbnail`
@@ -237,7 +248,7 @@ class Lanraragi extends ComicSource {
}, },
loadThumbnails: async (id, next) => { loadThumbnails: async (id, next) => {
const metaUrl = `${this.baseUrl}/api/archives/${id}/metadata` const metaUrl = `${this.baseUrl}/api/archives/${id}/metadata`
const res = await Network.get(metaUrl) const res = await Network.get(metaUrl, this.headers)
if (res.status !== 200) throw `Invalid status code: ${res.status}` if (res.status !== 200) throw `Invalid status code: ${res.status}`
const data = JSON.parse(res.body) const data = JSON.parse(res.body)
const pagecount = data.pagecount || 1 const pagecount = data.pagecount || 1
@@ -249,7 +260,7 @@ class Lanraragi extends ComicSource {
loadEp: async (comicId, epId) => { loadEp: async (comicId, epId) => {
const base = (this.baseUrl || '').replace(/\/$/, '') const base = (this.baseUrl || '').replace(/\/$/, '')
const url = `${base}/api/archives/${comicId}/files?force=false` const url = `${base}/api/archives/${comicId}/files?force=false`
const res = await Network.get(url) const res = await Network.get(url, this.headers)
if (res.status !== 200) throw `Invalid status code: ${res.status}` if (res.status !== 200) throw `Invalid status code: ${res.status}`
const data = JSON.parse(res.body) const data = JSON.parse(res.body)
const images = (data.pages || []).map(p => { const images = (data.pages || []).map(p => {
@@ -260,8 +271,16 @@ class Lanraragi extends ComicSource {
}).filter(Boolean) }).filter(Boolean)
return { images } return { images }
}, },
// onImageLoad: (url, comicId, epId) => ({}), onImageLoad: (url, comicId, epId) => {
// onThumbnailLoad: (url) => ({}), return {
headers: this.headers
}
},
onThumbnailLoad: (url) => {
return {
headers: this.headers
}
},
// likeComic: async (id, isLike) => {}, // likeComic: async (id, isLike) => {},
// loadComments: async (comicId, subId, page, replyTo) => {}, // loadComments: async (comicId, subId, page, replyTo) => {},
// sendComment: async (comicId, subId, content, replyTo) => {}, // sendComment: async (comicId, subId, content, replyTo) => {},
@@ -272,4 +291,4 @@ class Lanraragi extends ComicSource {
// link: { domains: ['example.com'], linkToId: (url) => null }, // link: { domains: ['example.com'], linkToId: (url) => null },
enableTagsTranslate: false, enableTagsTranslate: false,
} }
} }