Merge branch 'master'
This commit is contained in:
12
package.json
Normal file
12
package.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "netstar-categorizer",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "src/app.js",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "node --watch src/app.js"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
18
playground.js
Normal file
18
playground.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
const { spawn, exec } = require("node:child_process")
|
||||||
|
|
||||||
|
// const subprocess = spawn('ls', ["-l"])
|
||||||
|
|
||||||
|
// subprocess.stdout.on("data", (data) => {
|
||||||
|
// console.log(data.toString("utf-8"))
|
||||||
|
// })
|
||||||
|
|
||||||
|
|
||||||
|
exec("echo '99999.incompass.netstar-inc.com' | bin/gcf1check.sh etc check_categorize_hybrid", { cwd: '/usr/local/gcf1' }, (error, stdout, stderr)=>{
|
||||||
|
if (error) {
|
||||||
|
console.error(error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(stdout.trim())
|
||||||
|
|
||||||
|
})
|
||||||
10
src/app.js
Normal file
10
src/app.js
Normal 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')
|
||||||
176
src/etc/categories-mapping.json
Normal file
176
src/etc/categories-mapping.json
Normal 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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
12
src/use-cases/category-converter-use-case.js
Normal file
12
src/use-cases/category-converter-use-case.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
class CategoryConverterUseCase {
|
||||||
|
constructor(categoriesMapping) {
|
||||||
|
this.categoriesMapping = categoriesMapping
|
||||||
|
}
|
||||||
|
|
||||||
|
execute() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.export = { CategoryConverterUseCase }
|
||||||
27
src/use-cases/get-category-use-case.js
Normal file
27
src/use-cases/get-category-use-case.js
Normal 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 }
|
||||||
|
|
||||||
Reference in New Issue
Block a user