mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-27 17:38:51 +05:00
fix seasons in JackRed
This commit is contained in:
@@ -236,6 +236,13 @@ router.get('/search/:imdbId', async (req, res) => {
|
|||||||
filteredResults = redApiClient.filterByQuality(results, qualityFilter);
|
filteredResults = redApiClient.filterByQuality(results, qualityFilter);
|
||||||
console.log(`Filtered to ${filteredResults.length} torrents by quality`);
|
console.log(`Filtered to ${filteredResults.length} torrents by quality`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Дополнительная фильтрация по сезону для сериалов
|
||||||
|
if (type === 'tv' && season) {
|
||||||
|
const redApiClient = torrentService.redApiClient;
|
||||||
|
filteredResults = redApiClient.filterBySeason(filteredResults, parseInt(season));
|
||||||
|
console.log(`Filtered to ${filteredResults.length} torrents for season ${season}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Группировка или обычная сортировка
|
// Группировка или обычная сортировка
|
||||||
let responseData;
|
let responseData;
|
||||||
|
|||||||
@@ -150,16 +150,24 @@ class RedApiClient {
|
|||||||
* @param {string} title - название на русском
|
* @param {string} title - название на русском
|
||||||
* @param {string} originalTitle - оригинальное название
|
* @param {string} originalTitle - оригинальное название
|
||||||
* @param {number} year - год выпуска
|
* @param {number} year - год выпуска
|
||||||
|
* @param {number} season - номер сезона (опционально)
|
||||||
* @returns {Promise<Array>}
|
* @returns {Promise<Array>}
|
||||||
*/
|
*/
|
||||||
async searchSeries(title, originalTitle, year) {
|
async searchSeries(title, originalTitle, year, season = null) {
|
||||||
const results = await this.searchTorrents({
|
const searchParams = {
|
||||||
title,
|
title,
|
||||||
title_original: originalTitle,
|
title_original: originalTitle,
|
||||||
year,
|
year,
|
||||||
is_serial: 2,
|
is_serial: 2,
|
||||||
category: '5000'
|
category: '5000'
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// Добавляем параметр season если он указан
|
||||||
|
if (season) {
|
||||||
|
searchParams.season = season;
|
||||||
|
}
|
||||||
|
|
||||||
|
const results = await this.searchTorrents(searchParams);
|
||||||
|
|
||||||
return this.filterByContentType(results, 'serial');
|
return this.filterByContentType(results, 'serial');
|
||||||
}
|
}
|
||||||
@@ -645,6 +653,7 @@ class RedApiClient {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Фильтрация результатов по сезону на клиенте
|
* Фильтрация результатов по сезону на клиенте
|
||||||
|
* Показываем только те торренты, где в названии найден номер сезона
|
||||||
* @param {Array} results - результаты поиска
|
* @param {Array} results - результаты поиска
|
||||||
* @param {number} season - номер сезона
|
* @param {number} season - номер сезона
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
@@ -653,21 +662,21 @@ class RedApiClient {
|
|||||||
if (!season) return results;
|
if (!season) return results;
|
||||||
|
|
||||||
return results.filter(torrent => {
|
return results.filter(torrent => {
|
||||||
// Проверяем поле seasons
|
// Используем точную регулярку для поиска сезона в названии
|
||||||
if (torrent.seasons && Array.isArray(torrent.seasons)) {
|
const title = torrent.title;
|
||||||
return torrent.seasons.includes(season);
|
const seasonRegex = /(?:s|сезон)[\s:]*(\d+)|(\d+)\s*сезон/gi;
|
||||||
|
|
||||||
|
// Проверяем, есть ли в названии нужный сезон
|
||||||
|
let foundSeason = false;
|
||||||
|
for (const match of title.matchAll(seasonRegex)) {
|
||||||
|
const seasonNumber = parseInt(match[1] || match[2]);
|
||||||
|
if (!isNaN(seasonNumber) && seasonNumber === season) {
|
||||||
|
foundSeason = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверяем название торрента
|
return foundSeason;
|
||||||
const title = torrent.title.toLowerCase();
|
|
||||||
const seasonPatterns = [
|
|
||||||
new RegExp(`сезон[\\s:]*${season}`, 'i'),
|
|
||||||
new RegExp(`season[\\s:]*${season}`, 'i'),
|
|
||||||
new RegExp(`s${season}(?![0-9])`, 'i'),
|
|
||||||
new RegExp(`${season}[\\s]*сезон`, 'i')
|
|
||||||
];
|
|
||||||
|
|
||||||
return seasonPatterns.some(pattern => pattern.test(title));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user