mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
@@ -18,6 +18,7 @@ import {
|
||||
} from '../../debrid/index.js';
|
||||
import { PTT } from '../../parser/index.js';
|
||||
import { ParseResult } from 'go-ptt';
|
||||
import { preprocessTitle } from '../../parser/utils.js';
|
||||
|
||||
// we have a list of torrents which need to be
|
||||
// - 1. checked for instant availability for each configured debrid service
|
||||
@@ -158,7 +159,15 @@ async function processTorrentsForDebridService(
|
||||
|
||||
const parsedTorrent = parsedFiles.get(torrent.title ?? '');
|
||||
if (metadata && parsedTorrent) {
|
||||
if (torrent.confirmed !== true && isTitleWrong(parsedTorrent, metadata)) {
|
||||
const preprocessedTitle = preprocessTitle(
|
||||
parsedTorrent.title,
|
||||
torrent.title ?? '',
|
||||
metadata.titles
|
||||
);
|
||||
if (
|
||||
torrent.confirmed !== true &&
|
||||
isTitleWrong({ title: preprocessedTitle }, metadata)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (isSeasonWrong(parsedTorrent, metadata)) {
|
||||
|
||||
@@ -17,7 +17,11 @@ import {
|
||||
FileInfo,
|
||||
TitleMetadata,
|
||||
} from './base.js';
|
||||
import { normaliseTitle, titleMatch } from '../parser/utils.js';
|
||||
import {
|
||||
normaliseTitle,
|
||||
preprocessTitle,
|
||||
titleMatch,
|
||||
} from '../parser/utils.js';
|
||||
import { partial_ratio } from 'fuzzball';
|
||||
|
||||
const logger = createLogger('debrid');
|
||||
@@ -218,7 +222,19 @@ export async function selectFileInTorrentOrNZB(
|
||||
}
|
||||
|
||||
// Title matching (third priority)
|
||||
if (parsed && !isTitleWrong(parsed, metadata)) {
|
||||
if (
|
||||
parsed?.title &&
|
||||
!isTitleWrong(
|
||||
{
|
||||
title: preprocessTitle(
|
||||
parsed.title,
|
||||
torrentOrNZB.title ?? '',
|
||||
metadata?.titles ?? []
|
||||
),
|
||||
},
|
||||
metadata
|
||||
)
|
||||
) {
|
||||
score += 100;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,39 @@ export function titleMatch(
|
||||
return highestScore >= threshold;
|
||||
}
|
||||
|
||||
export function preprocessTitle(
|
||||
parsedTitle: string,
|
||||
filename: string,
|
||||
titles: string[]
|
||||
) {
|
||||
let preprocessedTitle = parsedTitle;
|
||||
|
||||
const altTitleSeparators = ['/', ' aka '];
|
||||
for (const sep of altTitleSeparators) {
|
||||
if (
|
||||
preprocessedTitle?.toLowerCase().includes(sep) &&
|
||||
!titles.some((title) => title.toLowerCase().includes(sep))
|
||||
) {
|
||||
preprocessedTitle =
|
||||
preprocessedTitle.split(sep)[0]?.trim() ?? preprocessedTitle;
|
||||
logger.debug(
|
||||
`Updated title from ${parsedTitle} to ${preprocessedTitle} because of ${sep}`
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
titles.some((title) => title.toLowerCase().includes('saga')) &&
|
||||
filename?.toLowerCase().includes('saga') &&
|
||||
!preprocessedTitle.toLowerCase().includes('saga')
|
||||
) {
|
||||
preprocessedTitle += ' Saga';
|
||||
}
|
||||
|
||||
return preprocessedTitle;
|
||||
}
|
||||
|
||||
export function normaliseTitle(title: string) {
|
||||
return title
|
||||
.normalize('NFD')
|
||||
|
||||
@@ -15,7 +15,7 @@ import { StreamSelector } from '../parser/streamExpression.js';
|
||||
import StreamUtils from './utils.js';
|
||||
import { MetadataService } from '../metadata/service.js';
|
||||
import { Metadata } from '../metadata/utils.js';
|
||||
import { titleMatch } from '../parser/utils.js';
|
||||
import { preprocessTitle, titleMatch } from '../parser/utils.js';
|
||||
import { partial_ratio } from 'fuzzball';
|
||||
import { calculateAbsoluteEpisode } from '../builtins/utils/general.js';
|
||||
import { formatBytes } from '../formatters/utils.js';
|
||||
@@ -479,19 +479,16 @@ class StreamFilterer {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!streamTitle) {
|
||||
if (!streamTitle || !stream.filename) {
|
||||
// only filter out movies without a year as series results usually don't include a year
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
requestedMetadata.title.toLowerCase().includes('saga') &&
|
||||
stream.filename?.toLowerCase().includes('saga') &&
|
||||
!streamTitle.toLowerCase().includes('saga')
|
||||
) {
|
||||
streamTitle += ' Saga';
|
||||
stream.parsedFile!.title = streamTitle;
|
||||
}
|
||||
streamTitle = preprocessTitle(
|
||||
streamTitle,
|
||||
stream.filename,
|
||||
requestedMetadata.titles
|
||||
);
|
||||
|
||||
if (titleMatchingOptions.mode === 'exact') {
|
||||
return titleMatch(
|
||||
|
||||
Reference in New Issue
Block a user