Add fictioneer multisrc (#1468)
* Add fictioneer multisrc, auto source req labeling for it, move daoistquest to it, add novelib * fictioneer pagination, fix author, add status
This commit is contained in:
@@ -84,11 +84,28 @@ jobs:
|
|||||||
echo "hotnovelpub=false" >> $GITHUB_OUTPUT
|
echo "hotnovelpub=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Check Fictioneer theme
|
||||||
|
id: check_fictioneer
|
||||||
|
env:
|
||||||
|
BASE_URL: ${{ steps.get_base_url.outputs.BASE_URL }}
|
||||||
|
USER_AGENT: ${{ steps.get_user_agent.outputs.USER_AGENT }}
|
||||||
|
run: |
|
||||||
|
if curl --location --output /dev/null --silent --head --fail "https://$BASE_URL/wp-content/themes/fictioneer/css/application.css" -H "User-Agent: $USER_AGENT"; then
|
||||||
|
echo "fictioneer=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "✅ Fictioneer Theme Detected" >> $GITHUB_STEP_SUMMARY
|
||||||
|
elif curl --location --output /dev/null --silent --head --fail "http://$BASE_URL/wp-content/themes/fictioneer/css/application.css" -H "User-Agent: $USER_AGENT"; then
|
||||||
|
echo "fictioneer=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "✅ Fictioneer Theme Detected" >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "fictioneer=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Add Label
|
- name: Add Label
|
||||||
env:
|
env:
|
||||||
MADARA: ${{ steps.check_madara.outputs.madara }}
|
MADARA: ${{ steps.check_madara.outputs.madara }}
|
||||||
LIGHNOVELWP: ${{ steps.check_lighnovelwp.outputs.lighnovelwp }}
|
LIGHNOVELWP: ${{ steps.check_lighnovelwp.outputs.lighnovelwp }}
|
||||||
HOTNOVELPUB: ${{ steps.check_hotnovelpub.outputs.hotnovelpub }}
|
HOTNOVELPUB: ${{ steps.check_hotnovelpub.outputs.hotnovelpub }}
|
||||||
|
FICTIONEER: ${{ steps.check_fictioneer.outputs.fictioneer }}
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
run: |
|
run: |
|
||||||
if [[ "$MADARA" == "true" ]]; then
|
if [[ "$MADARA" == "true" ]]; then
|
||||||
@@ -97,6 +114,8 @@ jobs:
|
|||||||
gh issue edit $ISSUE_NUMBER --add-label "Theme: Lighnovelwp" -R $REPO
|
gh issue edit $ISSUE_NUMBER --add-label "Theme: Lighnovelwp" -R $REPO
|
||||||
elif [[ "$HOTNOVELPUB" == "true" ]]; then
|
elif [[ "$HOTNOVELPUB" == "true" ]]; then
|
||||||
gh issue edit $ISSUE_NUMBER --add-label "Theme: Hotnovelpub" -R $REPO
|
gh issue edit $ISSUE_NUMBER --add-label "Theme: Hotnovelpub" -R $REPO
|
||||||
|
elif [[ "$FICTIONEER" == "true" ]]; then
|
||||||
|
gh issue edit $ISSUE_NUMBER --add-label "Theme: Fictioneer" -R $REPO
|
||||||
else
|
else
|
||||||
echo "No Theme Detected" >> $GITHUB_STEP_SUMMARY
|
echo "No Theme Detected" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 806 B After Width: | Height: | Size: 806 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,33 @@
|
|||||||
|
import { readFileSync } from 'fs';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
import { dirname, join } from 'path';
|
||||||
|
|
||||||
|
const folder = dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
|
import list from './sources.json' with { type: 'json' };
|
||||||
|
|
||||||
|
export const generateAll = function () {
|
||||||
|
return list.map(source => {
|
||||||
|
console.log(
|
||||||
|
`[fictioneer] Generating: ${source.id}${' '.repeat(20 - source.id.length)}`,
|
||||||
|
);
|
||||||
|
return generator(source);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const generator = function generator(source) {
|
||||||
|
const readNovelFullTemplate = readFileSync(join(folder, 'template.ts'), {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
});
|
||||||
|
|
||||||
|
const pluginScript = `
|
||||||
|
${readNovelFullTemplate}
|
||||||
|
const plugin = new FictioneerPlugin(${JSON.stringify(source)});
|
||||||
|
export default plugin;
|
||||||
|
`.trim();
|
||||||
|
return {
|
||||||
|
lang: source.options?.lang || 'English',
|
||||||
|
filename: source.sourceName,
|
||||||
|
pluginScript,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "daoistquest",
|
||||||
|
"sourceSite": "https://daoist.quest",
|
||||||
|
"sourceName": "Daoist Quest",
|
||||||
|
"options": {
|
||||||
|
"browsePage": "collection/novels",
|
||||||
|
"versionIncrements": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "novelib",
|
||||||
|
"sourceSite": "https://novelib.com",
|
||||||
|
"sourceName": "NovelLib",
|
||||||
|
"options": {
|
||||||
|
"browsePage": "browse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,19 +1,40 @@
|
|||||||
|
import { CheerioAPI, load as loadCheerio, load } from 'cheerio';
|
||||||
import { fetchApi } from '@libs/fetch';
|
import { fetchApi } from '@libs/fetch';
|
||||||
import { Plugin } from '@typings/plugin';
|
import { Plugin } from '@typings/plugin';
|
||||||
import { Filters } from '@libs/filterInputs';
|
import { NovelStatus } from '@libs/novelStatus';
|
||||||
import { load as loadCheerio } from 'cheerio';
|
import { Filters } from '../../../src/libs/filterInputs';
|
||||||
|
|
||||||
class DaoistQuestPlugin implements Plugin.PluginBase {
|
type FictioneerOptions = {
|
||||||
id = 'daoistquest';
|
browsePage: string;
|
||||||
name = 'Daoist Quest';
|
lang?: string;
|
||||||
icon = 'src/en/daoistquest/icon.png';
|
versionIncrements?: number;
|
||||||
site = 'https://daoist.quest';
|
};
|
||||||
version = '1.0.0';
|
|
||||||
|
export type FictioneerMetadata = {
|
||||||
|
id: string;
|
||||||
|
sourceSite: string;
|
||||||
|
sourceName: string;
|
||||||
|
options: FictioneerOptions;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FictioneerPlugin implements Plugin.PluginBase {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
icon: string;
|
||||||
|
site: string;
|
||||||
|
version: string;
|
||||||
|
options: FictioneerOptions;
|
||||||
filters: Filters | undefined = undefined;
|
filters: Filters | undefined = undefined;
|
||||||
imageRequestInit?: Plugin.ImageRequestInit | undefined = undefined;
|
|
||||||
|
|
||||||
//flag indicates whether access to LocalStorage, SesesionStorage is required.
|
constructor(metadata: FictioneerMetadata) {
|
||||||
webStorageUtilized?: boolean;
|
this.id = metadata.id;
|
||||||
|
this.name = metadata.sourceName;
|
||||||
|
this.icon = `multisrc/fictioneer/${metadata.id.toLowerCase()}/icon.png`;
|
||||||
|
this.site = metadata.sourceSite;
|
||||||
|
const versionIncrements = metadata.options?.versionIncrements || 0;
|
||||||
|
this.version = `1.0.${0 + versionIncrements}`;
|
||||||
|
this.options = metadata.options;
|
||||||
|
}
|
||||||
|
|
||||||
async popularNovels(
|
async popularNovels(
|
||||||
pageNo: number,
|
pageNo: number,
|
||||||
@@ -22,12 +43,19 @@ class DaoistQuestPlugin implements Plugin.PluginBase {
|
|||||||
filters,
|
filters,
|
||||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||||
): Promise<Plugin.NovelItem[]> {
|
): Promise<Plugin.NovelItem[]> {
|
||||||
if (pageNo !== 1) return [];
|
const req = await fetchApi(
|
||||||
const req = await fetchApi(this.site + '/collection/novels/');
|
this.site +
|
||||||
|
'/' +
|
||||||
|
this.options.browsePage +
|
||||||
|
'/' +
|
||||||
|
(pageNo === 1 ? '' : 'page/' + pageNo + '/'),
|
||||||
|
);
|
||||||
const body = await req.text();
|
const body = await req.text();
|
||||||
const loadedCheerio = loadCheerio(body);
|
const loadedCheerio = loadCheerio(body);
|
||||||
|
|
||||||
return loadedCheerio('#featured-list > li > div > div')
|
return loadedCheerio(
|
||||||
|
'#featured-list > li > div > div, #list-of-stories > li > div > div',
|
||||||
|
)
|
||||||
.map((i, el) => {
|
.map((i, el) => {
|
||||||
const novelName = loadedCheerio(el).find('h3 > a').text();
|
const novelName = loadedCheerio(el).find('h3 > a').text();
|
||||||
const novelCover = loadedCheerio(el)
|
const novelCover = loadedCheerio(el)
|
||||||
@@ -59,6 +87,7 @@ class DaoistQuestPlugin implements Plugin.PluginBase {
|
|||||||
.text()
|
.text()
|
||||||
.split('|')[0]
|
.split('|')[0]
|
||||||
.replace('Author: ', '')
|
.replace('Author: ', '')
|
||||||
|
.replace('by ', '')
|
||||||
.trim();
|
.trim();
|
||||||
novel.cover = loadedCheerio('figure.story__thumbnail > a').attr('href');
|
novel.cover = loadedCheerio('figure.story__thumbnail > a').attr('href');
|
||||||
novel.genres = loadedCheerio('div.tag-group > a')
|
novel.genres = loadedCheerio('div.tag-group > a')
|
||||||
@@ -84,6 +113,12 @@ class DaoistQuestPlugin implements Plugin.PluginBase {
|
|||||||
})
|
})
|
||||||
.toArray();
|
.toArray();
|
||||||
|
|
||||||
|
const status = loadedCheerio('span.story__status').text().trim();
|
||||||
|
if (status === 'Ongoing') novel.status = NovelStatus.Ongoing;
|
||||||
|
if (status === 'Completed') novel.status = NovelStatus.Completed;
|
||||||
|
if (status === 'Cancelled') novel.status = NovelStatus.Cancelled;
|
||||||
|
if (status === 'Hiatus') novel.status = NovelStatus.OnHiatus;
|
||||||
|
|
||||||
return novel;
|
return novel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,9 +134,9 @@ class DaoistQuestPlugin implements Plugin.PluginBase {
|
|||||||
searchTerm: string,
|
searchTerm: string,
|
||||||
pageNo: number,
|
pageNo: number,
|
||||||
): Promise<Plugin.NovelItem[]> {
|
): Promise<Plugin.NovelItem[]> {
|
||||||
if (pageNo !== 1) return [];
|
|
||||||
const req = await fetchApi(
|
const req = await fetchApi(
|
||||||
this.site + `?s=${encodeURIComponent(searchTerm)}&post_type=fcn_story`,
|
this.site +
|
||||||
|
`/${pageNo === 1 ? '' : 'page/' + pageNo + '/'}?s=${encodeURIComponent(searchTerm)}&post_type=fcn_story`,
|
||||||
);
|
);
|
||||||
const body = await req.text();
|
const body = await req.text();
|
||||||
const loadedCheerio = loadCheerio(body);
|
const loadedCheerio = loadCheerio(body);
|
||||||
@@ -126,5 +161,3 @@ class DaoistQuestPlugin implements Plugin.PluginBase {
|
|||||||
resolveUrl = (path: string, isNovel?: boolean) =>
|
resolveUrl = (path: string, isNovel?: boolean) =>
|
||||||
this.site + '/' + path + '/';
|
this.site + '/' + path + '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new DaoistQuestPlugin();
|
|
||||||
Reference in New Issue
Block a user