eğer ki proje yapıyorsan bu koddan ilerle node.js ortamında çalıştırabilirsin
'use strict';
const axios = require('axios').default;
const { URL } = require('url');
class RapidgatorHost {
constructor() {
this.alias = ["rg.to"];
this.autoDeleteAccount = true;
this.useAPI = false;
}
async login(username, password) {
try {
const loginUrl = 'https://rapidgator.net/auth/login';
const response = await axios.post(loginUrl, {
"LoginForm[email]": username,
"LoginForm[password]": password,
"LoginForm[rememberMe]": 1
}, { withCredentials: true });
const cookies = response.headers['set-cookie'];
if (!cookies) {
throw new Error('Login failed: No cookies returned');
}
return cookies.join('; ');
} catch (error) {
throw new Error(`Login failed: ${error.message}`);
}
}
async check(cookie) {
try {
const profileUrl = 'https://rapidgator.net/profile/index';
const response = await axios.get(profileUrl, {
headers: { Cookie: cookie },
withCredentials: true
});
const isPremium = !/premium">Free</.test(response.data);
const bandwidthMatch = response.data.match(/Bandwidth available<\/td>\s*<td>(.*)<\/td>/);
const bandwidthAvailable = bandwidthMatch ? bandwidthMatch[1].trim() : 'Unknown';
return { isPremium, bandwidthAvailable };
} catch (error) {
throw new Error(`Account check failed: ${error.message}`);
}
}
async download(link, cookie) {
try {
let response = await axios.head(link, { withCredentials: true, headers: { Cookie: cookie } });
if (response.status >= 300 && response.status < 400) {
link = response.headers.location;
}
response = await axios.get(link, {
responseType: 'stream',
headers: { Cookie: cookie },
withCredentials: true
});
return response.data;
} catch (error) {
throw new Error(`Download failed: ${error.message}`);
}
}
}
module.exports = RapidgatorHost;