mirror of
https://github.com/himanshu8443/providers.git
synced 2026-04-17 21:41:45 +00:00
Enhance URL checker with Discord notification support
Added tracking for updated providers to notify Discord.
This commit is contained in:
23
.github/scripts/url-checker.js
vendored
23
.github/scripts/url-checker.js
vendored
@@ -2,6 +2,7 @@ const fs = require('fs');
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const FILE_PATH = 'modflix.json';
|
const FILE_PATH = 'modflix.json';
|
||||||
|
const updatedProviders = []; // Track updated providers for Discord notification
|
||||||
|
|
||||||
// Read the modflix.json file
|
// Read the modflix.json file
|
||||||
function readModflixJson() {
|
function readModflixJson() {
|
||||||
@@ -147,9 +148,20 @@ async function main() {
|
|||||||
try {
|
try {
|
||||||
const newUrl = await checkUrl(url);
|
const newUrl = await checkUrl(url);
|
||||||
if (newUrl && newUrl !== url) {
|
if (newUrl && newUrl !== url) {
|
||||||
|
// Store the old URL before updating
|
||||||
|
const oldUrl = provider.url;
|
||||||
|
|
||||||
|
// Update the provider URL
|
||||||
provider.url = newUrl;
|
provider.url = newUrl;
|
||||||
hasChanges = true;
|
hasChanges = true;
|
||||||
console.log(`Updated ${provider.name} URL from ${url} to ${newUrl}`);
|
console.log(`Updated ${provider.name} URL from ${oldUrl} to ${newUrl}`);
|
||||||
|
|
||||||
|
// Track updated provider for Discord notification
|
||||||
|
updatedProviders.push({
|
||||||
|
name: provider.name,
|
||||||
|
oldUrl: oldUrl,
|
||||||
|
newUrl: newUrl
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`❌ Error processing ${url}: ${error.message}`);
|
console.log(`❌ Error processing ${url}: ${error.message}`);
|
||||||
@@ -162,6 +174,15 @@ async function main() {
|
|||||||
const jsonString = JSON.stringify(providers, null, 2);
|
const jsonString = JSON.stringify(providers, null, 2);
|
||||||
fs.writeFileSync(FILE_PATH, jsonString);
|
fs.writeFileSync(FILE_PATH, jsonString);
|
||||||
console.log(`✅ Updated ${FILE_PATH} with new URLs`);
|
console.log(`✅ Updated ${FILE_PATH} with new URLs`);
|
||||||
|
|
||||||
|
// Output updated providers for Discord notification
|
||||||
|
if (updatedProviders.length > 0) {
|
||||||
|
console.log("\n### UPDATED_PROVIDERS_START ###");
|
||||||
|
for (const provider of updatedProviders) {
|
||||||
|
console.log(`${provider.name}|${provider.oldUrl}|${provider.newUrl}`);
|
||||||
|
}
|
||||||
|
console.log("### UPDATED_PROVIDERS_END ###");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(`ℹ️ No changes needed for ${FILE_PATH}`);
|
console.log(`ℹ️ No changes needed for ${FILE_PATH}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user