adds kitsu mapping for horrible subs

This commit is contained in:
TheBeastLT
2019-12-30 18:35:02 +01:00
parent a73cdb6b54
commit 7aa0572fb8
3 changed files with 3612 additions and 8832 deletions

View File

@@ -39,11 +39,12 @@ async function _scrapeAllShows() {
async function initMapping() {
console.log(`${NAME}: initiating kitsu mapping...`);
const currentMapping = require('../horrible_subs_mapping');
const mappings = Object.values(currentMapping);
const shows = await horriblesubs.allShows()
.then((shows) => Promise.all(shows.map((show) => limiter.schedule(() => enrichShow(show)))))
.then((shows) => shows.reduce((map, show) => (map[show.showId] = show, map), {}));
const kitsuIds = Object.values(shows).map((show) => show.kitsu_id);
console.log(JSON.stringify(kitsuIds));
.then((shows) => shows.filter((show) => !mappings.find((mapping) => mapping.title === show.title)))
.then((shows) => Promise.all(shows.map((show) => limiter.schedule(() => enrichShow(show)))))
.then((shows) => shows.reduce((map, show) => (map[show.title] = show, map), currentMapping));
fs.writeFile("./horrible_subs_mapping.json", JSON.stringify(shows), 'utf8', function (err) {
if (err) {
@@ -57,8 +58,7 @@ async function enrichShow(show) {
console.log(`${NAME}: getting show info for ${show.title}...`);
const showId = await horriblesubs._getShowId(show.url)
.catch((error) => show.title);
const slug = show.url.replace(/^.*\//, '');
const metadata = await getKitsuId(slug)
const metadata = await getKitsuId(show.title)
.then((kitsuId) => getKitsuMetadata(kitsuId))
.catch((error) => {
console.log(`Failed getting kitsu meta: ${error.message}`);
@@ -75,11 +75,6 @@ async function enrichShow(show) {
}
}
const hardcodedShows = {
'199': 'tt2098220',
'347': 'tt0388629'
};
async function _parseShowData(showData) {
console.log(`${NAME}: scrapping ${showData.title} data...`);
const imdbId = hardcodedShows[showData.showId] || await getImdbId({