init project

This commit is contained in:
daniel muniz
2024-06-05 18:15:03 -03:00
commit 6d4e9bb221
6 changed files with 255 additions and 0 deletions

10
src/app.js Normal file
View File

@@ -0,0 +1,10 @@
const { GetCategoryUseCase } = require('./use-cases/get-category-use-case.js')
const categoriesMapping = require('../etc/categories-mapping.json')
const getCategoryUseCase = new GetCategoryUseCase({categoriesMapping})
getCategoryUseCase.execute('utorrent.com')

View File

@@ -0,0 +1,176 @@
[
{
"id": "701",
"related": [
"10005"
]
},
{
"id": "20066",
"related": [
"10298"
]
},
{
"id": "401",
"related": [
"10076"
]
},
{
"id": "402",
"related": [
"10297, 10300"
]
},
{
"id": "20068",
"related": [
"10297"
]
},
{
"id": "20082",
"related": [
"10080"
]
},
{
"id": "204",
"related": [
"10016, 10018"
]
},
{
"id": "101",
"related": [
"10084, 10078"
]
},
{
"id": "301",
"related": [
"10009, 10008"
]
},
{
"id": "501",
"related": [
"10283"
]
},
{
"id": "305",
"related": [
"10074"
]
},
{
"id": "205",
"related": [
"10325"
]
},
{
"id": "211",
"related": [
"10001, 10002, 10003"
]
},
{
"id": "20022",
"related": [
"10015, 10072"
]
},
{
"id": "20054",
"related": [
"10019, 10020"
]
},
{
"id": "20008",
"related": [
"10120, 10105"
]
},
{
"id": "20091",
"related": [
"10094"
]
},
{
"id": "20016",
"related": [
"10234"
]
},
{
"id": "1802",
"related": [
"10415"
]
},
{
"id": "20059",
"related": [
"10144, 10141"
]
},
{
"id": "20053",
"related": [
"10107, 10146"
]
},
{
"id": "20070",
"related": [
"10045"
]
},
{
"id": "20071",
"related": [
"10336"
]
},
{
"id": "20077",
"related": [
"10329"
]
},
{
"id": "20013",
"related": [
"10050, 10333"
]
},
{
"id": "20004",
"related": [
"10044, 10337"
]
},
{
"id": "604",
"related": [
"10149, 10163"
]
},
{
"id": "603",
"related": [
"10155"
]
},
{
"id": "801",
"related": [
"10279, 10266"
]
}
]

View File

@@ -0,0 +1,12 @@
class CategoryConverterUseCase {
constructor(categoriesMapping) {
this.categoriesMapping = categoriesMapping
}
execute() {
}
}
module.export = { CategoryConverterUseCase }

View File

@@ -0,0 +1,27 @@
const { exec } = require("node:child_process")
class GetCategoryUseCase {
constructor({categoriesMapping}) {
this.categoriesMapping = categoriesMapping
}
execute(domain) {
exec(`echo ${domain} | bin/gcf1check.sh etc check_categorize_hybrid`, { cwd: '/usr/local/gcf1' }, (error, stdout, stderr)=>{
if (error) {
console.error(error)
return
}
const outputParts = stdout.split(/\s+/); // Split by whitespace
if (outputParts[3]) {
const categoryId = outputParts[2];
console.log({ categoryId });
} else {
console.log({ error: 'Category ID not found' });
}
})
}
}
module.exports = { GetCategoryUseCase }