Changed book status to smallint. Added media_type to series. Added 'Hanashi Media' regex resolver for searching. Removed 'Fiction' limitation when searching. Added update series to add new volumes. Fixed search when not all volumes would show up.
This commit is contained in:
@ -59,9 +59,10 @@ export class GoogleService {
|
||||
volume: item.volumeInfo.seriesInfo?.bookDisplayNumber ? parseInt(item.volumeInfo.seriesInfo?.bookDisplayNumber, 10) : undefined,
|
||||
publisher: item.volumeInfo.publisher,
|
||||
authors: item.volumeInfo.authors,
|
||||
categories: item.volumeInfo.categories,
|
||||
categories: item.volumeInfo.categories ?? [],
|
||||
mediaType: null,
|
||||
maturityRating: item.volumeInfo.maturityRating,
|
||||
industryIdentifiers: item.volumeInfo.industryIdentifiers ? Object.assign({}, ...item.volumeInfo.industryIdentifiers.map(i => ({ [i.type]: i.identifier }))) : [],
|
||||
industryIdentifiers: item.volumeInfo.industryIdentifiers ? Object.assign({}, ...item.volumeInfo.industryIdentifiers.map(i => i.type == 'OTHER' ? { [i.identifier.split(':')[0]]: i.identifier.split(':')[1] } : { [i.type]: i.identifier })) : [],
|
||||
publishedAt: new Date(item.volumeInfo.publishedDate),
|
||||
language: item.volumeInfo.language,
|
||||
thumbnail: item.volumeInfo.imageLinks?.thumbnail,
|
||||
@ -69,8 +70,7 @@ export class GoogleService {
|
||||
provider: 'google'
|
||||
}
|
||||
|
||||
let regex = this.getRegexByPublisher(result.publisher);
|
||||
|
||||
const regex = this.getRegexByPublisher(result.publisher);
|
||||
const match = result.title.match(regex);
|
||||
if (match?.groups) {
|
||||
result.title = match.groups['title'].trim();
|
||||
@ -79,19 +79,41 @@ export class GoogleService {
|
||||
}
|
||||
}
|
||||
|
||||
if (match?.groups && 'media_type' in match.groups) {
|
||||
result.mediaType = match.groups['media_type'];
|
||||
} else if (result.categories.includes('Comics & Graphic Novels')) {
|
||||
result.mediaType = 'Comics & Graphic Novels';
|
||||
} else if (result.categories.includes('Fiction') || result.categories.includes('Young Adult Fiction')) {
|
||||
result.mediaType = 'Novel';
|
||||
} else {
|
||||
result.mediaType = 'Book';
|
||||
}
|
||||
|
||||
if (result.mediaType) {
|
||||
if (result.mediaType.toLowerCase() == "light novel") {
|
||||
result.mediaType = 'Light Novel';
|
||||
} else if (result.mediaType.toLowerCase() == 'manga') {
|
||||
result.mediaType = 'Manga';
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private getRegexByPublisher(publisher: string): RegExp {
|
||||
switch (publisher) {
|
||||
case 'J-Novel Club':
|
||||
return /(?<title>.+?):?\sVolume\s(?<volume>\d+)/i;
|
||||
return /^(?<title>.+?):?\sVolume\s(?<volume>\d+)$/i;
|
||||
case 'Yen On':
|
||||
case 'Yen Press':
|
||||
case 'Yen Press LLC':
|
||||
return /(?<title>.+?),?\sVol\.\s(?<volume>\d+)\s\((?<media_type>[\w\s]+)\)/;
|
||||
return /^(?<title>.+?)(?:,?\sVol\.\s(?<volume>\d+))?\s\((?<media_type>[\w\s]+)\)$/;
|
||||
case 'Hanashi Media':
|
||||
return /^(?<title>.+?)\s\((?<media_type>[\w\s]+)\),?\sVol\.\s(?<volume>\d+)$/
|
||||
case 'Regin\'s Chronicles':
|
||||
return /^(?<title>.+?)\s\((?<media_type>[\w\s]+)\)(?<subtitle>\:\s.+?)?$/
|
||||
default:
|
||||
return /(?<title>.+?)(?:,|:|\s\-)?\s(?:Vol(?:\.|ume)?)?\s(?<volume>\d+)/;
|
||||
return /^(?<title>.+?)(?:,|:|\s\-)?\s(?:Vol(?:\.|ume)?)?\s(?<volume>\d+)$/;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user