[addon] adds filtering based on provider

This commit is contained in:
TheBeastLT
2020-03-15 23:46:06 +01:00
parent 6c56d76f98
commit 70c279d7d7
11 changed files with 102 additions and 45 deletions

View File

@@ -10,6 +10,16 @@ function toStreamInfo(record) {
return seriesStream(record);
}
function sanitizeStreamInfo(stream) {
if (stream.filters) {
delete stream.filters;
}
if (stream.fileIdx === undefined || stream.fileIdx === null) {
delete stream.fileIdx;
}
return stream;
}
function movieStream(record) {
const titleInfo = titleParser.parse(record.title);
const sameInfo = record.title === record.torrent.title;
@@ -28,6 +38,12 @@ function movieStream(record) {
name: `${ADDON_NAME}\n${record.torrent.provider}`,
title: title,
infoHash: record.infoHash,
fileIdx: record.fileIndex,
filters: {
quality: titleInfo.resolution || record.torrent.resolution || titleInfo.source,
seeders: record.torrent.seeders,
uploadDate: new Date(record.torrent.uploadDate)
}
};
}
@@ -55,6 +71,11 @@ function seriesStream(record) {
title: title,
infoHash: record.infoHash,
fileIdx: record.fileIndex,
filters: {
quality: tInfo.resolution || eInfo.resolution || record.torrent.resolution || tInfo.source || eInfo.source,
seeders: record.torrent.seeders,
uploadDate: new Date(record.torrent.uploadDate)
}
};
}
@@ -64,4 +85,4 @@ function joinDetailParts(parts, prefix = '', delimiter = ' ') {
return filtered.length > 0 ? `${prefix}${filtered}` : undefined;
}
module.exports = { toStreamInfo };
module.exports = { toStreamInfo, sanitizeStreamInfo };