Fix: AO3 [archive of our own] handling single chapter stories and minor cleanup (#1098)
* Add files via upload * 2nd * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * clean up * clean up * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories and minor cleanup * fix handling single chapter stories and minor cleanup * New source test * New source test * fix bugs * fix bugs * fix bugs * bugs fix
This commit is contained in:
+79
-16
@@ -7,7 +7,7 @@ import { defaultCover } from '@libs/defaultCover';
|
|||||||
class ArchiveOfOurOwn implements Plugin.PluginBase {
|
class ArchiveOfOurOwn implements Plugin.PluginBase {
|
||||||
id = 'archiveofourown';
|
id = 'archiveofourown';
|
||||||
name = 'Archive Of Our Own';
|
name = 'Archive Of Our Own';
|
||||||
version = '1.0.0';
|
version = '1.0.1';
|
||||||
icon = 'src/en/ao3/icon.png';
|
icon = 'src/en/ao3/icon.png';
|
||||||
site = 'https://archiveofourown.org/';
|
site = 'https://archiveofourown.org/';
|
||||||
|
|
||||||
@@ -144,22 +144,85 @@ class ArchiveOfOurOwn implements Plugin.PluginBase {
|
|||||||
.join(',');
|
.join(',');
|
||||||
novel.summary = `Fandom:\n${fandom}\n\nRating:\n${rating}\n\nWarning:\n${warning}\n\nSummary:\n${summary}\n\nSeries:\n${series}\n\nRelationships:\n${relation}\n\nCharacters:\n${character}\n\nStats:\n${stats}`;
|
novel.summary = `Fandom:\n${fandom}\n\nRating:\n${rating}\n\nWarning:\n${warning}\n\nSummary:\n${summary}\n\nSeries:\n${series}\n\nRelationships:\n${relation}\n\nCharacters:\n${character}\n\nStats:\n${stats}`;
|
||||||
const chapterItems: Plugin.ChapterItem[] = [];
|
const chapterItems: Plugin.ChapterItem[] = [];
|
||||||
loadedCheerio('#chapter_index select').each((i, selectEl) => {
|
const releaseTimeText = loadedCheerio('.wrapper dd.published')
|
||||||
loadedCheerio(selectEl)
|
.text()
|
||||||
.find('option')
|
.trim();
|
||||||
.each((i, el) => {
|
const releaseTime = releaseTimeText
|
||||||
const chapterName = loadedCheerio(el).text().trim();
|
? new Date(releaseTimeText).toISOString()
|
||||||
const chapterUrlCode = loadedCheerio(el).attr('value')?.trim();
|
: '';
|
||||||
const chapterUrl = `${novelUrl}/chapters/${chapterUrlCode}`;
|
if (loadedCheerio('#chapter_index select').length > 0) {
|
||||||
|
loadedCheerio('#chapter_index select').each((i, selectEl) => {
|
||||||
|
loadedCheerio(selectEl)
|
||||||
|
.find('option')
|
||||||
|
.each((i, el) => {
|
||||||
|
const chapterName = loadedCheerio(el).text().trim();
|
||||||
|
const chapterUrlCode = loadedCheerio(el).attr('value')?.trim();
|
||||||
|
const chapterUrl = `${novelUrl}/chapters/${chapterUrlCode}`;
|
||||||
|
|
||||||
if (chapterUrl) {
|
if (chapterUrl) {
|
||||||
chapterItems.push({
|
chapterItems.push({
|
||||||
name: chapterName,
|
name: chapterName,
|
||||||
path: new URL(chapterUrl, this.site).toString(),
|
path: chapterUrl,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (chapterItems.length === 0) {
|
||||||
|
loadedCheerio('#chapters h3.title').each((i, titleEl) => {
|
||||||
|
const fullTitleText = loadedCheerio(titleEl).text().trim();
|
||||||
|
const chapterNameMatch = fullTitleText.match(/:\s*(.*)$/);
|
||||||
|
let chapterName = chapterNameMatch ? chapterNameMatch[1].trim() : '';
|
||||||
|
const chapterUrlRaw = loadedCheerio(titleEl)
|
||||||
|
.find('a')
|
||||||
|
.attr('href')
|
||||||
|
?.trim();
|
||||||
|
const chapterUrlCode = chapterUrlRaw?.match(/\/chapters\/(\d+)/)?.[1];
|
||||||
|
const chapterUrl = `${novelUrl}/chapters/${chapterUrlCode}`;
|
||||||
|
|
||||||
|
if (chapterUrl) {
|
||||||
|
if (chapterName === '') {
|
||||||
|
const novelTitle = loadedCheerio('.work .title.heading')
|
||||||
|
.text()
|
||||||
|
.trim();
|
||||||
|
chapterName = novelTitle;
|
||||||
|
}
|
||||||
|
chapterItems.push({
|
||||||
|
name: chapterName,
|
||||||
|
path: chapterUrl,
|
||||||
|
releaseTime: releaseTime,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (chapterItems.length === 0) {
|
||||||
|
loadedCheerio('.work.navigation.actions li a').each((i, el) => {
|
||||||
|
const href = loadedCheerio(el).attr('href');
|
||||||
|
if (href && href.includes('/downloads/')) {
|
||||||
|
const chapterUrlCodeMatch = href.match(/updated_at=(\d+)/);
|
||||||
|
const chapterUrlCode = chapterUrlCodeMatch
|
||||||
|
? chapterUrlCodeMatch[1]
|
||||||
|
: null;
|
||||||
|
let chapterName = loadedCheerio('h2.title.heading').text().trim();
|
||||||
|
|
||||||
|
const chapterUrl = `${novelUrl}/chapters/${chapterUrlCode}`;
|
||||||
|
|
||||||
|
if (chapterUrl) {
|
||||||
|
if (chapterName === '') {
|
||||||
|
const novelTitle = loadedCheerio('.work .title.heading')
|
||||||
|
.text()
|
||||||
|
.trim();
|
||||||
|
chapterName = novelTitle;
|
||||||
|
}
|
||||||
|
chapterItems.push({
|
||||||
|
name: chapterName,
|
||||||
|
path: chapterUrl,
|
||||||
|
releaseTime: releaseTime,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
}
|
||||||
novel.chapters = chapterItems;
|
novel.chapters = chapterItems;
|
||||||
|
|
||||||
return novel;
|
return novel;
|
||||||
@@ -434,8 +497,8 @@ class ArchiveOfOurOwn implements Plugin.PluginBase {
|
|||||||
},
|
},
|
||||||
singlechap: {
|
singlechap: {
|
||||||
value: '',
|
value: '',
|
||||||
label: 'Single Chapter',
|
label: 'Single Chapter Stories',
|
||||||
options: [{ label: 'Days', value: '1' }],
|
options: [{ label: 'Single Chapter', value: '1' }],
|
||||||
type: FilterTypes.Picker,
|
type: FilterTypes.Picker,
|
||||||
},
|
},
|
||||||
author: {
|
author: {
|
||||||
|
|||||||
Reference in New Issue
Block a user