stores files without found episode
This commit is contained in:
@@ -86,9 +86,6 @@ async function filesFromTorrentStream(torrent) {
|
|||||||
if (!torrent.infoHash && !torrent.magnetLink) {
|
if (!torrent.infoHash && !torrent.magnetLink) {
|
||||||
return Promise.reject(new Error("no infoHash or magnetLink"));
|
return Promise.reject(new Error("no infoHash or magnetLink"));
|
||||||
}
|
}
|
||||||
if (torrent.seeders === 0) {
|
|
||||||
return Promise.reject(new Error("no seeders for the torrent"));
|
|
||||||
}
|
|
||||||
return new Promise((resolve, rejected) => {
|
return new Promise((resolve, rejected) => {
|
||||||
const engine = new torrentStream(torrent.magnetLink || torrent.infoHash, { connections: MAX_PEER_CONNECTIONS });
|
const engine = new torrentStream(torrent.magnetLink || torrent.infoHash, { connections: MAX_PEER_CONNECTIONS });
|
||||||
|
|
||||||
@@ -125,8 +122,8 @@ function filterSamples(files) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function filterExtras(files) {
|
function filterExtras(files) {
|
||||||
const isSample = file => file.path.match(/extras?\//i);
|
const isExtra = file => file.path.match(/extras?\//i);
|
||||||
return files.filter(file => !isSample(file));
|
return files.filter(file => !isExtra(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
function dynamicTimeout(torrent) {
|
function dynamicTimeout(torrent) {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ async function parseTorrentFiles(torrent) {
|
|||||||
.then((files) => assignKitsuOrImdbEpisodes(files, metadata))
|
.then((files) => assignKitsuOrImdbEpisodes(files, metadata))
|
||||||
.then((files) => Promise.all(files.map(file => file.isMovie
|
.then((files) => Promise.all(files.map(file => file.isMovie
|
||||||
? mapSeriesMovie(file, torrent)
|
? mapSeriesMovie(file, torrent)
|
||||||
: mapSeriesEpisode(file, torrent))))
|
: mapSeriesEpisode(file, torrent, files))))
|
||||||
.then((files) => files.reduce((a, b) => a.concat(b), []))
|
.then((files) => files.reduce((a, b) => a.concat(b), []))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(`Failed getting files for ${torrent.title}`, error.message);
|
console.log(`Failed getting files for ${torrent.title}`, error.message);
|
||||||
@@ -72,8 +72,17 @@ async function getSeriesFiles(torrent, parsedTorrentName) {
|
|||||||
return torrentFiles(torrent);
|
return torrentFiles(torrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mapSeriesEpisode(file, torrent) {
|
async function mapSeriesEpisode(file, torrent, files) {
|
||||||
if (!file.episodes && !file.kitsuEpisodes) {
|
if (!file.episodes && !file.kitsuEpisodes) {
|
||||||
|
if (files.some(otherFile => otherFile.episodes || otherFile.kitsuEpisodes) || parse(torrent.title).seasons) {
|
||||||
|
return Promise.resolve({
|
||||||
|
infoHash: torrent.infoHash,
|
||||||
|
fileIndex: file.fileIndex,
|
||||||
|
title: file.path || file.name,
|
||||||
|
size: file.size,
|
||||||
|
imdbId: torrent.imdbId || file.imdbId,
|
||||||
|
});
|
||||||
|
}
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
}
|
}
|
||||||
const episodeIndexes = [...(file.episodes || file.kitsuEpisodes).keys()];
|
const episodeIndexes = [...(file.episodes || file.kitsuEpisodes).keys()];
|
||||||
|
|||||||
@@ -77,11 +77,13 @@ async function reapplyEpisodeDecomposing(infoHash, includeSourceFiles = true) {
|
|||||||
.then(newFiles => newFiles.map(file => {
|
.then(newFiles => newFiles.map(file => {
|
||||||
if (fileIndexMap[file.fileIndex]) {
|
if (fileIndexMap[file.fileIndex]) {
|
||||||
const originalFile = fileIndexMap[file.fileIndex].shift();
|
const originalFile = fileIndexMap[file.fileIndex].shift();
|
||||||
originalFile.imdbSeason = file.imdbSeason;
|
if (originalFile) {
|
||||||
originalFile.imdbEpisode = file.imdbEpisode;
|
originalFile.imdbSeason = file.imdbSeason;
|
||||||
originalFile.kitsuId = file.kitsuId;
|
originalFile.imdbEpisode = file.imdbEpisode;
|
||||||
originalFile.kitsuEpisode = file.kitsuEpisode;
|
originalFile.kitsuId = file.kitsuId;
|
||||||
return originalFile;
|
originalFile.kitsuEpisode = file.kitsuEpisode;
|
||||||
|
return originalFile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}))
|
}))
|
||||||
@@ -166,5 +168,5 @@ async function findAllFiles() {
|
|||||||
//addMissingEpisodes().then(() => console.log('Finished'));
|
//addMissingEpisodes().then(() => console.log('Finished'));
|
||||||
//findAllFiles().then(() => console.log('Finished'));
|
//findAllFiles().then(() => console.log('Finished'));
|
||||||
//updateMovieCollections().then(() => console.log('Finished'));
|
//updateMovieCollections().then(() => console.log('Finished'));
|
||||||
//reapplyEpisodeDecomposing().then(() => console.log('Finished'));
|
reapplyEpisodeDecomposing('87e7354028f2aaab56dfd0dabbab679a1b54c3c0', false).then(() => console.log('Finished'));
|
||||||
reapplySeriesSeasonsSavedAsMovies().then(() => console.log('Finished'));
|
//reapplySeriesSeasonsSavedAsMovies().then(() => console.log('Finished'));
|
||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1714,7 +1714,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"parse-torrent-title": {
|
"parse-torrent-title": {
|
||||||
"version": "git://github.com/TheBeastLT/parse-torrent-title.git#286c5f9b06a2ac38354ea249a1d96b17919ba930",
|
"version": "git://github.com/TheBeastLT/parse-torrent-title.git#6767960f4c40c7c97fd2f8e191cf099ab7dcd1dd",
|
||||||
"from": "git://github.com/TheBeastLT/parse-torrent-title.git#master"
|
"from": "git://github.com/TheBeastLT/parse-torrent-title.git#master"
|
||||||
},
|
},
|
||||||
"parseurl": {
|
"parseurl": {
|
||||||
|
|||||||
Reference in New Issue
Block a user