|
|
@@ -619,6 +619,18 @@ export class ProviderVideoSyncService {
|
|
|
|
|
|
const normalized = rawList.map((item) => this.normalizeItem(item));
|
|
|
|
|
|
+ for (const record of normalized) {
|
|
|
+ const previousLength = Array.isArray(record.secondTags)
|
|
|
+ ? record.secondTags.length
|
|
|
+ : 0;
|
|
|
+ record.secondTags = this.sanitizeSecondTags(record.secondTags);
|
|
|
+ if (record.secondTags.length !== previousLength) {
|
|
|
+ this.logger.debug(
|
|
|
+ `[processProviderRawList] sanitized secondTags count ${previousLength} -> ${record.secondTags.length} for ${record.id}`,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
const hasSecondTags = normalized.some(
|
|
|
(v) => Array.isArray(v.secondTags) && v.secondTags.length > 0,
|
|
|
);
|
|
|
@@ -800,6 +812,29 @@ export class ProviderVideoSyncService {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ private sanitizeSecondTags(input: string[] | null | undefined): string[] {
|
|
|
+ if (!Array.isArray(input)) return [];
|
|
|
+
|
|
|
+ const newlineSpam = /\n\s+\n/;
|
|
|
+ const timestamp = /\b\d+:\d{2}:\d{2}\b/;
|
|
|
+
|
|
|
+ return input
|
|
|
+ .map((tag) => (typeof tag === 'string' ? tag.trim() : ''))
|
|
|
+ .filter((tag) => !!tag && !newlineSpam.test(tag) && !timestamp.test(tag));
|
|
|
+ }
|
|
|
+
|
|
|
+ // Example:
|
|
|
+ // sanitizeSecondTags([
|
|
|
+ // 'MISSAV-最近更新',
|
|
|
+ // '1:07:03\n ... 1:04:05',
|
|
|
+ // 'OL',
|
|
|
+ // '恋物癖',
|
|
|
+ // '偷拍',
|
|
|
+ // '单体作品',
|
|
|
+ // '自慰',
|
|
|
+ // '高清',
|
|
|
+ // ]) // -> ['MISSAV-最近更新','OL','恋物癖','偷拍','单体作品','自慰','高清']
|
|
|
+
|
|
|
private async upsertOne(record: any): Promise<UpsertOutcome> {
|
|
|
const id = record?.id as string | undefined;
|
|
|
if (!id) return { ok: false, error: { error: 'Missing id' } };
|