Wip Blacklisting dmm porn
Create adult text classifier ML Model wip - starting to write PTN in c# More work on season, show and movie parsing Remove ML project
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
"bottleneck": "^2.19.5",
|
||||
"cache-manager": "^5.4.0",
|
||||
"fuse.js": "^7.0.0",
|
||||
"google-sr": "^3.2.1",
|
||||
"inversify": "^6.0.2",
|
||||
"magnet-uri": "^6.2.0",
|
||||
"moment": "^2.30.1",
|
||||
|
||||
@@ -10,7 +10,6 @@ import {IMetadataService} from "@interfaces/metadata_service";
|
||||
import {IMongoRepository} from "@mongo/interfaces/mongo_repository";
|
||||
import {IocTypes} from "@setup/ioc_types";
|
||||
import axios from 'axios';
|
||||
import {ResultTypes, search} from 'google-sr';
|
||||
import {inject, injectable} from "inversify";
|
||||
import nameToImdb from 'name-to-imdb';
|
||||
|
||||
@@ -46,10 +45,7 @@ export class MetadataService implements IMetadataService {
|
||||
const name = this.escapeTitle(info.title!);
|
||||
const year = info.year || (info.date && info.date.slice(0, 4));
|
||||
const key = `${name}_${year || 'NA'}_${info.type}`;
|
||||
const query = `${name} ${year || ''} ${info.type} imdb`;
|
||||
const fallbackQuery = `${name} ${info.type} imdb`;
|
||||
const googleQuery = year ? query : fallbackQuery;
|
||||
|
||||
|
||||
const imdbInMongo = await this.mongoRepository.getImdbId(name, info.type, year);
|
||||
|
||||
if (imdbInMongo) {
|
||||
@@ -62,8 +58,7 @@ export class MetadataService implements IMetadataService {
|
||||
);
|
||||
return imdbId && 'tt' + imdbId.replace(/tt0*([1-9][0-9]*)$/, '$1').padStart(7, '0');
|
||||
} catch (error) {
|
||||
const imdbIdFallback = await this.getIMDbIdFromGoogle(googleQuery);
|
||||
return imdbIdFallback && 'tt' + imdbIdFallback.toString().replace(/tt0*([1-9][0-9]*)$/, '$1').padStart(7, '0');
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,23 +215,4 @@ export class MetadataService implements IMetadataService {
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
private getIMDbIdFromGoogle = async (query: string): Promise<string | undefined> => {
|
||||
try {
|
||||
const searchResults = await search({query: query});
|
||||
for (const result of searchResults) {
|
||||
if (result.type === ResultTypes.SearchResult) {
|
||||
if (result.link.includes('imdb.com/title/')) {
|
||||
const match = result.link.match(/imdb\.com\/title\/(tt\d+)/);
|
||||
if (match) {
|
||||
return match[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
} catch (error) {
|
||||
throw new Error('Failed to find IMDb ID from Google search');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -103,10 +103,12 @@ describe('Configuration Tests', () => {
|
||||
it('should populate metadataConfig correctly', async() => {
|
||||
process.env.IMDB_CONCURRENT = '1';
|
||||
process.env.IMDB_INTERVAL_MS = '1000';
|
||||
process.env.TITLE_MATCH_THRESHOLD = '0.1';
|
||||
const {configurationService} = await import("@services/configuration_service");
|
||||
const {metadataConfig} = configurationService;
|
||||
expect(metadataConfig.IMDB_CONCURRENT).toBe(1);
|
||||
expect(metadataConfig.IMDB_INTERVAL_MS).toBe(1000);
|
||||
expect(metadataConfig.TITLE_MATCH_THRESHOLD).toBe(0.1);
|
||||
});
|
||||
|
||||
it('should populate rabbitConfig correctly', async () => {
|
||||
|
||||
@@ -5,20 +5,28 @@ import {MongoRepository} from "@mongo/mongo_repository";
|
||||
import {IocTypes} from "@setup/ioc_types";
|
||||
import {Container, inject} from "inversify";
|
||||
|
||||
jest.mock('@services/configuration_service', () => {
|
||||
const metadataConfig = {
|
||||
TITLE_MATCH_THRESHOLD: 0.25,
|
||||
}
|
||||
|
||||
const cacheConfig = {
|
||||
MONGODB_HOST: 'localhost',
|
||||
MONGODB_PORT: '27017',
|
||||
MONGODB_DB: 'knightcrawler',
|
||||
MONGODB_USER: 'mongo',
|
||||
MONGODB_PASSWORD: 'mongo',
|
||||
get MONGO_URI(): string {
|
||||
return `mongodb://${this.MONGODB_USER}:${this.MONGODB_PASSWORD}@${this.MONGODB_HOST}:${this.MONGODB_PORT}/${this.MONGODB_DB}?authSource=admin`;
|
||||
},
|
||||
};
|
||||
|
||||
jest.doMock('@services/configuration_service', () => {
|
||||
return {
|
||||
configurationService: {
|
||||
cacheConfig: {
|
||||
MONGODB_HOST: 'localhost',
|
||||
MONGODB_PORT: '27017',
|
||||
MONGODB_DB: 'knightcrawler',
|
||||
MONGODB_USER: 'mongo',
|
||||
MONGODB_PASSWORD: 'mongo',
|
||||
get MONGO_URI(): string {
|
||||
return `mongodb://${this.MONGODB_USER}:${this.MONGODB_PASSWORD}@${this.MONGODB_HOST}:${this.MONGODB_PORT}/${this.MONGODB_DB}?authSource=admin`;
|
||||
}
|
||||
},
|
||||
}
|
||||
cacheConfig: cacheConfig,
|
||||
metadataConfig: metadataConfig,
|
||||
},
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user