updates the package structure and updates initial horriblesubs scraper WIP

This commit is contained in:
TheBeastLT
2020-01-07 13:33:46 +01:00
parent 643917939b
commit 051c50de3f
12 changed files with 264 additions and 280 deletions

View File

@@ -11,6 +11,21 @@ const GLOBAL_TTL = process.env.METADATA_TTL || 7 * 24 * 60 * 60; // 7 days
const MONGO_URI = process.env.MONGODB_URI;
const cache = initiateCache();
const torrentFilesCache = initiateTorrentFilesCache();
function initiateTorrentFilesCache() {
if (MONGO_URI) {
return cacheManager.caching({
store: mangodbStore,
uri: MONGO_URI,
options: {
collection: 'cacheManager',
},
ttl: GLOBAL_TTL,
ignoreCacheErrors: true
});
}
}
function initiateCache() {
if (MONGO_URI) {
@@ -18,7 +33,7 @@ function initiateCache() {
store: mangodbStore,
uri: MONGO_URI,
options: {
collection: 'cacheManager',
collection: 'torrentio_scraper_collection',
},
ttl: GLOBAL_TTL,
ignoreCacheErrors: true
@@ -32,7 +47,7 @@ function initiateCache() {
}
function retrieveTorrentFiles(infoHash) {
return cache.get(`${TORRENT_FILES_KEY_PREFIX}:${infoHash}`)
return torrentFilesCache.get(`${TORRENT_FILES_KEY_PREFIX}:${infoHash}`)
.then((results) => {
if (!results) {
throw new Error('No cached files found');