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": "禁漫天堂",
"fileName": "jm.js",
"key": "jm",
"version": "1.2.1",
"version": "1.2.2",
"description": "禁漫天堂漫畫源, 不能使用時請嘗試切換分流"
},
{

32
jm.js
View File

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

View File

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