[addon] compare size with delta instead of equality

This commit is contained in:
TheBeastLT
2020-04-15 14:36:12 +02:00
parent c2389cd9e9
commit 940954bb19

View File

@@ -3,13 +3,13 @@ const { Type } = require('./types');
const { mapLanguages } = require('./languages');
const ADDON_NAME = 'Torrentio';
const SIZE_DELTA = 0.02;
const UNKNOWN_SIZE = 300000000;
function toStreamInfo(record) {
const torrentInfo = titleParser.parse(record.torrent.title);
const fileInfo = titleParser.parse(record.title);
const sameInfo = !Number.isInteger(record.fileIndex)
|| record.size !== UNKNOWN_SIZE && record.size === record.torrent.size;
const sameInfo = !Number.isInteger(record.fileIndex) || Math.abs(record.size / record.torrent.size - 1) < SIZE_DELTA;
const title = joinDetailParts(
[
joinDetailParts([record.torrent.title.replace(/[, ]+/g, ' ')]),