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
59
.forgejo/scripts/readme-m3u.js
Normal file
59
.forgejo/scripts/readme-m3u.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function updateReadme(m3uPath) {
|
||||
// Get list of group files
|
||||
const groupsDir = path.join(path.dirname(m3uPath), 'countries');
|
||||
const groups = {};
|
||||
|
||||
// Read the main M3U to get original group names and channel counts
|
||||
const content = fs.readFileSync(m3uPath, 'utf8');
|
||||
const lines = content.split('\n');
|
||||
let totalChannels = 0;
|
||||
|
||||
lines.forEach(line => {
|
||||
if (line.startsWith('#EXTINF')) {
|
||||
totalChannels++;
|
||||
const groupMatch = line.match(/group-title="([^"]*)"/);
|
||||
const groupTitle = groupMatch ? groupMatch[1] : 'Unknown';
|
||||
groups[groupTitle] = (groups[groupTitle] || 0) + 1;
|
||||
}
|
||||
});
|
||||
|
||||
// Start building README content
|
||||
let readmeContent = '# Mystique IPTV\n\n';
|
||||
readmeContent += '## Available Playlists\n\n';
|
||||
readmeContent += '| Playlist | Channels | Link |\n';
|
||||
readmeContent += '|----------|-----------|------|\n';
|
||||
|
||||
// Add main playlist first
|
||||
const mainPlaylistName = path.basename(m3uPath);
|
||||
readmeContent += `| **Complete (All countries)** | ${totalChannels} | [${mainPlaylistName}](${mainPlaylistName}) |\n`;
|
||||
|
||||
// Sort groups alphabetically
|
||||
const sortedGroups = Object.entries(groups).sort((a, b) => a[0].localeCompare(b[0]));
|
||||
|
||||
// Add each group to the table
|
||||
sortedGroups.forEach(([groupName, channelCount]) => {
|
||||
const safeGroupName = groupName.replace(/[^a-z0-9]/gi, '_').toLowerCase();
|
||||
readmeContent += `| ${groupName} | ${channelCount} | [${safeGroupName}.m3u](countries/${safeGroupName}.m3u) |\n`;
|
||||
});
|
||||
|
||||
const readmePath = path.join(path.dirname(m3uPath), 'README.md');
|
||||
|
||||
fs.writeFileSync(readmePath, readmeContent);
|
||||
console.log('README.md has been updated with playlist and group information');
|
||||
}
|
||||
|
||||
const filePath = process.argv[2];
|
||||
if (!filePath) {
|
||||
console.error('Please provide the path to mystique.m3u');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
updateReadme(filePath);
|
||||
} catch (error) {
|
||||
console.error('Error updating README:', error.message);
|
||||
process.exit(1);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue