mirror of
https://github.com/0belous/universal-plugin-repo.git
synced 2025-12-19 19:21:17 -03:00
make update.js
This commit is contained in:
parent
f0f59a45ac
commit
70b749cc80
4 changed files with 5920 additions and 3 deletions
55
update.js
55
update.js
|
|
@ -0,0 +1,55 @@
|
|||
const fs = require('fs/promises');
|
||||
const userAgent = "Jellyfin-Server/10.10.7"; // Required for some repositories
|
||||
|
||||
async function getSources(){
|
||||
let sources = [];
|
||||
try {
|
||||
const fileContent = await fs.readFile('sources.txt', 'utf8');
|
||||
sources = fileContent.split(/\r?\n/).filter(line => line.trim() !== '');
|
||||
} catch (err) {
|
||||
console.error("Error reading sources.txt:", err);
|
||||
return [];
|
||||
}
|
||||
|
||||
let mergedData = [];
|
||||
|
||||
for(const url of sources){
|
||||
try {
|
||||
console.log(`Fetching ${url}...`);
|
||||
const response = await fetch(url, {
|
||||
headers: { 'User-Agent': userAgent }
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Response status: ${response.status}`);
|
||||
}
|
||||
const json = await response.json();
|
||||
mergedData.push(...json);
|
||||
console.log(` -> Merged ${json.length} plugins.`);
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Error processing ${url}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
return mergedData;
|
||||
}
|
||||
|
||||
async function writeManifest(dataToWrite){
|
||||
if (!dataToWrite || dataToWrite.length === 0) {
|
||||
console.log("No data to write to manifest. Aborting.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const manifestJson = JSON.stringify(dataToWrite, null, 2);
|
||||
await fs.writeFile('manifest.json', manifestJson);
|
||||
} catch (err) {
|
||||
console.error('Error writing manifest file:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await writeManifest(await getSources());
|
||||
}
|
||||
|
||||
main();
|
||||
Loading…
Add table
Add a link
Reference in a new issue