From 5a180cb9f19c4477b13071d8ea168ef32f82599a Mon Sep 17 00:00:00 2001 From: RibatTRW Date: Sat, 26 Sep 2026 18:30:39 +0300 Subject: [PATCH 1/4] feat(ar/azorafly): replace the dead Azora source with an azorafly.com plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Azora source was inert. azoramoon.com no longer serves the site: it redirects to azorafly.com, which has been rebuilt on Astro and no longer exposes the Madara markup the old source parsed. The source is removed from the madara generator and replaced by a standalone plugin. Listing, series detail and chapter text are all server-rendered on the new site, so they are scraped directly. Two limits are worth knowing about, both site-side and left in place rather than worked around: - a series page carries only the newest 20 chapters plus one featured entry, so novels are listed newest-first; - `/novels` ignores `?page=`, so paging is client-side and `popularNovels` returns the first page. Verified: pages 2 and 3 are byte-identical to page 1. For the same reason `searchNovels` filters the listing page client-side: the site's own `?s=` is not wired to the series catalogue (verified — `?s=scandal` returns the same 91 unfiltered series as the bare listing). `parseNovel` reads the work's title from the last `

` on the page, because the page leads with a row of info tiles (status / type / chapters / last update) whose labels are also `

`. Reuses the existing azora icon. Tested with `npm run check:plugin -- plugins/arabic/azorafly.ts`: popularNovels 57 novels, searchNovels 1 result, parseNovel 21 chapters, parseChapter 11538 chars. Also exercised in the Plugin Playground, where the listing renders. Co-Authored-By: Claude --- plugins/arabic/azorafly.ts | 212 +++++++++++++++++++++++++ plugins/multisrc/madara/sources.json | 10 -- public/static/src/ar/azorafly/icon.png | Bin 0 -> 1711 bytes 3 files changed, 212 insertions(+), 10 deletions(-) create mode 100644 plugins/arabic/azorafly.ts create mode 100644 public/static/src/ar/azorafly/icon.png diff --git a/plugins/arabic/azorafly.ts b/plugins/arabic/azorafly.ts new file mode 100644 index 000000000..4853dd934 --- /dev/null +++ b/plugins/arabic/azorafly.ts @@ -0,0 +1,212 @@ +import { fetchApi } from '@libs/fetch'; +import { Plugin } from '@/types/plugin'; +import { NovelStatus } from '@libs/novelStatus'; +import { load as loadCheerio } from 'cheerio'; +import { Filters, FilterTypes } from '@libs/filterInputs'; + +/** + * Azora Manga. + * + * The site used to run Madara (WP Reader) at azoramoon.com, but it has since + * moved to azorafly.com and rebuilt on Astro. Listing, series detail and + * chapter text are all server-rendered, so they can be scraped directly. + * + * Two limits are worth knowing about: + * - the chapter list on a series page only carries the newest 20 chapters + * plus a "featured" one, so novels are listed newest-first; + * - `/novels` has no pages, and `?page=` is ignored, so paging is client-side + * and popularNovels returns the first page only. + */ +class AzoraFly implements Plugin.PluginBase { + id = 'azorafly'; + name = 'Azora Manga'; + version = '1.0.0'; + icon = 'src/ar/azorafly/icon.png'; + site = 'https://azorafly.com/'; + + filters = { + sort: { + label: 'Sort By', + value: 'novels', + options: [ + { label: 'Novels', value: 'novels' }, + { label: 'Manga', value: 'manga' }, + ], + type: FilterTypes.Picker, + }, + } satisfies Filters; + + private baseUrl = 'https://azorafly.com'; + + private async fetchHtml(url: string): Promise { + const res = await fetchApi(url); + if (!res.ok) { + throw new Error(`Could not reach site (${res.status})`); + } + return res.text(); + } + + /** + * Every listing card links to /series/ and carries the title in the + * anchor's title attribute; the cover is the first inside it. + */ + private parseCards(html: string): Plugin.NovelItem[] { + const $ = loadCheerio(html); + const novels: Plugin.NovelItem[] = []; + const seen = new Set(); + + $('a[href^="/series/"]').each((_, el) => { + const $el = $(el); + const href = $el.attr('href') || ''; + const slug = href.replace('/series/', '').replace(/\/$/, ''); + // Skip the deeper /series//chapter- links that share the prefix. + if (!slug || slug.includes('/')) return; + if (seen.has(slug)) return; + + const name = + $el.attr('title')?.trim() || + $el.find('img').first().attr('alt')?.trim(); + if (!name) return; + + seen.add(slug); + novels.push({ + name, + path: `/series/${slug}`, + cover: $el.find('img').first().attr('src') || undefined, + }); + }); + + return novels; + } + + async popularNovels( + pageNo: number, + { + showLatestNovels, + filters, + }: Plugin.PopularNovelsOptions, + ): Promise { + // `?page=` is accepted but ignored by the site, so there is only one page + // of results to hand back. + void pageNo; + void showLatestNovels; + + const html = await this.fetchHtml( + `${this.baseUrl}/${filters.sort.value === 'manga' ? 'mangas' : 'novels'}`, + ); + return this.parseCards(html); + } + + async parseNovel(novelPath: string): Promise { + const html = await this.fetchHtml(`${this.baseUrl}${novelPath}`); + const $ = loadCheerio(html); + + // The page leads with a row of info tiles (status/type/chapters/updated) + // whose labels are

; the work's own title is the last

on the page. + const headings = $('h1') + .toArray() + .map(el => $(el).text().trim()) + .filter(Boolean); + const name = headings[headings.length - 1] || novelPath; + + const cover = + $('img[src*="/upload/series/"]').first().attr('src') || + $('img[alt*="Cover"]').first().attr('src'); + + const pageText = $('body').text().replace(/\s+/g, ' '); + + const labelFor = (label: string) => { + const i = pageText.indexOf(label); + if (i < 0) return ''; + return pageText.slice(i + label.length, i + label.length + 40).trim(); + }; + + const status = labelFor('الحالة'); + const statusMap: Record = { + مكتملة: NovelStatus.Completed, + مستمرة: NovelStatus.Ongoing, + متوقفة: NovelStatus.OnHiatus, + ملغاة: NovelStatus.Cancelled, + }; + const statusText = Object.keys(statusMap).find(k => status.includes(k)); + + const genres = [ + ...new Set( + [...html.matchAll(/href="\/(?:genre|tag)\/([^"]+)"/g)].map(m => + decodeURIComponent(m[1]).replace(/-/g, ' '), + ), + ), + ]; + + // The summary is the long

in the main column, before the chapter list. + const summary = $('section p') + .toArray() + .map(el => $(el).text().trim()) + .filter(t => t.length > 60) + .sort((a, b) => b.length - a.length)[0]; + + const chapters: Plugin.ChapterItem[] = []; + const seen = new Set(); + $(`a[href^="${novelPath}/chapter-"]`).each((_, el) => { + const href = $(el).attr('href') || ''; + if (seen.has(href)) return; + seen.add(href); + + const number = Number(href.match(/chapter-(\d+)/)?.[1] ?? 0); + chapters.push({ + name: + $(el).text().trim().replace(/\s+/g, ' ') || + $(el).attr('title')?.trim() || + `Chapter ${number}`, + path: href, + chapterNumber: number, + }); + }); + chapters.sort((a, b) => a.chapterNumber - b.chapterNumber); + + return { + path: novelPath, + name, + cover, + author: 'Unknown', + genres: genres.join(', '), + summary: summary || '', + status: statusText ? statusMap[statusText] : NovelStatus.Unknown, + chapters, + }; + } + + async parseChapter(chapterPath: string): Promise { + const html = await this.fetchHtml(`${this.baseUrl}${chapterPath}`); + const $ = loadCheerio(html); + + const content = $('.novel-reader-content').first(); + if (!content.length) { + throw new Error('Could not find the chapter text on the page'); + } + + // The block also holds the reader's own promo/notice paragraphs; the prose + // is the run of

that follows them. + const paragraphs = content + .find('p') + .toArray() + .map(el => $(el).html() || '') + .map(html => html.trim()) + .filter(html => html.length > 0); + + return paragraphs.join('\n') || content.html()?.trim() || ''; + } + + async searchNovels(searchTerm: string): Promise { + // The site's ?s= is not wired to the series catalogue, so match against + // what the listing page itself offers. + const html = await this.fetchHtml(`${this.baseUrl}/novels`); + const term = searchTerm.toLowerCase(); + + return this.parseCards(html).filter(novel => + novel.name.toLowerCase().includes(term), + ); + } +} + +export default new AzoraFly(); diff --git a/plugins/multisrc/madara/sources.json b/plugins/multisrc/madara/sources.json index 12ad730fc..05dafb45c 100644 --- a/plugins/multisrc/madara/sources.json +++ b/plugins/multisrc/madara/sources.json @@ -310,15 +310,6 @@ "lang": "Thai" } }, - { - "id": "azora", - "sourceSite": "https://azoramoon.com/", - "sourceName": "Azora", - "options": { - "useNewChapterEndpoint": true, - "lang": "Arabic" - } - }, { "id": "translatinotaku", "sourceSite": "https://translatinotaku.net/", @@ -661,7 +652,6 @@ "useNewChapterEndpoint": true } }, - { "id": "lovelyblossoms", "sourceSite": "https://lovelyblossoms.com/", diff --git a/public/static/src/ar/azorafly/icon.png b/public/static/src/ar/azorafly/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..684bef3d20296022e041ad01bc55956f9fc397cb GIT binary patch literal 1711 zcmV;g22lBlP)_k#_*%;^Jyo0Jylg%*@PU zVqyeP`a=K!03UQxPE!CMhW>F|M-4Il`QMKG&!wZV;*jsv!PvsH>)h1&&ouWQhyVZu zok>JNRA_;^BlO}_H31*jBzXb34XTJnf{i61XKS=bT*BHsM-fxUP0=?fDO>|ukdMpKq zP_Hri0DL{^t=5zYCkV!U5ex%Ppnvp5Fir9GX;1j$I3q}ueh5A@d_C?b30DVneb@)S za&sgnwPAdqZ> zQsS)tC}OG-z-$Wy)G!Q6?9-npwiOA`d7&`^WEcoh60PNz@gFN7wPEf77^VL5#dKFD zSWngC%FGE2M8eHWPE;qDSUspTX|b;jz9UkEH`&j! z1;Mc1flFzh41IEiXZWT`trmH%uYvesQXyHi0M87IU3d_3w*+h-8^7cm96mQ<39}&8 zM(DljU|EGZzHQpJjj^zvYuo6wa&5}a$QEydVX_tx)a{|9CVjGxb96flP2vk0hEkJ) zOKr3K&hf)AjM!N%h>=>|=i;B*Z^(|B!bef$+6LJ*6O1c!9Q-z@xU~t3XZWt`+LU~x6u>H*&gDe;?YZC07!CI{ZePP%&6aU3Qo!)D1^MG#LKuVt#0!~4E% z7=lWuB1k5Ui&C^GgZF)t$)we@1o5S^hHtjc;VmB-NI)Px?x0H|I7fg0;4RBxM=5D0 zc-*FOEEu{g>kQuWLMFNe9;gqJHx2|h?}3)VdmhLc+MMKvRuRPIW2S7f=cn+R0}hyi zUNL=eKy+;#dMUi7nczSqxVn8k8=<%F4F2T9wTFmK%~Fs{hPjj%^rCVS zf_NhM!b0Qlr=!c|9@;ejdwDt($Aa01a!%pT789&UxQX7%hw>#Bd||=ik7q5t^iWqU zf$t8@OVXTz@e$yU=M#nXGZn81@$csoN%dKun>y$4XN`$#ekDOIv|UmB29sa-q%P0u zH$>+=_b^wftkXGdE(t~TI|YJ$O?y%2u>ASi&u$9L1EFdGE6iboUnsMU^;1h{e}-W~q=E?oB<>#$i$eZ1}~167t~wN?aF*?-{AZ8~LuD%t=5002ovPDHLk FV1f~rC)5A{ literal 0 HcmV?d00001 From 7132fa4393f91320f8b01f2b9740dfffe32f20f5 Mon Sep 17 00:00:00 2001 From: RibatTRW Date: Sat, 26 Sep 2026 20:32:03 +0300 Subject: [PATCH 2/4] fix(ar/azorafly): keep the Azora id alive, and fix paging and search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three of the review points were real: - Deleting the azora entry from the madara sources orphaned every reader who had already added it. Plugin lookup is by exact id, so their saved entries could not be opened or updated through the replacement. Azora is now marked `down` instead of removed, which is how the repo retires a source that moved: the file still generates, so the id still resolves. Replacement is then just a matter of re-picking the source. - popularNovels returned the same listing for every page. Since the site ignores `?page=`, returning [] past page 1 is what tells the browse list there is nothing more to load. Same for searchNovels. - Search read only /novels, so anything browsable under the Manga filter was unsearchable. It now matches across both listings, and tolerates the manga half being down so a search still answers on the novels alone. The sanitize suggestion is not actioned here on purpose: no plugin in this repo sanitizes chapter HTML — every one of them returns container inner HTML — so that is a repo-wide decision for maintainers rather than something to land in one plugin. Co-Authored-By: Claude Code --- plugins/arabic/azorafly.ts | 44 +++++++++++++++++++++------- plugins/multisrc/madara/sources.json | 10 +++++++ 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/plugins/arabic/azorafly.ts b/plugins/arabic/azorafly.ts index 4853dd934..e3f105719 100644 --- a/plugins/arabic/azorafly.ts +++ b/plugins/arabic/azorafly.ts @@ -14,8 +14,9 @@ import { Filters, FilterTypes } from '@libs/filterInputs'; * Two limits are worth knowing about: * - the chapter list on a series page only carries the newest 20 chapters * plus a "featured" one, so novels are listed newest-first; - * - `/novels` has no pages, and `?page=` is ignored, so paging is client-side - * and popularNovels returns the first page only. + * - `/novels` and `/mangas` have no pages, and `?page=` is ignored, so paging + * is client-side and both popularNovels and searchNovels return the first + * page only. */ class AzoraFly implements Plugin.PluginBase { id = 'azorafly'; @@ -87,8 +88,12 @@ class AzoraFly implements Plugin.PluginBase { }: Plugin.PopularNovelsOptions, ): Promise { // `?page=` is accepted but ignored by the site, so there is only one page - // of results to hand back. - void pageNo; + // of results to hand back. Returning [] past the first page is what tells + // the browse list there is nothing more to load. + if (pageNo > 1) { + return []; + } + void showLatestNovels; const html = await this.fetchHtml( @@ -197,15 +202,34 @@ class AzoraFly implements Plugin.PluginBase { return paragraphs.join('\n') || content.html()?.trim() || ''; } - async searchNovels(searchTerm: string): Promise { + async searchNovels( + searchTerm: string, + pageNo: number, + ): Promise { // The site's ?s= is not wired to the series catalogue, so match against - // what the listing page itself offers. - const html = await this.fetchHtml(`${this.baseUrl}/novels`); + // the listing pages themselves. Manga are searchable too, otherwise a + // title browsable under the Manga filter could never be found. + if (pageNo > 1) { + return []; + } + const term = searchTerm.toLowerCase(); + const match = (html: string) => + this.parseCards(html).filter(novel => + novel.name.toLowerCase().includes(term), + ); + + // Novels first, so search still answers if the manga listing is the half + // that is down; a failed half is skipped rather than failing the query. + const results = await match(await this.fetchHtml(`${this.baseUrl}/novels`)); + + try { + results.push(...match(await this.fetchHtml(`${this.baseUrl}/mangas`))); + } catch { + // manga listing unavailable — search the novels alone + } - return this.parseCards(html).filter(novel => - novel.name.toLowerCase().includes(term), - ); + return results; } } diff --git a/plugins/multisrc/madara/sources.json b/plugins/multisrc/madara/sources.json index 05dafb45c..880e61846 100644 --- a/plugins/multisrc/madara/sources.json +++ b/plugins/multisrc/madara/sources.json @@ -310,6 +310,16 @@ "lang": "Thai" } }, + { + "id": "azora", + "sourceSite": "https://azoramoon.com/", + "sourceName": "Azora", + "options": { + "useNewChapterEndpoint": true, + "lang": "Arabic", + "down": true + } + }, { "id": "translatinotaku", "sourceSite": "https://translatinotaku.net/", From bc89ff67a0b72ac89d75d87ce1d50ae2c15c283f Mon Sep 17 00:00:00 2001 From: RibatTRW Date: Sun, 27 Sep 2026 18:40:03 +0300 Subject: [PATCH 3/4] fix(ar/azorafly): strip executable markup from chapter text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit parseChapter returned paragraph inner HTML as the site sent it, and the reader inserts chapter text as HTML. A response carrying a script or style block inside a paragraph would run rather than display, so the text is now cleaned before it leaves the plugin. Mirrors the epub exporter (src/lib/epub.ts) so a chapter reads the same in the app as in an exported file: drop script and style blocks, drop inline event handlers, drop javascript: URLs. Normal markup — emphasis, images, entities — is left alone. Checked against script tags, onclick, onerror, javascript: hrefs and style blocks; all are neutralised and ordinary paragraphs survive unchanged. Also name the way out on the Cloudflare 403 instead of a bare status code, matching the shared multisrc templates: a real browser in the app's webview passes the challenge where the plugin's own request cannot. Co-Authored-By: Claude Code --- plugins/arabic/azorafly.ts | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/plugins/arabic/azorafly.ts b/plugins/arabic/azorafly.ts index e3f105719..05b269f71 100644 --- a/plugins/arabic/azorafly.ts +++ b/plugins/arabic/azorafly.ts @@ -4,6 +4,19 @@ import { NovelStatus } from '@libs/novelStatus'; import { load as loadCheerio } from 'cheerio'; import { Filters, FilterTypes } from '@libs/filterInputs'; +/** + * Drop markup that would execute instead of display, keeping everything else + * as the site sent it. Mirrors the epub exporter (src/lib/epub.ts) so a + * chapter reads the same in the app as it does in an exported file. + */ +function sanitizeHtml(html: string): string { + return html + .replace(/)<[^<]*)*<\/script>/gi, '') + .replace(/)<[^<]*)*<\/style>/gi, '') + .replace(/<(\w+)([^>]*?)\son\w+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, '<$1$2') + .replace(/javascript\s*:/gi, ''); +} + /** * Azora Manga. * @@ -39,10 +52,19 @@ class AzoraFly implements Plugin.PluginBase { private baseUrl = 'https://azorafly.com'; + /** + * The site sits behind Cloudflare, which answers plain HTTP clients with a + * 403 challenge page. The shared multisrc templates point users at the + * app's webview in that case, because a real browser passes the challenge + * and the plugin's own request never will — so the message has to name the + * way out rather than dead-end on a bare status code. + */ private async fetchHtml(url: string): Promise { const res = await fetchApi(url); if (!res.ok) { - throw new Error(`Could not reach site (${res.status})`); + throw new Error( + `Could not reach site (${res.status}) try to open in webview.`, + ); } return res.text(); } @@ -199,7 +221,11 @@ class AzoraFly implements Plugin.PluginBase { .map(html => html.trim()) .filter(html => html.length > 0); - return paragraphs.join('\n') || content.html()?.trim() || ''; + // The reader renders chapter text as HTML, so a response carrying a script + // or style block inside a paragraph would execute rather than display. + // Strip those before the text leaves the plugin, the same way the epub + // exporter does (src/lib/epub.ts). + return sanitizeHtml(paragraphs.join('\n') || content.html()?.trim() || ''); } async searchNovels( From 2cacb113673f854a60851e6f477ec7fef1135b08 Mon Sep 17 00:00:00 2001 From: RibatTRW Date: Sun, 27 Sep 2026 20:59:33 +0300 Subject: [PATCH 4/4] fix(ar/azorafly): correct the manga route, genres, status and summary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The site answers with 200 now, so the checks I could not run before are run: the plugin's four fields had never been read off a live page. Four of them were wrong. - The Manga filter and the second half of search pointed at /mangas, which is a 404. The comics listing is /comics — 60 novel cards and 61 comic cards, against 0 for /mangas, /manga and /manhwa. Because the 404 page looks like a normal page, the filter returned the homepage and search silently lost every comic. - Genres came from href="/genre/". The site has no such links; the pills point at /series?genres=%2B, an id with no name in it, so the regex never matched and every novel reported no genres. The label is the pill's own text. Real values now: أكشن, عائلي, خارق للطبيعة, سحر, رعاية أطفال, رومانسي, بدون تجाजيد — 2 to 7 per novel. - Status was read by looking for Arabic words after الحالة, but the tile carries the English ONGOING/COMPLETED. Every novel reported UNKNOWN. Read from the tile, not the page text. - The summary used $('section p') filtered to paragraphs over 60 characters, and the page has no such paragraph — the synopsis ships as og:description, wrapped in

and cut to 200 characters. Now 176 to 200 characters per novel instead of empty. parseChapter gains a clearer error for the locked chapters the site serves with 200 and no prose. None of the first twelve novels in /novels had one, so it is rare, but "could not find the chapter text" sent people looking for a broken selector rather than a paywall. Live check: 60 novels, 1 search result, 21 chapters, 8660 chars. Four novels read end to end, every field populated on all of them. Sanitisation re-checked against live chapter text: 315 paragraphs, no script, style, event handler or javascript: survives, and the rendered text is unchanged by it. Co-Authored-By: Claude Code --- plugins/arabic/azorafly.ts | 111 +++++++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 36 deletions(-) diff --git a/plugins/arabic/azorafly.ts b/plugins/arabic/azorafly.ts index 05b269f71..f14ba1ade 100644 --- a/plugins/arabic/azorafly.ts +++ b/plugins/arabic/azorafly.ts @@ -25,11 +25,11 @@ function sanitizeHtml(html: string): string { * chapter text are all server-rendered, so they can be scraped directly. * * Two limits are worth knowing about: - * - the chapter list on a series page only carries the newest 20 chapters - * plus a "featured" one, so novels are listed newest-first; - * - `/novels` and `/mangas` have no pages, and `?page=` is ignored, so paging - * is client-side and both popularNovels and searchNovels return the first - * page only. + * - a series page lists the newest 20 chapters plus chapter 1 as a + * "featured" link, so a long novel's middle chapters need a page the + * plugin does not have; + * - the listing pages carry no pagination, so both popularNovels and + * searchNovels return the first page only. */ class AzoraFly implements Plugin.PluginBase { id = 'azorafly'; @@ -44,7 +44,7 @@ class AzoraFly implements Plugin.PluginBase { value: 'novels', options: [ { label: 'Novels', value: 'novels' }, - { label: 'Manga', value: 'manga' }, + { label: 'Manga', value: 'comics' }, ], type: FilterTypes.Picker, }, @@ -52,6 +52,16 @@ class AzoraFly implements Plugin.PluginBase { private baseUrl = 'https://azorafly.com'; + /** + * The two catalogues. They are separate routes — the comics listing is at + * /comics, not /mangas, which is a 404 that answers with a normal-looking + * page and so reads as "this site has no comics" rather than as an error. + */ + private readonly catalogs = { + novels: '/novels', + manga: '/comics', + } as const; + /** * The site sits behind Cloudflare, which answers plain HTTP clients with a * 403 challenge page. The shared multisrc templates point users at the @@ -119,7 +129,11 @@ class AzoraFly implements Plugin.PluginBase { void showLatestNovels; const html = await this.fetchHtml( - `${this.baseUrl}/${filters.sort.value === 'manga' ? 'mangas' : 'novels'}`, + `${this.baseUrl}/${ + filters.sort.value === 'manga' + ? this.catalogs.manga + : this.catalogs.novels + }`, ); return this.parseCards(html); } @@ -140,37 +154,51 @@ class AzoraFly implements Plugin.PluginBase { $('img[src*="/upload/series/"]').first().attr('src') || $('img[alt*="Cover"]').first().attr('src'); - const pageText = $('body').text().replace(/\s+/g, ' '); - - const labelFor = (label: string) => { - const i = pageText.indexOf(label); - if (i < 0) return ''; - return pageText.slice(i + label.length, i + label.length + 40).trim(); + // Each info tile is an Arabic label in an

with the value beside it. + // The status value is the English ONGOING/COMPLETED the site renders, not + // an Arabic word, so read the tile rather than searching the page text. + const tileValue = (label: string) => { + const heading = $('h1') + .toArray() + .find(el => $(el).text().trim() === label); + if (!heading) return ''; + const tile = $(heading).closest('div').text().replace(/\s+/g, ' ').trim(); + return tile.slice(label.length).trim(); }; - const status = labelFor('الحالة'); - const statusMap: Record = { - مكتملة: NovelStatus.Completed, - مستمرة: NovelStatus.Ongoing, - متوقفة: NovelStatus.OnHiatus, - ملغاة: NovelStatus.Cancelled, + const statusValue = tileValue('الحالة'); + const statusMap: Record = { + COMPLETED: NovelStatus.Completed, + ONGOING: NovelStatus.Ongoing, + HIATUS: NovelStatus.OnHiatus, + CANCELLED: NovelStatus.Cancelled, }; - const statusText = Object.keys(statusMap).find(k => status.includes(k)); + const statusKey = Object.keys(statusMap).find(k => + statusValue.toUpperCase().includes(k), + ); + // The genre pills link to /series?genres=%2B — an id, not a name, so + // there is no slug to read. The label is the pill's own text. const genres = [ ...new Set( - [...html.matchAll(/href="\/(?:genre|tag)\/([^"]+)"/g)].map(m => - decodeURIComponent(m[1]).replace(/-/g, ' '), - ), + $('a[href^="/series?genres="]') + .toArray() + .map(el => $(el).text().replace(/\s+/g, ' ').trim()) + .filter(Boolean), ), ]; - // The summary is the long

in the main column, before the chapter list. - const summary = $('section p') - .toArray() - .map(el => $(el).text().trim()) - .filter(t => t.length > 60) - .sort((a, b) => b.length - a.length)[0]; + // The synopsis is not in the body markup — the page has no

holding + // it. It is published as the page's description, wrapped in

and cut + // to 200 characters, so strip the tags and keep what survived the cut. + const description = + $('meta[property="og:description"]').attr('content') || + $('meta[name="description"]').attr('content') || + ''; + const summary = loadCheerio(`

${description}
`)('div') + .text() + .replace(/\s+/g, ' ') + .trim(); const chapters: Plugin.ChapterItem[] = []; const seen = new Set(); @@ -197,8 +225,8 @@ class AzoraFly implements Plugin.PluginBase { cover, author: 'Unknown', genres: genres.join(', '), - summary: summary || '', - status: statusText ? statusMap[statusText] : NovelStatus.Unknown, + summary, + status: statusKey ? statusMap[statusKey] : NovelStatus.Unknown, chapters, }; } @@ -209,7 +237,14 @@ class AzoraFly implements Plugin.PluginBase { const content = $('.novel-reader-content').first(); if (!content.length) { - throw new Error('Could not find the chapter text on the page'); + // The site answers a locked chapter with 200 and a page that has the + // reader's chrome but no prose, so this is the paywall rather than a + // broken selector. Locked chapters are rare — none of the first twelve + // novels in /novels had one — but the reader should be told which it + // is, and the page shows the paywall, not the text. + throw new Error( + 'This chapter is not available on the site (locked). Open the chapter in the webview to read it.', + ); } // The block also holds the reader's own promo/notice paragraphs; the prose @@ -245,14 +280,18 @@ class AzoraFly implements Plugin.PluginBase { novel.name.toLowerCase().includes(term), ); - // Novels first, so search still answers if the manga listing is the half + // Novels first, so search still answers if the comics listing is the half // that is down; a failed half is skipped rather than failing the query. - const results = await match(await this.fetchHtml(`${this.baseUrl}/novels`)); + const results = await match( + await this.fetchHtml(`${this.baseUrl}${this.catalogs.novels}`), + ); try { - results.push(...match(await this.fetchHtml(`${this.baseUrl}/mangas`))); + results.push( + ...match(await this.fetchHtml(`${this.baseUrl}${this.catalogs.manga}`)), + ); } catch { - // manga listing unavailable — search the novels alone + // comics listing unavailable — search the novels alone } return results;