forked from Mystique-Play/Mystique
Workflow improvements
This commit is contained in:
parent
8dee5cbec5
commit
133682c6b0
3 changed files with 84 additions and 2 deletions
|
@ -11,6 +11,11 @@ function splitByGroup(filePath) {
|
|||
fs.mkdirSync(groupsDir);
|
||||
}
|
||||
|
||||
// Get existing country files
|
||||
const existingFiles = fs.readdirSync(groupsDir)
|
||||
.filter(file => file.endsWith('.m3u'))
|
||||
.map(file => file.toLowerCase());
|
||||
|
||||
const groups = {};
|
||||
let currentExtinf = null;
|
||||
|
||||
|
@ -43,12 +48,26 @@ function splitByGroup(filePath) {
|
|||
}
|
||||
});
|
||||
|
||||
// Get list of current group files that should exist
|
||||
const currentGroupFiles = Object.keys(groups).map(groupTitle =>
|
||||
`${groupTitle.replace(/[^a-z0-9]/gi, '_').toLowerCase()}.m3u`
|
||||
);
|
||||
|
||||
// Remove files for groups that no longer exist
|
||||
existingFiles.forEach(existingFile => {
|
||||
if (!currentGroupFiles.includes(existingFile)) {
|
||||
const fileToRemove = path.join(groupsDir, existingFile);
|
||||
fs.unlinkSync(fileToRemove);
|
||||
console.log(`Removed obsolete group playlist: ${existingFile}`);
|
||||
}
|
||||
});
|
||||
|
||||
// Write each group to a separate file
|
||||
Object.entries(groups).forEach(([groupTitle, groupLines]) => {
|
||||
const safeGroupTitle = groupTitle.replace(/[^a-z0-9]/gi, '_').toLowerCase();
|
||||
const groupFilePath = path.join(groupsDir, `${safeGroupTitle}.m3u`);
|
||||
fs.writeFileSync(groupFilePath, groupLines.join('\n') + '\n');
|
||||
console.log(`Created group playlist: ${groupFilePath}`);
|
||||
console.log(`Created/updated group playlist: ${groupFilePath}`);
|
||||
});
|
||||
|
||||
// Create a summary of the split
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue