fix: [Scribble Hub]: Add Page and Correct Filters (#1054)
* scribble-hub: edit filters * scribble-hub: add search params * scribble-hub: fix * scribble-hub: revert version
This commit is contained in:
@@ -6,10 +6,11 @@ import dayjs from 'dayjs';
|
|||||||
|
|
||||||
class ScribbleHubPlugin implements Plugin.PluginBase {
|
class ScribbleHubPlugin implements Plugin.PluginBase {
|
||||||
id = 'scribblehub';
|
id = 'scribblehub';
|
||||||
name = 'ScribbleHub';
|
name = 'Scribble Hub';
|
||||||
icon = 'src/en/scribblehub/icon.png';
|
icon = 'src/en/scribblehub/icon.png';
|
||||||
site = 'https://www.scribblehub.com/';
|
site = 'https://www.scribblehub.com/';
|
||||||
version = '1.0.0';
|
version = '1.0.1';
|
||||||
|
|
||||||
parseNovels(loadedCheerio: CheerioAPI) {
|
parseNovels(loadedCheerio: CheerioAPI) {
|
||||||
const novels: Plugin.NovelItem[] = [];
|
const novels: Plugin.NovelItem[] = [];
|
||||||
|
|
||||||
@@ -39,43 +40,45 @@ class ScribbleHubPlugin implements Plugin.PluginBase {
|
|||||||
filters,
|
filters,
|
||||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||||
): Promise<Plugin.NovelItem[]> {
|
): Promise<Plugin.NovelItem[]> {
|
||||||
let link = `${this.site}`;
|
let url = `${this.site}`;
|
||||||
if (showLatestNovels) link += 'latest-series/';
|
if (showLatestNovels) {
|
||||||
// if (filters.genres.value.include?.length ||
|
url += `latest-series/?pg=${page}`;
|
||||||
// filters.genres.value.exclude?.length)
|
} else if (filters) {
|
||||||
else link += 'series-finder/?sf=1';
|
const params = new URLSearchParams();
|
||||||
// else
|
if (filters.genres.value.include?.length) {
|
||||||
// link += "series-ranking/";
|
params.append('gi', filters.genres.value.include.join(','));
|
||||||
// TODO, series-ranking filters when hideOnSelect come out
|
}
|
||||||
|
if (
|
||||||
|
filters.genres.value.include?.length ||
|
||||||
|
filters.genres.value.exclude?.length
|
||||||
|
) {
|
||||||
|
params.append('mgi', filters.genre_operator.value);
|
||||||
|
}
|
||||||
|
if (filters.genres.value.exclude?.length) {
|
||||||
|
params.append('ge', filters.genres.value.exclude.join(','));
|
||||||
|
}
|
||||||
|
if (filters.content_warning.value.include?.length) {
|
||||||
|
params.append('cti', filters.content_warning.value.include.join(','));
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
filters.content_warning.value.include?.length ||
|
||||||
|
filters.content_warning.value.exclude?.length
|
||||||
|
) {
|
||||||
|
params.append('mct', filters.content_warning_operator.value);
|
||||||
|
}
|
||||||
|
if (filters.content_warning.value.exclude?.length) {
|
||||||
|
params.append('cte', filters.content_warning.value.exclude.join(','));
|
||||||
|
}
|
||||||
|
params.append('cp', filters.storyStatus.value);
|
||||||
|
params.append('sort', filters.sort.value);
|
||||||
|
params.append('order', filters.order.value);
|
||||||
|
params.append('pg', page.toString());
|
||||||
|
url += `series-finder/?sf=1&${params.toString()}`;
|
||||||
|
} else {
|
||||||
|
url += `series-finder/?sf=1&sort=ratings&order=desc&pg=${page}`;
|
||||||
|
}
|
||||||
|
|
||||||
if (filters.genres.value.include?.length)
|
const body = await fetchApi(url).then(result => result.text());
|
||||||
link += '&gi=' + filters.genres.value.include.join(',');
|
|
||||||
|
|
||||||
if (filters.genres.value.exclude?.length)
|
|
||||||
link += '&ge=' + filters.genres.value.exclude.join(',');
|
|
||||||
|
|
||||||
if (
|
|
||||||
filters.genres.value.include?.length ||
|
|
||||||
filters.genres.value.exclude?.length
|
|
||||||
)
|
|
||||||
link += '&mgi=' + filters.genre_operator.value;
|
|
||||||
|
|
||||||
if (filters.content_warning.value.include?.length)
|
|
||||||
link += '&cti=' + filters.content_warning.value.include.join(',');
|
|
||||||
|
|
||||||
if (filters.content_warning.value.exclude?.length)
|
|
||||||
link += '&cte=' + filters.content_warning.value.exclude.join(',');
|
|
||||||
|
|
||||||
if (
|
|
||||||
filters.content_warning.value.include?.length ||
|
|
||||||
filters.content_warning.value.exclude?.length
|
|
||||||
)
|
|
||||||
link += '&mct' + filters.content_warning_operator.value;
|
|
||||||
|
|
||||||
link += '&sort=' + filters.sort.value;
|
|
||||||
link += '&order=' + filters.order.value;
|
|
||||||
|
|
||||||
const body = await fetchApi(link).then(result => result.text());
|
|
||||||
|
|
||||||
const loadedCheerio = parseHTML(body);
|
const loadedCheerio = parseHTML(body);
|
||||||
return this.parseNovels(loadedCheerio);
|
return this.parseNovels(loadedCheerio);
|
||||||
@@ -188,7 +191,7 @@ class ScribbleHubPlugin implements Plugin.PluginBase {
|
|||||||
value: 'ratings',
|
value: 'ratings',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'Chapters', value: 'chapters' },
|
{ label: 'Chapters', value: 'chapters' },
|
||||||
{ label: 'Chapters per week', value: 'frequency' },
|
{ label: 'Chapters per Week', value: 'frequency' },
|
||||||
{ label: 'Date Added', value: 'dateadded' },
|
{ label: 'Date Added', value: 'dateadded' },
|
||||||
{ label: 'Favorites', value: 'favorites' },
|
{ label: 'Favorites', value: 'favorites' },
|
||||||
{ label: 'Last Updated', value: 'lastchdate' },
|
{ label: 'Last Updated', value: 'lastchdate' },
|
||||||
@@ -203,7 +206,7 @@ class ScribbleHubPlugin implements Plugin.PluginBase {
|
|||||||
type: FilterTypes.Picker,
|
type: FilterTypes.Picker,
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
label: 'Order by',
|
label: 'Order By',
|
||||||
value: 'desc',
|
value: 'desc',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'Descending', value: 'desc' },
|
{ label: 'Descending', value: 'desc' },
|
||||||
@@ -212,8 +215,8 @@ class ScribbleHubPlugin implements Plugin.PluginBase {
|
|||||||
type: FilterTypes.Picker,
|
type: FilterTypes.Picker,
|
||||||
},
|
},
|
||||||
storyStatus: {
|
storyStatus: {
|
||||||
label: 'Story Status (Translation)',
|
label: 'Story Status',
|
||||||
value: '',
|
value: 'all',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'All', value: 'all' },
|
{ label: 'All', value: 'all' },
|
||||||
{ label: 'Completed', value: 'completed' },
|
{ label: 'Completed', value: 'completed' },
|
||||||
@@ -222,6 +225,15 @@ class ScribbleHubPlugin implements Plugin.PluginBase {
|
|||||||
],
|
],
|
||||||
type: FilterTypes.Picker,
|
type: FilterTypes.Picker,
|
||||||
},
|
},
|
||||||
|
genre_operator: {
|
||||||
|
value: 'and',
|
||||||
|
label: 'Genres (And/Or)',
|
||||||
|
options: [
|
||||||
|
{ label: 'And', value: 'and' },
|
||||||
|
{ label: 'Or', value: 'or' },
|
||||||
|
],
|
||||||
|
type: FilterTypes.Picker,
|
||||||
|
},
|
||||||
genres: {
|
genres: {
|
||||||
label: 'Genres',
|
label: 'Genres',
|
||||||
value: {
|
value: {
|
||||||
@@ -263,12 +275,12 @@ class ScribbleHubPlugin implements Plugin.PluginBase {
|
|||||||
],
|
],
|
||||||
type: FilterTypes.ExcludableCheckboxGroup,
|
type: FilterTypes.ExcludableCheckboxGroup,
|
||||||
},
|
},
|
||||||
genre_operator: {
|
content_warning_operator: {
|
||||||
value: 'and',
|
value: 'and',
|
||||||
label: 'Genre And/Or',
|
label: 'Mature Content (And/Or)',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'OR', value: 'or' },
|
{ label: 'And', value: 'and' },
|
||||||
{ label: 'AND', value: 'and' },
|
{ label: 'Or', value: 'or' },
|
||||||
],
|
],
|
||||||
type: FilterTypes.Picker,
|
type: FilterTypes.Picker,
|
||||||
},
|
},
|
||||||
@@ -285,15 +297,6 @@ class ScribbleHubPlugin implements Plugin.PluginBase {
|
|||||||
],
|
],
|
||||||
type: FilterTypes.ExcludableCheckboxGroup,
|
type: FilterTypes.ExcludableCheckboxGroup,
|
||||||
},
|
},
|
||||||
content_warning_operator: {
|
|
||||||
value: 'and',
|
|
||||||
label: 'Mature Content And/Or',
|
|
||||||
options: [
|
|
||||||
{ label: 'OR', value: 'or' },
|
|
||||||
{ label: 'AND', value: 'and' },
|
|
||||||
],
|
|
||||||
type: FilterTypes.Picker,
|
|
||||||
},
|
|
||||||
} satisfies Filters;
|
} satisfies Filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user