Commit e1101f3974

e1101f39744944612980261a70b252fda1a9e7a8

parent: 120ecd4298

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-09-30 12:31 UTC

cs3

Layout: unified · split

docs/.vitepress/configs/markdown/extRepoPlugin.ts +3 −1
@@ -164,6 +164,7 @@ export function extRepoPlugin(md: MarkdownIt): void {
164 164
165 const attrs = parseAttrs(params) 165 const attrs = parseAttrs(params)
166 const scheme = attrs.scheme || 'mihon' 166 const scheme = attrs.scheme || 'mihon'
167 const from = attrs.from
167 168
168 const rows: ParsedRepoRow[] = [] 169 const rows: ParsedRepoRow[] = []
169 for (const entry of parseEntries(bodyLines)) { 170 for (const entry of parseEntries(bodyLines)) {
@@ -205,10 +206,11 @@ export function extRepoPlugin(md: MarkdownIt): void {
205 } 206 }
206 207
207 const reposJson = JSON.stringify(rows).replace(/'/g, '&#39;') 208 const reposJson = JSON.stringify(rows).replace(/'/g, '&#39;')
209 const fromAttr = from ? ` from="${from.replace(/"/g, '&quot;')}"` : ''
208 210
209 const token = state.push('html_block', '', 0) 211 const token = state.push('html_block', '', 0)
210 token.map = [startLine, nextLine] 212 token.map = [startLine, nextLine]
211 token.content = `<ExtensionRepos scheme="${scheme}" :repos='${reposJson}' />\n` 213 token.content = `<ExtensionRepos scheme="${scheme}"${fromAttr} :repos='${reposJson}' />\n`
212 214
213 state.line = found ? nextLine + 1 : nextLine 215 state.line = found ? nextLine + 1 : nextLine
214 return true 216 return true
docs/.vitepress/theme/components/extrepo/ExtensionRepos.vue +19 −1
@@ -14,15 +14,33 @@ const { tooltip } = provideTooltip()
14const repoData = data.sites 14const repoData = data.sites
15const soraAuthors = data.soraAuthors 15const soraAuthors = data.soraAuthors
16const echoAuthors = data.echoAuthors 16const echoAuthors = data.echoAuthors
17const repoLists = data.repoLists ?? {}
17 18
18const props = defineProps<{ 19const props = defineProps<{
19 repos: Repo[] 20 repos: Repo[]
20 scheme: string 21 scheme: string
22 from?: string
21}>() 23}>()
22 24
25const baseRepos = computed<Repo[]>(() => {
26 const list = props.from ? repoLists[props.from] ?? [] : []
27 const auto: Repo[] = list.map(entry => ({
28 name: entry.repoUrl
29 ? `<a href="${entry.repoUrl}" target="_blank" rel="noopener noreferrer">${escapeHtml(entry.label)}</a>`
30 : escapeHtml(entry.label),
31 indexUrl: entry.indexUrl,
32 repoName: entry.label,
33 repoUrl: entry.repoUrl
34 }))
35 const manualByUrl = new Map(props.repos.map(repo => [repo.indexUrl, repo]))
36 const merged = [...auto.filter(repo => !manualByUrl.has(repo.indexUrl)), ...props.repos]
37 merged.sort((a, b) => stripHtml(a.name).localeCompare(stripHtml(b.name)))
38 return merged
39})
40
23const resolvedRepos = computed<Repo[]>(() => { 41const resolvedRepos = computed<Repo[]>(() => {
24 const result: Repo[] = [] 42 const result: Repo[] = []
25 for (const repo of props.repos) { 43 for (const repo of baseRepos.value) {
26 const authors = soraAuthors[repo.indexUrl] ?? echoAuthors[repo.indexUrl] 44 const authors = soraAuthors[repo.indexUrl] ?? echoAuthors[repo.indexUrl]
27 if (!authors?.length) { 45 if (!authors?.length) {
28 result.push(repo) 46 result.push(repo)
docs/ext/extensionRepos.data.ts +114 −1
@@ -107,9 +107,21 @@ interface PaperbackIndex {
107} 107}
108 108
109interface CloudstreamRepo { 109interface CloudstreamRepo {
110 name?: string
110 pluginLists: string[] 111 pluginLists: string[]
111} 112}
112 113
114interface CloudstreamRepoListItem {
115 url: string
116 verified?: boolean
117}
118
119export interface RepoListEntry {
120 label: string
121 indexUrl: string
122 repoUrl?: string
123}
124
113interface CloudstreamPlugin { 125interface CloudstreamPlugin {
114 name: string 126 name: string
115 iconUrl?: string 127 iconUrl?: string
@@ -309,6 +321,81 @@ function cachePathFor(url: string): string {
309 return join(CACHE_DIR, `${Buffer.from(url).toString('base64url')}.json`) 321 return join(CACHE_DIR, `${Buffer.from(url).toString('base64url')}.json`)
310} 322}
311 323
324function collectRepoListUrls(): string[] {
325 const urls = new Set<string>()
326 const blockRe = /:::\s*extrepo\s*\{([^}]*)\}/g
327
328 for (const file of findMarkdownFiles(DOCS_DIR)) {
329 const src = readFileSync(file, 'utf-8')
330
331 let match: RegExpExecArray | null
332 blockRe.lastIndex = 0
333 while ((match = blockRe.exec(src))) {
334 const from = match[1].match(/(?:^|\s)from=(?:"([^"]+)"|'([^']+)'|(\S+))/)
335 if (from) urls.add((from[1] ?? from[2] ?? from[3]).trim())
336 }
337 }
338 return [...urls]
339}
340
341function isCloudstreamRepoList(json: unknown): json is Array<string | CloudstreamRepoListItem> {
342 if (!Array.isArray(json) || json.length === 0) return false
343 return json.every(item => {
344 if (typeof item === 'string') return /^https?:\/\//.test(item)
345 if (item && typeof item === 'object') {
346 const rec = item as Record<string, unknown>
347 // LNReader plugins also carry a `url` field — rule those out.
348 if ('name' in rec || 'lang' in rec || 'baseUrl' in rec || 'baseURL' in rec) return false
349 return typeof rec.url === 'string' && /^https?:\/\//.test(rec.url)
350 }
351 return false
352 })
353}
354
355function inferRepoUrl(rawUrl: string): string | undefined {
356 try {
357 const u = new URL(rawUrl)
358 const parts = u.pathname.split('/').filter(Boolean)
359 if (u.hostname === 'raw.githubusercontent.com' && parts.length >= 2) {
360 return `https://github.com/${parts[0]}/${parts[1]}`
361 }
362 const dashRaw = u.pathname.indexOf('/-/raw/')
363 if (dashRaw > 0) return `${u.origin}${u.pathname.slice(0, dashRaw)}`
364 const rawSeg = parts.indexOf('raw')
365 if (rawSeg > 1) return `${u.origin}/${parts.slice(0, rawSeg).join('/')}`
366 } catch {
367 return undefined
368 }
369 return undefined
370}
371
372function inferLabel(rawUrl: string): string {
373 const repoUrl = inferRepoUrl(rawUrl)
374 if (repoUrl) {
375 try {
376 const parts = new URL(repoUrl).pathname.split('/').filter(Boolean)
377 if (parts.length >= 2) return `${parts[parts.length - 2]}/${parts[parts.length - 1]}`
378 if (parts.length === 1) return decodeURIComponent(parts[0])
379 } catch {
380 // fall through to raw-URL fallback below
381 }
382 }
383 try {
384 const parts = new URL(rawUrl).pathname.split('/').filter(Boolean)
385 return decodeURIComponent(parts[parts.length - 2] ?? parts[parts.length - 1] ?? rawUrl)
386 } catch {
387 return rawUrl
388 }
389}
390
391function repoListLabel(indexUrl: string, repoJson: unknown): string {
392 if (repoJson && typeof repoJson === 'object' && !Array.isArray(repoJson)) {
393 const name = (repoJson as { name?: unknown }).name
394 if (typeof name === 'string' && name.trim() !== '') return name.trim()
395 }
396 return inferLabel(indexUrl)
397}
398
312async function fetchIndex(url: string): Promise<unknown> { 399async function fetchIndex(url: string): Promise<unknown> {
313 const cachePath = cachePathFor(url) 400 const cachePath = cachePathFor(url)
314 if (existsSync(cachePath) && Date.now() - statSync(cachePath).mtimeMs < CACHE_TTL_MS) { 401 if (existsSync(cachePath) && Date.now() - statSync(cachePath).mtimeMs < CACHE_TTL_MS) {
@@ -832,6 +919,7 @@ export interface ExtensionRepoData {
832 sites: Record<string, RepoData> 919 sites: Record<string, RepoData>
833 soraAuthors: Record<string, SoraAuthorRepo[]> 920 soraAuthors: Record<string, SoraAuthorRepo[]>
834 echoAuthors: Record<string, EchoAuthorRepo[]> 921 echoAuthors: Record<string, EchoAuthorRepo[]>
922 repoLists: Record<string, RepoListEntry[]>
835} 923}
836 924
837export declare const data: ExtensionRepoData 925export declare const data: ExtensionRepoData
@@ -840,10 +928,35 @@ export default {
840 watch: ['../**/*.md'], 928 watch: ['../**/*.md'],
841 async load(): Promise<ExtensionRepoData> { 929 async load(): Promise<ExtensionRepoData> {
842 const urls = collectIndexUrls() 930 const urls = collectIndexUrls()
931 const listUrls = collectRepoListUrls()
932 const listUrlSet = new Set(listUrls)
843 const sites: Record<string, RepoData> = {} 933 const sites: Record<string, RepoData> = {}
844 const soraAuthors: Record<string, SoraAuthorRepo[]> = {} 934 const soraAuthors: Record<string, SoraAuthorRepo[]> = {}
845 const echoAuthors: Record<string, EchoAuthorRepo[]> = {} 935 const echoAuthors: Record<string, EchoAuthorRepo[]> = {}
936 const repoLists: Record<string, RepoListEntry[]> = {}
937 await Promise.all(listUrls.map(async listUrl => {
938 const json = await fetchIndex(listUrl)
939 if (!isCloudstreamRepoList(json)) {
940 repoLists[listUrl] = []
941 return
942 }
943 const indexUrls = [...new Set(json.map(item => typeof item === 'string' ? item : item.url))]
944 const repoJsons = await Promise.all(indexUrls.map(url => fetchIndex(url)))
945 const entries: RepoListEntry[] = indexUrls.map((indexUrl, i) => ({
946 label: repoListLabel(indexUrl, repoJsons[i]),
947 indexUrl,
948 repoUrl: inferRepoUrl(indexUrl)
949 }))
950 entries.sort((a, b) => a.label.localeCompare(b.label))
951 repoLists[listUrl] = entries
952 await Promise.all(indexUrls.map(async (indexUrl, i) => {
953 if (indexUrl in sites) return
954 sites[indexUrl] = await toRepoData(indexUrl, repoJsons[i])
955 }))
956 }))
846 await Promise.all(urls.map(async url => { 957 await Promise.all(urls.map(async url => {
958 if (listUrlSet.has(url)) return
959 if (url in sites) return
847 const json = await fetchIndex(url) 960 const json = await fetchIndex(url)
848 if (isSoraRepoIndex(json)) { 961 if (isSoraRepoIndex(json)) {
849 const result = await loadSoraRepoIndex(url, json) 962 const result = await loadSoraRepoIndex(url, json)
@@ -861,6 +974,6 @@ export default {
861 } 974 }
862 sites[url] = await toRepoData(url, json) 975 sites[url] = await toRepoData(url, json)
863 })) 976 }))
864 return { sites, soraAuthors, echoAuthors } 977 return { sites, soraAuthors, echoAuthors, repoLists }
865 } 978 }
866} 979}
docs/ext/misc.md +1 −45
@@ -10,60 +10,16 @@ og:
10 10
11## Cloudstream 11## Cloudstream
12 12
13::: extrepo {scheme=cloudstreamrepo} 13::: extrepo {scheme=cloudstreamrepo from=https://raw.githubusercontent.com/recloudstream/cs-repos/refs/heads/master/repos-db.json}
14
15== MegaRepo
16- url: https://github.com/self-similarity/MegaRepo/
17- raw: https://raw.githubusercontent.com/self-similarity/MegaRepo/builds/repo.json
18
19== Aniyomi Compat
20- url: https://github.com/CranberrySoup/AniyomiCompatExtension
21- raw: https://raw.githubusercontent.com/CranberrySoup/AniyomiCompatExtension/master/repo.json
22
23== CakesTwix
24- url: https://github.com/CakesTwix/cloudstream-extensions-uk
25- raw: https://raw.githubusercontent.com/CakesTwix/cloudstream-extensions-uk/master/repo.json
26 14
27== CloudX 15== CloudX
28- url: https://github.com/Asm0d3usX/CloudX-V2 16- url: https://github.com/Asm0d3usX/CloudX-V2
29- raw: https://raw.githubusercontent.com/Asm0d3usX/CloudX/builds/repo.json 17- raw: https://raw.githubusercontent.com/Asm0d3usX/CloudX/builds/repo.json
30 18
31== CSX
32- url: https://github.com/SaurabhKaperwan/CSX
33- raw: https://raw.githubusercontent.com/SaurabhKaperwan/CSX/builds/CS.json
34
35== doGior
36- url: https://github.com/doGior/doGiorsHadEnough
37- raw: https://raw.githubusercontent.com/doGior/doGiorsHadEnough/refs/heads/builds/repo.json
38
39== Gian-Fr
40- url: https://github.com/Gian-Fr/ItalianProvider
41- raw: https://raw.githubusercontent.com/Gian-Fr/ItalianProvider/builds/repo.json
42
43== NetMirror 19== NetMirror
44- url: https://github.com/Sushan64/NetMirror-Extension/ 20- url: https://github.com/Sushan64/NetMirror-Extension/
45- raw: https://raw.githubusercontent.com/Sushan64/NetMirror-Extension/refs/heads/builds/Netflix.json 21- raw: https://raw.githubusercontent.com/Sushan64/NetMirror-Extension/refs/heads/builds/Netflix.json
46 22
47== Phisher
48- url: https://github.com/phisher98/cloudstream-extensions-phisher
49- raw: https://raw.githubusercontent.com/phisher98/cloudstream-extensions-phisher/refs/heads/builds/repo.json
50
51== Raghav
52- url: https://github.com/KSHITIJ8473/raghav
53- raw: https://raw.githubusercontent.com/KSHITIJ8473/raghav/refs/heads/builds/repo.json
54
55== Redowan
56- url: https://github.com/redowan99/Redowan-CloudStream
57- raw: https://raw.githubusercontent.com/redowan99/Redowan-CloudStream/master/repo.json
58
59== Reflex
60- url: https://github.com/Reflex755/ReflexRepo
61- raw: https://raw.githubusercontent.com/Reflex755/ReflexRepo/refs/heads/builds/repo.json
62
63== Tearrs
64- url: https://gitlab.com/tearrs/cloudstream-vietnamese
65- raw: https://gitlab.com/tearrs/cloudstream-vietnamese/-/raw/main/repo.json
66
67== zzikozz 23== zzikozz
68- url: https://codeberg.org/zzikozz/frencharchive/ 24- url: https://codeberg.org/zzikozz/frencharchive/
69- raw: https://codeberg.org/zzikozz/frencharchive/raw/branch/Release/repo.json 25- raw: https://codeberg.org/zzikozz/frencharchive/raw/branch/Release/repo.json