Commit 323b6de462

323b6de462a42e1817807c661cd4a93a671fbb3b

parent: 2dbb464f92

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-05-23 12:46 UTC

scrapetable

Layout: unified · split

docs/.vitepress/configs/markdown/index.ts +2
@@ -19,6 +19,7 @@ import { getTooltip } from '../../utils/tooltips'
19import { headersPlugin } from '../markdown/headers' 19import { headersPlugin } from '../markdown/headers'
20import { emojiRender } from './emoji' 20import { emojiRender } from './emoji'
21import markdownSteps from './steps' 21import markdownSteps from './steps'
22import { scrapeTablePlugin } from './scrapeTablePlugin'
22 23
23export function configureMarkdown(md: MarkdownRenderer) { 24export function configureMarkdown(md: MarkdownRenderer) {
24 md.use(emojiRender) 25 md.use(emojiRender)
@@ -39,6 +40,7 @@ export function configureMarkdown(md: MarkdownRenderer) {
39 renderTooltip(md) 40 renderTooltip(md)
40 renderInlineTooltip(md) 41 renderInlineTooltip(md)
41 md.use(markdownSteps) 42 md.use(markdownSteps)
43 md.use(scrapeTablePlugin)
42 renderHighlight(md) 44 renderHighlight(md)
43} 45}
44 46
docs/.vitepress/configs/markdown/scrapeTablePlugin.ts added +168
@@ -0,0 +1,168 @@
1import type MarkdownIt from 'markdown-it'
2
3// Types
4
5interface ParsedEntry {
6 source: string
7 metadata: string[]
8}
9
10interface ParsedSite {
11 name: string
12 entries: ParsedEntry[]
13}
14
15interface ParsedBlock {
16 cornerLabel: string | null
17 sites: ParsedSite[]
18}
19
20// Parser
21
22function parseCornerLabel(info: string): string | null {
23 const match = info.match(/\{([^}]*)\}/)
24 return match ? match[1].trim() || null : null
25}
26
27function parseEntry(raw: string): ParsedEntry | null {
28 const trimmed = raw.trim()
29 if (!trimmed.startsWith('(') || !trimmed.endsWith(')')) return null
30 const inner = trimmed.slice(1, -1)
31 const parts = inner.split(',').map(s => s.trim()).filter(Boolean)
32 if (parts.length === 0) return null
33 const [source, ...metadata] = parts
34 return { source, metadata }
35}
36
37function parseSiteRow(line: string): ParsedSite | null {
38 const match = line.match(/^-\s+(.+)$/)
39 if (!match) return null
40 const rest = match[1]
41 const colonIdx = rest.indexOf(':')
42 if (colonIdx === -1) return null
43 const siteName = rest.slice(0, colonIdx).trim()
44 if (!siteName) return null
45 const entryStr = rest.slice(colonIdx + 1).replace(/;\s*$/, '').trim()
46
47 const rawEntries = entryStr
48 .split(/\)\s*,\s*(?=\()/)
49 .map(s => s.trim())
50 .filter(Boolean)
51 .map((s, i, arr) => (i < arr.length - 1 && !s.endsWith(')') ? s + ')' : s))
52
53 const entries: ParsedEntry[] = []
54 for (const raw of rawEntries) {
55 const entry = parseEntry(raw)
56 if (entry) entries.push(entry)
57 }
58 return { name: siteName, entries }
59}
60
61function parseBlock(info: string, body: string): ParsedBlock {
62 const cornerLabel = parseCornerLabel(info)
63 const sites: ParsedSite[] = []
64 for (const line of body.split('\n')) {
65 const site = parseSiteRow(line.trim())
66 if (site) sites.push(site)
67 }
68 return { cornerLabel, sites }
69}
70
71// Code generator
72
73function escStr(s: string): string {
74 return s.replace(/\\/g, '\\\\').replace(/'/g, "\\'")
75}
76
77function generateComponent(block: ParsedBlock): string {
78 const sitesJson = JSON.stringify(
79 block.sites.map(site => {
80 const scrapes: Record<string, string | { name: string; metadata: string[] }> = {}
81 for (const entry of site.entries) {
82 const [playerName, ...tags] = entry.metadata
83 if (!playerName) {
84 scrapes[entry.source] = ""
85 } else if (tags.length === 0) {
86 scrapes[entry.source] = playerName
87 } else {
88 scrapes[entry.source] = { name: playerName, metadata: tags }
89 }
90 }
91 return { name: site.name, scrapes }
92 }),
93 null,
94 0,
95 )
96
97 const cornerProp = block.cornerLabel
98 ? ` corner-label="${escStr(block.cornerLabel)}"`
99 : ''
100
101 return `<ScrapeTable${cornerProp} :sites='${sitesJson.replace(/'/g, "\\'")}' />\n`
102}
103
104// Plugin
105
106export function scrapeTablePlugin(md: MarkdownIt): void {
107
108 const MARKER = ':'
109 const MIN_MARKERS = 3
110 const NAME = 'scrapetable'
111
112 md.block.ruler.before(
113 'fence',
114 'scrape_table',
115 (state, startLine, endLine, silent) => {
116 let pos = state.bMarks[startLine] + state.tShift[startLine]
117 let max = state.eMarks[startLine]
118
119 // Count opening colons
120 let markerCount = 0
121 while (pos < max && state.src[pos] === MARKER) {
122 pos++
123 markerCount++
124 }
125 if (markerCount < MIN_MARKERS) return false
126
127 // Must be followed by optional space then "scrapetable"
128 const markup = state.src.slice(state.bMarks[startLine] + state.tShift[startLine], pos)
129 const params = state.src.slice(pos, max).trim()
130 if (!params.toLowerCase().startsWith(NAME)) return false
131
132 if (silent) return true
133
134 // Find closing fence (same or more colons)
135 let nextLine = startLine + 1
136 let found = false
137 while (nextLine < endLine) {
138 let p = state.bMarks[nextLine] + state.tShift[nextLine]
139 const m = state.eMarks[nextLine]
140 if (p < m && state.sCount[nextLine] < state.blkIndent) break
141
142 let cnt = 0
143 while (p < m && state.src[p] === MARKER) { p++; cnt++ }
144 if (cnt >= markerCount && state.src.slice(p, m).trim() === '') {
145 found = true
146 break
147 }
148 nextLine++
149 }
150
151 // Collect body lines
152 const bodyLines: string[] = []
153 for (let i = startLine + 1; i < nextLine; i++) {
154 bodyLines.push(state.src.slice(state.bMarks[i], state.eMarks[i]))
155 }
156 const body = bodyLines.join('\n')
157 const block = parseBlock(params, body)
158
159 const token = state.push('html_block', '', 0)
160 token.map = [startLine, nextLine]
161 token.content = generateComponent(block)
162
163 state.line = found ? nextLine + 1 : nextLine
164 return true
165 },
166 { alt: ['paragraph', 'reference', 'blockquote', 'list'] }
167 )
168}\ No newline at end of file
docs/.vitepress/theme/components/ScrapeTable.vue +6 −1
@@ -174,7 +174,12 @@ onMounted(() => {
174 </colgroup> 174 </colgroup>
175 <thead> 175 <thead>
176 <tr> 176 <tr>
177 <th class="corner">{{ cornerLabel ?? 'Sources' }}</th> 177 <th class="corner">
178 {{ cornerLabel ?? 'Sources' }}
179 <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" style="display:inline-block;vertical-align:middle;margin-left:4px;color:inherit">
180 <path fill="currentColor" d="m12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"/>
181 </svg>
182 </th>
178 <th v-for="source in sources" :key="source" class="source-header"> 183 <th v-for="source in sources" :key="source" class="source-header">
179 <span>{{ source }}</span> 184 <span>{{ source }}</span>
180 </th> 185 </th>
docs/ext/index.md +10 −10
@@ -30,16 +30,16 @@ og:
30 30
31 31
32## Cross-app Support 32## Cross-app Support
33<ScrapeTable :sites="[ 33::: scrapetable
34 { name: 'Anymex', scrapes: { 'Mihon': '', 'Aniyomi': '', 'Mangayomi': '', 'Sora': '', 'Cloudstream': '', 'LNreader': '' } }, 34- Anymex : (Mihon), (Aniyomi), (Mangayomi), (Sora), (Cloudstream), (LNreader);
35 { name: 'Cloudstream', scrapes: { 'Cloudstream': '', 'Aniyomi': '' } }, 35- Cloudstream : (Cloudstream), (Aniyomi);
36 { name: 'Dantotsu', scrapes: { 'Mihon': '', 'Aniyomi': '', 'LNreader': '' } }, 36- Dantotsu : (Mihon), (Aniyomi), (LNreader);
37 { name: 'Futon', scrapes: { 'Kotatsu': '', 'Mihon': '' } }, 37- Futon : (Kotatsu), (Mihon);
38 { name: 'IReader', scrapes: { 'IReader': '', 'LNreader': '', 'Legado': '' } }, 38- IReader : (IReader), (LNreader), (Legado);
39 { name: 'Kototoro', scrapes: { 'Mihon': '', 'Aniyomi': '', 'Kotatsu': '', 'LNReader': '', 'Legado': '', 'IReader': '' } }, 39- Kototoro : (Mihon), (Aniyomi), (Kotatsu), (LNReader), (Legado), (IReader);
40 { name: 'Mangayomi', scrapes: { 'Mihon': '', 'Aniyomi': '', 'Mangayomi': '' } }, 40- Mangayomi : (Mihon), (Aniyomi), (Mangayomi);
41 { name: 'Usagi', scrapes: { 'Kotatsu': '', 'Mihon': '', 'LNreader': '' } } 41- Usagi : (Kotatsu), (Mihon), (LNreader);
42]" /> 42:::
43 43
44 44
45::: tip README 45::: tip README
docs/misc.md +13 −13
@@ -29,19 +29,19 @@ outline: [1,2]
29 29
30</collapsible> 30</collapsible>
31 31
32<ScrapeTable corner-label="Topics" :sites="[ 32::: scrapetable {Topics}
33 { name: 'AniList', scrapes: { 'Anime': '', 'Manga': '', 'Novels': '' } }, 33- AniList : (Anime), (Manga), (Novels);
34 { name: 'Anime Planet', scrapes: { 'Anime': '', 'Manga': '' } }, 34- Anime Planet : (Anime), (Manga);
35 { name: 'aniSearch', scrapes: { 'Anime': '', 'Manga': '', 'Novels': '', 'Live Action': '', 'Tokusatsu': '' } }, 35- aniSearch : (Anime), (Manga), (Novels), (Live Action), (Tokusatsu);
36 { name: 'ANN', scrapes: { 'Anime': '', 'Manga': ''} }, 36- ANN : (Anime), (Manga);
37 { name: 'Bookmeter', scrapes: { 'Manga': '', 'Novels': '', 'Non-fiction': '' } }, 37- Bookmeter : (Manga), (Novels), (Non-fiction);
38 { name: 'Hanmoto', scrapes: { 'Manga': '', 'Novels': '', 'Non-fiction': '' } }, 38- Hanmoto : (Manga), (Novels), (Non-fiction);
39 { name: 'Kitsu', scrapes: { 'Anime': '', 'Manga': '' } }, 39- Kitsu : (Anime), (Manga);
40 { name: 'Kurozora', scrapes: { 'Anime': '', 'Manga': '', 'Games': '' } }, 40- Kurozora : (Anime), (Manga), (Games);
41 { name: 'MangaBaka', scrapes: { 'Manga': '', 'Novels': '' } }, 41- MangaBaka : (Manga), (Novels);
42 { name: 'MyAnimeList', scrapes: { 'Anime': '', 'Manga': '', 'Novels': '' } }, 42- MyAnimeList : (Anime), (Manga), (Novels);
43 { name: 'Sakuhin Database', scrapes: { 'Anime': '', 'Manga': '', 'Novels': '', 'Games': '', 'Live Action': '', 'Tokusatsu': '' } }, 43- Sakuhin Database : (Anime), (Manga), (Novels), (Games), (Live Action), (Tokusatsu);
44]" /> 44:::
45 45
46::: tip README 46::: tip README
47- **Novels**: All the types of novels (LN, WN etc.) are grouped in one category. 47- **Novels**: All the types of novels (LN, WN etc.) are grouped in one category.
docs/websites.md +14 −14
@@ -50,13 +50,14 @@ outline: 1
50| [Animetsu](https://animetsu.net/) [:prx:](https://rentry.org/wotaxy#animetsu) | :yes: | :ie::msync: | :cc::oc: | 50| [Animetsu](https://animetsu.net/) [:prx:](https://rentry.org/wotaxy#animetsu) | :yes: | :ie::msync: | :cc::oc: |
51| [AnimeX](https://animex.one/home) | :yes: | :sync::ie: | :cc::oc: | 51| [AnimeX](https://animex.one/home) | :yes: | :sync::ie: | :cc::oc: |
52 52
53### Source table 53
54<ScrapeTable :sites="[ 54::: scrapetable
55 { name: '1anime', scrapes: { 'Anime Nexus': 'nexus', 'AnimePahe': 'pahe', 'AniNeko': 'gogo', 'Re:ANIME': 'Zen', 'AniZone': 'Zone' } }, 55- 1anime : (Anime Nexus, nexus), (AnimePahe, pahe), (AniNeko, gogo), (Re:ANIME, Zen), (AniZone, Zone);
56 { name: 'Animetsu', scrapes: { 'AnimeGG': 'Meg', 'AnimePahe': 'Pahe','AniNeko': 'Dio', } }, 56- Animetsu : (AnimeGG, Meg), (AnimePahe, Pahe), (AniNeko, Dio);
57 { name: 'AnimeX', scrapes: { '123anime (SD)': { name: 'wave', metadata: ['SD'] }, 'Animehub (SD)': { name: 'shiro', metadata: ['SD'] }, 'AnimePahe': 'uwu', 'Anibd': 'beep', 'AniNeko': 'mimi', 'AllManga': 'miku & mochi', 'AnimeOnsen (SD)': { name: 'vee', metadata: ['SD'] }, 'Anikoto': 'yuki' } }, 57- AnimeX : (123anime, wave, SD), (Animehub, shiro, SD), (AnimePahe, uwu), (Anibd, beep), (AniNeko, mimi), (AllManga, miku & mochi), (AnimeOnsen, vee, SD), (Anikoto, yuki);
58 { name: 'Miruro', scrapes: { 'AnimeDunya (SD)': { name: 'dune', metadata: ['SD'] }, 'AnimePahe': 'kiwi & telli', 'KickAssAnime': 'hop & kuz', 'AllManga': 'ally & nun', 'Anikoto': 'bun & bee', } , } 58- Miruro : (AnimeDunya, dune, SD), (AnimePahe, kiwi & telli), (KickAssAnime, hop & kuz), (AllManga, ally & nun), (Anikoto, bun & bee);
59]" /> 59:::
60
60</Collapsible> 61</Collapsible>
61 62
62<Collapsible title="Donghua dedicated"> 63<Collapsible title="Donghua dedicated">
@@ -205,13 +206,12 @@ Some sites may include manga, but they are listed here for their manhwa and manh
205| [Cubari Proxy](https://proxy.cubari.moe/#/) | :msync: | :ms: | :sp::dp::ls: | :no: | 206| [Cubari Proxy](https://proxy.cubari.moe/#/) | :msync: | :ms: | :sp::dp::ls: | :no: |
206| [Vidbox](https://vidbox.cc/manga) | :no: | :ss: | :lsg: | :no: | 207| [Vidbox](https://vidbox.cc/manga) | :no: | :ss: | :lsg: | :no: |
207 208
208### Source Table 209::: scrapetable
209<ScrapeTable :sites="[ 210- Akari Manga : (Atsumaru);
210 { name: 'Akari Manga', scrapes: { 'Atsumaru': '' } }, 211- ComiKuro : (Allmanga), (Atsumaru), (Mangaball), (Zazamanga);
211 { name: 'ComiKuro', scrapes: { 'Allmanga': '', 'Atsumaru': '', 'Mangaball': '', 'Zazamanga': '' } }, 212- Cubari Proxy : (MangaDex), (Weeb Central), (MangaKatana), (Guya), (AssortedScans), (DankeFarsLesen);
212 { name: 'Cubari Proxy', scrapes: { 'MangaDex': '', 'Weeb Central': '', 'MangaKatana': '', 'Guya': '', 'AssortedScans': '', 'DankeFarsLesen': '' } }, 213- Vidbox : (MangaFire);
213 { name: 'Vidbox', scrapes: { 'MangaFire': '' } } 214:::
214]" />
215 215
216</Collapsible> 216</Collapsible>
217 217