Last active
October 1, 2023 08:39
-
-
Save flleeppyy/20b343f6b84cddf76c61ca990fd9921a to your computer and use it in GitHub Desktop.
My personal yt-dlp commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const musicDirectory = 'D:/Music/Music'; // Specify your music directory here | |
function processFolders(directory) { | |
fs.readdir(directory, (err, files) => { | |
if (err) { | |
console.error(`Error reading directory: ${directory}`); | |
return; | |
} | |
files.forEach((file) => { | |
const filePath = path.join(directory, file); | |
fs.stat(filePath, (err, stats) => { | |
if (err) { | |
console.error(`Error stating file: ${filePath}`); | |
return; | |
} | |
if (stats.isDirectory()) { | |
const yearRegex = /\(\d{4}\)$/; // Matches the year in parentheses at the end of the folder name | |
const hasYearTemplate = yearRegex.test(file); | |
if (hasYearTemplate) { | |
const folderNameWithoutYear = file.replace(yearRegex, '').trim(); | |
const destinationDirectory = path.join(directory, folderNameWithoutYear); | |
const destinationPath = path.join(destinationDirectory, file); | |
fs.stat(destinationDirectory, (err, destStats) => { | |
if (!err && destStats.isDirectory()) { | |
fs.readdir(filePath, (err, files) => { | |
if (err) { | |
console.error(`Error reading directory: ${filePath}`); | |
return; | |
} | |
files.forEach((file) => { | |
const sourceFilePath = path.join(filePath, file); | |
const destinationFilePath = path.join(destinationDirectory, file); | |
fs.copyFileSync(sourceFilePath, destinationFilePath); | |
console.log(`Copied file: ${file}`); | |
}); | |
fs.rmdirSync(filePath, { recursive: true }); | |
console.log(`Deleted directory: ${filePath}`); | |
}); | |
} else { | |
console.log(`Skipping directory: ${filePath}`); | |
} | |
}); | |
} else { | |
processFolders(filePath); | |
} | |
} | |
}); | |
}); | |
}); | |
} | |
processFolders(musicDirectory); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const songs = fs.readdirSync(process.cwd()); | |
const topicString = " - Topic"; | |
for (const song of songs) { | |
if (song.includes(topicString)) { | |
try {fs.renameSync(song, song.replace(topicString, ""));} catch (err) {console.error(err)} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#playlist as album | |
yt-dlp -x --audio-format mp3 --audio-quality 320k -f bestaudio --concurrent-fragments 4 --output "%(uploader)s - %(album)s - %(title)s - %(playlist_index)s.%(ext)s" https://example.com/playlist?21 | |
# video with sections as album | |
yt-dlp -x --audio-format mp3 --audio-quality 320k -f 251 --split-chapters --output "chapter:%(uploader)s - %(title) - %(section_title)s - %(section_number)s.%(ext)s" https://www.youtube.com/watch?v=XNL3jbMhs0Q |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment