adds manual movie collection edit
This commit is contained in:
@@ -93,6 +93,14 @@ function getFiles(torrent) {
|
|||||||
return File.findAll({ where: { infoHash: torrent.infoHash } });
|
return File.findAll({ where: { infoHash: torrent.infoHash } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFilesBasedOnTitle(titleQuery) {
|
||||||
|
return File.findAll({ where: { title: { [Op.iLike]: `%${titleQuery}%` } } });
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteFile(file) {
|
||||||
|
return File.destroy({ where: { id: file.id } })
|
||||||
|
}
|
||||||
|
|
||||||
function getSkipTorrent(torrent) {
|
function getSkipTorrent(torrent) {
|
||||||
return SkipTorrent.findByPk(torrent.infoHash)
|
return SkipTorrent.findByPk(torrent.infoHash)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
@@ -129,6 +137,8 @@ module.exports = {
|
|||||||
createTorrent,
|
createTorrent,
|
||||||
createFile,
|
createFile,
|
||||||
getFiles,
|
getFiles,
|
||||||
|
getFilesBasedOnTitle,
|
||||||
|
deleteFile,
|
||||||
getSkipTorrent,
|
getSkipTorrent,
|
||||||
createSkipTorrent,
|
createSkipTorrent,
|
||||||
createFailedImdbTorrent
|
createFailedImdbTorrent
|
||||||
|
|||||||
@@ -97,12 +97,13 @@ async function filesFromTorrentStream(torrent) {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
engine.destroy();
|
engine.destroy();
|
||||||
rejected(new Error('No available connections for torrent!'));
|
rejected(new Error('No available connections for torrent!'));
|
||||||
}, 30000);
|
}, 60000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function isVideo(title) {
|
function isVideo(title) {
|
||||||
return EXTENSIONS.includes(title.path.match(/\.(\w{2,4})$/)[1]);
|
const match = title.path.match(/\.(\w{2,4})$/);
|
||||||
|
return match && EXTENSIONS.includes(match[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dynamicTimeout(torrent) {
|
function dynamicTimeout(torrent) {
|
||||||
|
|||||||
@@ -27,6 +27,27 @@ async function addMissingEpisodes() {
|
|||||||
.forEach((file) => repository.createFile(file));
|
.forEach((file) => repository.createFile(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateMovieCollections() {
|
||||||
|
const collectionFiles = await repository.getFilesBasedOnTitle('logy')
|
||||||
|
.then(files => files.filter(file => file.fileIndex === null))
|
||||||
|
.then(files => files.filter(file => parse(file.title).complete));
|
||||||
|
|
||||||
|
collectionFiles.map(original => repository.getTorrent({ infoHash: original.infoHash })
|
||||||
|
.then(torrent => parseTorrentFiles({ ...torrent, imdbId: original.imdbId }))
|
||||||
|
.then(files => Promise.all(files.map(file => {
|
||||||
|
console.log(file);
|
||||||
|
return repository.createFile(file)
|
||||||
|
})))
|
||||||
|
.then(createdFiled => {
|
||||||
|
if (createdFiled && createdFiled.length) {
|
||||||
|
console.log(`Updated movie collection ${original.title}`);
|
||||||
|
repository.deleteFile(original)
|
||||||
|
} else {
|
||||||
|
console.log(`Failed updating movie collection ${original.title}`);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
async function findAllFiles() {
|
async function findAllFiles() {
|
||||||
/* Test cases */
|
/* Test cases */
|
||||||
/* Anime Season and absolute episodes */
|
/* Anime Season and absolute episodes */
|
||||||
@@ -93,5 +114,6 @@ async function findAllFiles() {
|
|||||||
.then((files) => console.log(files));
|
.then((files) => console.log(files));
|
||||||
}
|
}
|
||||||
|
|
||||||
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'));
|
||||||
Reference in New Issue
Block a user