first commit
This commit is contained in:
42
run.js
Normal file
42
run.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const _ = require("lodash");
|
||||
const fs = require("fs");
|
||||
const normalize = require("normalize-path");
|
||||
const { toHeaderCase } = require("js-convert-case");
|
||||
|
||||
const data = fs.readFileSync("./backup/es_video-20250317-0.json", { encoding: "utf8" });
|
||||
|
||||
/**
|
||||
* @type {import("./types").Root[]}
|
||||
*/
|
||||
const sortedArrayOfObjects = data
|
||||
.split("\n")
|
||||
.filter(Boolean)
|
||||
.map(JSON.parse)
|
||||
.filter((i) => !i?.index);
|
||||
|
||||
const filteredVideos = _.filter(sortedArrayOfObjects, (i) => {
|
||||
return _.includes(i.playlist, "PLkA30FL9OreUKQI1w9eQ9D5TE54b5nwUd");
|
||||
});
|
||||
|
||||
const formattedList = filteredVideos.map((i) => {
|
||||
const title = normalize(i.title);
|
||||
// .replaceAll(String.fromCharCode(32), String.fromCharCode(92, 32))
|
||||
// .replaceAll(String.fromCharCode(40), String.fromCharCode(92, 40))
|
||||
// .replaceAll(String.fromCharCode(41), String.fromCharCode(92, 41))
|
||||
// .replace(
|
||||
// /([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,
|
||||
// ""
|
||||
// );
|
||||
|
||||
const changedCase = toHeaderCase(title);
|
||||
|
||||
// const trimmed = _.trim(changedCase);
|
||||
|
||||
return `cp ${i.media_url} output/${title}.${i.media_url.split(".").pop()}`;
|
||||
});
|
||||
|
||||
const concatted = _.concat(["#!/bin/bash"], ["mkdir -p output"], formattedList);
|
||||
|
||||
const joinedList = concatted.join("\n");
|
||||
|
||||
fs.writeFileSync("renamer.sh", joinedList, { encoding: "utf8" });
|
Reference in New Issue
Block a user