Added channel map to Naughty America.
This commit is contained in:
26
src/tools/naughtyamerica-map.js
Normal file
26
src/tools/naughtyamerica-map.js
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
const knex = require('../knex');
|
||||
const slugify = require('../utils/slugify');
|
||||
|
||||
async function init() {
|
||||
const channels = await knex('entities')
|
||||
.select('entities.*')
|
||||
.leftJoin('entities as parents', 'parents.id', 'entities.parent_id')
|
||||
.where('parents.slug', 'in', ['naughtyamerica', 'naughtyamericavr']);
|
||||
|
||||
const mapped = Object.fromEntries(channels.map((channel) => {
|
||||
const path = new URL(channel.url).pathname.match(/\/site\/(.*)/)?.[1];
|
||||
const urlSlug = slugify(path, '');
|
||||
|
||||
if (!urlSlug || urlSlug === channel.slug) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [urlSlug, channel.slug];
|
||||
}).filter(Boolean));
|
||||
|
||||
console.log(mapped);
|
||||
}
|
||||
|
||||
init();
|
||||
Reference in New Issue
Block a user