diff --git a/scraper/lib/repository.js b/scraper/lib/repository.js index d53b4b1..c6e748f 100644 --- a/scraper/lib/repository.js +++ b/scraper/lib/repository.js @@ -15,8 +15,8 @@ const Torrent = database.define('torrent', { infoHash: { type: Sequelize.STRING(64), primaryKey: true }, provider: { type: Sequelize.STRING(32), allowNull: false }, - torrentId: { type: Sequelize.STRING(128) }, - title: { type: Sequelize.STRING(256), allowNull: false }, + torrentId: { type: Sequelize.STRING(512) }, + title: { type: Sequelize.STRING(512), allowNull: false }, size: { type: Sequelize.BIGINT }, type: { type: Sequelize.STRING(16), allowNull: false }, uploadDate: { type: Sequelize.DATE, allowNull: false }, @@ -37,7 +37,7 @@ const File = database.define('file', onDelete: 'CASCADE' }, fileIndex: { type: Sequelize.INTEGER }, - title: { type: Sequelize.STRING(256), allowNull: false }, + title: { type: Sequelize.STRING(512), allowNull: false }, size: { type: Sequelize.BIGINT }, imdbId: { type: Sequelize.STRING(32) }, imdbSeason: { type: Sequelize.INTEGER }, @@ -67,7 +67,9 @@ function connect() { } function getProvider(provider) { - return Provider.findOrCreate({ where: { name: { [Op.eq]: provider.name } }, defaults: provider }); + return Provider.findOrCreate({ where: { name: { [Op.eq]: provider.name } }, defaults: provider }) + .then((result) => result[0]) + .catch(() => provider); } function updateProvider(provider) { diff --git a/scraper/lib/torrentFiles.js b/scraper/lib/torrentFiles.js index 2f52cb5..807daa3 100644 --- a/scraper/lib/torrentFiles.js +++ b/scraper/lib/torrentFiles.js @@ -122,7 +122,7 @@ function parseSeriesFile(file, parsedTorrentName) { fileInfo.season = pathInfo.season; } // force episode to any found number if it was not parsed - if (!fileInfo.episodes) { + if (!fileInfo.episodes && !fileInfo.date) { const epMatcher = fileInfo.title.match(/(?