mirror of
https://github.com/himanshu8443/providers.git
synced 2026-06-19 14:07:45 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb9cb22c70 | |||
| 38fd128eaa | |||
| bfe80ce95a | |||
| 55d79974db | |||
| 68dd646b90 | |||
| 1d39a56cc0 | |||
| 0081034e35 |
+102
-79
@@ -4,6 +4,17 @@ const axios = require('axios');
|
|||||||
const FILE_PATH = 'modflix.json';
|
const FILE_PATH = 'modflix.json';
|
||||||
const updatedProviders = []; // Track updated providers for Discord notification
|
const updatedProviders = []; // Track updated providers for Discord notification
|
||||||
|
|
||||||
|
const DEFAULT_HEADERS = {
|
||||||
|
'User-Agent':
|
||||||
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0 Safari/537.36',
|
||||||
|
Accept:
|
||||||
|
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
|
||||||
|
'Accept-Language': 'en-US,en;q=0.9',
|
||||||
|
'Accept-Encoding': 'gzip, deflate, br',
|
||||||
|
Connection: 'keep-alive',
|
||||||
|
'Upgrade-Insecure-Requests': '1'
|
||||||
|
};
|
||||||
|
|
||||||
// Read the modflix.json file
|
// Read the modflix.json file
|
||||||
function readModflixJson() {
|
function readModflixJson() {
|
||||||
try {
|
try {
|
||||||
@@ -31,103 +42,115 @@ function hasTrailingSlash(url) {
|
|||||||
return url.endsWith('/') && !url.endsWith('://');
|
return url.endsWith('/') && !url.endsWith('://');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check URL and return new URL if domain redirected
|
function getFinalUrl(response, originalUrl) {
|
||||||
|
return (
|
||||||
|
response?.request?.res?.responseUrl ||
|
||||||
|
response?.request?._redirectable?._currentUrl ||
|
||||||
|
response?.config?.url ||
|
||||||
|
originalUrl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeOrigin(url) {
|
||||||
|
try {
|
||||||
|
return new URL(url).origin;
|
||||||
|
} catch {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function requestUrl(method, url) {
|
||||||
|
return axios({
|
||||||
|
method,
|
||||||
|
url,
|
||||||
|
maxRedirects: 5,
|
||||||
|
timeout: 10000,
|
||||||
|
validateStatus: status => true,
|
||||||
|
headers: DEFAULT_HEADERS
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function logVerboseResult(url, response, finalUrl) {
|
||||||
|
const status = response?.status ?? 'unknown';
|
||||||
|
const locationHeader = response?.headers?.location;
|
||||||
|
console.log(
|
||||||
|
`ℹ️ ${url} -> status=${status} final=${finalUrl}` +
|
||||||
|
(locationHeader ? ` location=${locationHeader}` : '')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouldUpdateFromFinalUrl(originalUrl, finalUrl) {
|
||||||
|
const originalDomain = getDomain(originalUrl);
|
||||||
|
const finalDomain = getDomain(finalUrl);
|
||||||
|
return finalDomain && finalDomain !== originalDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check URL and return new URL if domain redirected or resolved elsewhere
|
||||||
async function checkUrl(url) {
|
async function checkUrl(url) {
|
||||||
try {
|
try {
|
||||||
// Set timeout to 10 seconds to avoid hanging
|
const response = await requestUrl('get', url);
|
||||||
const response = await axios.head(url, {
|
const finalUrl = getFinalUrl(response, url);
|
||||||
maxRedirects: 0,
|
logVerboseResult(url, response, finalUrl);
|
||||||
timeout: 10000,
|
|
||||||
validateStatus: status => true
|
if (shouldUpdateFromFinalUrl(url, finalUrl)) {
|
||||||
});
|
const updatedUrl = normalizeOrigin(finalUrl) + (hasTrailingSlash(url) ? '/' : '');
|
||||||
|
console.log(`🔄 ${url} resolved to ${finalUrl}`);
|
||||||
|
console.log(`Will update to: ${updatedUrl} (preserved trailing slash: ${hasTrailingSlash(url)})`);
|
||||||
|
return updatedUrl;
|
||||||
|
}
|
||||||
|
|
||||||
// If status is 200, no change needed
|
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
console.log(`✅ ${url} is valid (200 OK)`);
|
console.log(`✅ ${url} is valid (200 OK)`);
|
||||||
return null;
|
return null;
|
||||||
} else if (response.status >= 300 && response.status < 400) {
|
}
|
||||||
// Handle redirects
|
|
||||||
|
if (response.status >= 300 && response.status < 400) {
|
||||||
const newLocation = response.headers.location;
|
const newLocation = response.headers.location;
|
||||||
if (newLocation) {
|
if (newLocation) {
|
||||||
// If it's a relative redirect, construct the full URL
|
|
||||||
let fullRedirectUrl = newLocation;
|
let fullRedirectUrl = newLocation;
|
||||||
if (!newLocation.startsWith('http')) {
|
if (!newLocation.startsWith('http')) {
|
||||||
const baseUrl = new URL(url);
|
const baseUrl = new URL(url);
|
||||||
fullRedirectUrl = new URL(newLocation, baseUrl.origin).toString();
|
fullRedirectUrl = new URL(newLocation, baseUrl.origin).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`🔄 ${url} redirects to ${fullRedirectUrl}`);
|
if (shouldUpdateFromFinalUrl(url, fullRedirectUrl)) {
|
||||||
|
const newDomain = normalizeOrigin(fullRedirectUrl);
|
||||||
// Get the new domain
|
|
||||||
const newDomain = getDomain(fullRedirectUrl);
|
|
||||||
|
|
||||||
// Check if original URL had a trailing slash
|
|
||||||
const needsTrailingSlash = hasTrailingSlash(url);
|
|
||||||
|
|
||||||
// Create new URL: new domain + trailing slash if the original had one
|
|
||||||
let finalUrl = newDomain;
|
|
||||||
if (needsTrailingSlash) {
|
|
||||||
finalUrl += '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Will update to: ${finalUrl} (preserved trailing slash: ${needsTrailingSlash})`);
|
|
||||||
return finalUrl;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log(`⚠️ ${url} returned status ${response.status}`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
// Try GET request if HEAD fails
|
|
||||||
try {
|
|
||||||
const response = await axios.get(url, {
|
|
||||||
maxRedirects: 0,
|
|
||||||
timeout: 10000,
|
|
||||||
validateStatus: status => true
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.status === 200) {
|
|
||||||
console.log(`✅ ${url} is valid (200 OK)`);
|
|
||||||
return null;
|
|
||||||
} else if (response.status >= 300 && response.status < 400) {
|
|
||||||
// Handle redirects
|
|
||||||
const newLocation = response.headers.location;
|
|
||||||
if (newLocation) {
|
|
||||||
console.log(`🔄 ${url} redirects to ${newLocation}`);
|
|
||||||
|
|
||||||
let fullRedirectUrl = newLocation;
|
|
||||||
if (!newLocation.startsWith('http')) {
|
|
||||||
const baseUrl = new URL(url);
|
|
||||||
fullRedirectUrl = new URL(newLocation, baseUrl.origin).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the new domain
|
|
||||||
const newDomain = getDomain(fullRedirectUrl);
|
|
||||||
|
|
||||||
// Check if original URL had a trailing slash
|
|
||||||
const needsTrailingSlash = hasTrailingSlash(url);
|
const needsTrailingSlash = hasTrailingSlash(url);
|
||||||
|
const finalUrlForUpdate = newDomain + (needsTrailingSlash ? '/' : '');
|
||||||
// Create new URL: new domain + trailing slash if the original had one
|
console.log(`🔄 ${url} redirects to ${fullRedirectUrl}`);
|
||||||
let finalUrl = newDomain;
|
console.log(
|
||||||
if (needsTrailingSlash) {
|
`Will update to: ${finalUrlForUpdate} (preserved trailing slash: ${needsTrailingSlash})`
|
||||||
finalUrl += '/';
|
);
|
||||||
}
|
return finalUrlForUpdate;
|
||||||
|
|
||||||
console.log(`Will update to: ${finalUrl} (preserved trailing slash: ${needsTrailingSlash})`);
|
|
||||||
return finalUrl;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log(`⚠️ ${url} returned status ${response.status}`);
|
|
||||||
}
|
}
|
||||||
} catch (getError) {
|
}
|
||||||
if (getError.response) {
|
|
||||||
console.log(`⚠️ ${url} returned status ${getError.response.status}`);
|
console.log(`⚠️ ${url} returned status ${response.status}`);
|
||||||
} else if (getError.code === 'ECONNABORTED') {
|
} catch (error) {
|
||||||
console.log(`⌛ ${url} request timed out`);
|
if (error.response) {
|
||||||
} else if (getError.code === 'ENOTFOUND') {
|
const finalUrl = getFinalUrl(error.response, url);
|
||||||
console.log(`❌ ${url} domain not found`);
|
logVerboseResult(url, error.response, finalUrl);
|
||||||
} else {
|
|
||||||
console.log(`❌ Error checking ${url}: ${getError.message}`);
|
// If the request resolves to a different origin even with a non-2xx status,
|
||||||
|
// use that as an update signal. This keeps existing behavior intact while
|
||||||
|
// allowing sites that block HEAD/GET with 403 but still resolve elsewhere.
|
||||||
|
if (shouldUpdateFromFinalUrl(url, finalUrl)) {
|
||||||
|
const updatedUrl = normalizeOrigin(finalUrl) + (hasTrailingSlash(url) ? '/' : '');
|
||||||
|
console.log(`🔄 ${url} resolved to ${finalUrl}`);
|
||||||
|
console.log(
|
||||||
|
`Will update to: ${updatedUrl} (preserved trailing slash: ${hasTrailingSlash(url)})`
|
||||||
|
);
|
||||||
|
return updatedUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`⚠️ ${url} returned status ${error.response.status}`);
|
||||||
|
} else if (error.code === 'ECONNABORTED') {
|
||||||
|
console.log(`⌛ ${url} request timed out`);
|
||||||
|
} else if (error.code === 'ENOTFOUND') {
|
||||||
|
console.log(`❌ ${url} domain not found`);
|
||||||
|
} else {
|
||||||
|
console.log(`❌ Error checking ${url}: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,21 +27,27 @@ jobs:
|
|||||||
|
|
||||||
- name: Run URL checker
|
- name: Run URL checker
|
||||||
id: url_checker
|
id: url_checker
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# Run the URL checker and save output
|
set -o pipefail
|
||||||
node .github/scripts/url-checker.js > checker_output.log 2>&1
|
# Run the URL checker and show output in the job logs while also saving it
|
||||||
|
node .github/scripts/url-checker.js 2>&1 | tee checker_output.log
|
||||||
|
|
||||||
# Check if there are updated providers
|
# Check if there are updated providers
|
||||||
if grep -q "### UPDATED_PROVIDERS_START ###" checker_output.log; then
|
if grep -q "### UPDATED_PROVIDERS_START ###" checker_output.log; then
|
||||||
echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
|
echo "CHANGES_DETECTED=true" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Extract only the updated provider lines between the markers
|
# Extract only the updated provider lines between the markers
|
||||||
sed -n '/### UPDATED_PROVIDERS_START ###/,/### UPDATED_PROVIDERS_END ###/p' checker_output.log |
|
sed -n '/### UPDATED_PROVIDERS_START ###/,/### UPDATED_PROVIDERS_END ###/p' checker_output.log | \
|
||||||
grep -v "###" > updated_providers.txt
|
grep -v "###" > updated_providers.txt
|
||||||
else
|
else
|
||||||
echo "CHANGES_DETECTED=false" >> $GITHUB_ENV
|
echo "CHANGES_DETECTED=false" >> "$GITHUB_ENV"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "--- checker_output.log ---"
|
||||||
|
cat checker_output.log
|
||||||
|
echo "--- end checker_output.log ---"
|
||||||
|
|
||||||
- name: Commit changes if any
|
- name: Commit changes if any
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name "GitHub Actions"
|
git config --global user.name "GitHub Actions"
|
||||||
|
|||||||
+4
-4
@@ -33,7 +33,7 @@
|
|||||||
},
|
},
|
||||||
"multi": {
|
"multi": {
|
||||||
"name": "multimovies",
|
"name": "multimovies",
|
||||||
"url": "https://multimovies.autos"
|
"url": "https://multimovies.fyi"
|
||||||
},
|
},
|
||||||
"w4u": {
|
"w4u": {
|
||||||
"name": "world4ufree",
|
"name": "world4ufree",
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
},
|
},
|
||||||
"kat": {
|
"kat": {
|
||||||
"name": "katmovieshd",
|
"name": "katmovieshd",
|
||||||
"url": "https://katmoviehd.pictures"
|
"url": "https://new1.katmoviehd.cymru"
|
||||||
},
|
},
|
||||||
"dc": {
|
"dc": {
|
||||||
"name": "dramacool",
|
"name": "dramacool",
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
},
|
},
|
||||||
"4khdhub": {
|
"4khdhub": {
|
||||||
"name": "4khdhub",
|
"name": "4khdhub",
|
||||||
"url": "https://4khdhub.dad"
|
"url": "https://4khdhub.link"
|
||||||
},
|
},
|
||||||
"moviezwap": {
|
"moviezwap": {
|
||||||
"name": "moviezwap",
|
"name": "moviezwap",
|
||||||
@@ -185,6 +185,6 @@
|
|||||||
},
|
},
|
||||||
"1cinevood": {
|
"1cinevood": {
|
||||||
"name": "cinewood",
|
"name": "cinewood",
|
||||||
"url": "https://proxy01.cvproxy.workers.dev"
|
"url": "https://1cinevood.in"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user