• 19-03-2024, 19:56:13
    #1
    'use strict';function _typeof(obj){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.pro totype?"symbol":typeof obj},_typeof(obj)}var url=require("url"),Host=module.exports;Host.alias=["rg.to"],Host.autoDeleteAccount=!0;var useAPI=!1;Host.login=function(username,password,ca llback){var j=rp.jar(),loginUrl="https://rapidgator.net/auth/login";rp({uri:loginUrl,method:"POST",form:{"Login Form[email]":username,"LoginForm[password]"assword,"LoginForm[rememberMe]":1},jar:j}).then(function(body){var cookie=j.getCookieString(loginUrl);return /Invalid auth code/.test(body)?callback(new Error("Invalid auth code")):void callback(null,cookie)}).catch(function(err){callba ck(err)})},Host.check=function(cookie,callback){rp =rp.defaults({headers:{cookie:cookie+";lang=en"}}) ,rp("https://rapidgator.net/profile/index").then(function(body){if(/premium">Free</.test(body))return callback(new Error("Account free"));var t1=body.lastIndexOf("Bandwith available</td>"),t2=body.lastIndexOf("<td>Number of files</td>"),str=body.substring(t1,t2),regex=/<td>n(.*)</br/gm,match=regex.exec(str);return match?callback(null,!0,"Bandwith available: "+match[1].trim()):callback(new Error("Invalid account"))}).catch(function(err){callback(err)})}, Host.download=function(link,cookie,callback){var j=request.jar(),options={uri:link,method:"HEAD",fo llowRedirect:!0};request(options,function(err,res) {return err?callback(err):503===res.statusCode?callback(ne w Error("Account limit")):400<=res.statusCode?callback(new Error("Link dead")):void(""!==this.uri.href&&(link=this.uri.hr ef),options.uri=link,options.headers={Cookie:cooki e},options.followRedirect=!1,options.method="GET", options.jar=j,request(options,function(err,res,bod y){if(503===res.statusCode)return callback(new Error("Account limit"));if(400<=res.statusCode)return callback(new Error("Link dead"));var file_cookie=j.getCookieString(options.uri);if(res. headers&&"undefined"!=typeof res.headers.location)return callback(null,{cookie:file_cookie,download:res.hea ders.location});var urlParse=url.parse(link),url_antifrodDownloadLog=" https://rapidgator.net/antifrod/SaveDownloadLog";url_antifrodDownloadLog=url_antif rodDownloadLog.replace("http:",urlParse.protocol); var regex=/var fid =(.*);/gm,match=regex.exec(body);if(!match)return callback(new Error("Link dead"));var fid=match[1].trim(),regex2=/premium_download_link = '(.*)';/gm,premium_download_link="",match2=regex2.exec(bod y);if(match2)premium_download_link=match2[1].trim();else return callback(new Error("Link dead"));return""===premium_download_link?callback( new Error("Account limit")):void(options.uri=url_antifrodDownloadLog, options.method="POST",options.form={fid:fid},reque st(options,function(err){return err?callback(err):callback(null,{cookie:file_cooki e,downloadremium_download_link})}))}))})};var API;
  • 19-03-2024, 19:59:20
    #2
    Düzenlemeyi kast ediyorsanız https://beautifier.io/ gibi siteler kullanabilirsiniz. BKZ:
    'use strict';
    
    function _typeof(obj) {
        return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
            return typeof obj
        } : function(obj) {
            return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.pro totype ? "symbol" : typeof obj
        }, _typeof(obj)
    }
    var url = require("url"),
        Host = module.exports;
    Host.alias = ["rg.to"], Host.autoDeleteAccount = !0;
    var useAPI = !1;
    Host.login = function(username, password, ca llback) {
        var j = rp.jar(),
            loginUrl = "https://rapidgator.net/auth/login";
        rp({
            uri: loginUrl,
            method: "POST",
            form: {
                "Login Form[email]": username,
                "LoginForm[password]"
                assword,
                "LoginForm[rememberMe]": 1
            },
            jar: j
        }).then(function(body) {
            var cookie = j.getCookieString(loginUrl);
            return /Invalid auth code/.test(body) ? callback(new Error("Invalid auth code")) : void callback(null, cookie)
        }).catch(function(err) {
            callba ck(err)
        })
    }, Host.check = function(cookie, callback) {
        rp = rp.defaults({
            headers: {
                cookie: cookie + ";lang=en"
            }
        }), rp("https://rapidgator.net/profile/index").then(function(body) {
            if (/premium">Free</.test(body)) return callback(new Error("Account free"));
            var t1 = body.lastIndexOf("Bandwith available</td>"),
                t2 = body.lastIndexOf("<td>Number of files</td>"),
                str = body.substring(t1, t2),
                regex = /<td>n(.*)</br / gm,
                match = regex.exec(str);
            return match ? callback(null, !0, "Bandwith available: " + match[1].trim()) : callback(new Error("Invalid account"))
        }).catch(function(err) {
            callback(err)
        })
    }, Host.download = function(link, cookie, callback) {
        var j = request.jar(),
            options = {
                uri: link,
                method: "HEAD",
                fo llowRedirect: !0
            };
        request(options, function(err, res) {
            return err ? callback(err) : 503 === res.statusCode ? callback(ne w Error("Account limit")) : 400 <= res.statusCode ? callback(new Error("Link dead")) : void("" !== this.uri.href && (link = this.uri.hr ef), options.uri = link, options.headers = {
                Cookie: cooki e
            }, options.followRedirect = !1, options.method = "GET", options.jar = j, request(options, function(err, res, bod y) {
                if (503 === res.statusCode) return callback(new Error("Account limit"));
                if (400 <= res.statusCode) return callback(new Error("Link dead"));
                var file_cookie = j.getCookieString(options.uri);
                if (res.headers && "undefined" != typeof res.headers.location) return callback(null, {
                    cookie: file_cookie,
                    download: res.hea ders.location
                });
                var urlParse = url.parse(link),
                    url_antifrodDownloadLog = " https://rapidgator.net/antifrod/SaveDownloadLog";
                url_antifrodDownloadLog = url_antif rodDownloadLog.replace("http:", urlParse.protocol);
                var regex = /var fid =(.*);/gm,
                    match = regex.exec(body);
                if (!match) return callback(new Error("Link dead"));
                var fid = match[1].trim(),
                    regex2 = /premium_download_link = '(.*)';/gm,
                    premium_download_link = "",
                    match2 = regex2.exec(bod y);
                if (match2) premium_download_link = match2[1].trim();
                else return callback(new Error("Link dead"));
                return "" === premium_download_link ? callback(new Error("Account limit")) : void(options.uri = url_antifrodDownloadLog, options.method = "POST", options.form = {
                    fid: fid
                }, reque st(options, function(err) {
                    return err ? callback(err) : callback(null, {
                        cookie: file_cooki e,
                        downloadremium_download_link
                    })
                }))
            }))
        })
    };
    var API;
  • 19-03-2024, 19:59:27
    #3
    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;
  • 19-03-2024, 20:07:23
    #4
    'use strict';
    
    // Axios kütüphanesini import ediyoruz.
    const axios = require('axios').default;
    // URL sınıfını kullanıyoruz.
    const { URL } = require('url');
    
    // RapidgatorHost sınıfını tanımlıyoruz.
    class RapidgatorHost {
      constructor() {
        // Rapidgator'ün alternatif domain adlarını alias içinde saklıyoruz.
        this.alias = ["rg.to"];
        // Otomatik hesap silme özelliğini true olarak belirliyoruz.
        this.autoDeleteAccount = true;
        // API kullanımını false olarak belirliyoruz.
        this.useAPI = false;
      }
    
      // Kullanıcı girişi işlevini tanımlıyoruz.
      async login(username, password) {
        try {
          // Giriş URL'sini belirliyoruz.
          const loginUrl = 'https://rapidgator.net/auth/login';
          // Axios ile giriş yapma isteği gönderiyoruz.
          const response = await axios.post(loginUrl, {
            "LoginForm[email]": username,
            "LoginForm[password]": password,
            "LoginForm[rememberMe]": 1
          }, { withCredentials: true });
    
          // Yanıtta dönen çerezleri alıyoruz.
          const cookies = response.headers['set-cookie'];
          // Eğer çerez yoksa bir hata fırlatıyoruz.
          if (!cookies) {
            throw new Error('Login failed: No cookies returned');
          }
    
          // Çerezleri birleştirerek döndürüyoruz.
          return cookies.join('; ');
        } catch (error) {
          // Hata durumunda bir hata fırlatıyoruz.
          throw new Error(`Login failed: ${error.message}`);
        }
      }
    
      // Hesap durumu kontrol işlevini tanımlıyoruz.
      async check(cookie) {
        try {
          // Profil URL'sini belirliyoruz.
          const profileUrl = 'https://rapidgator.net/profile/index';
          // Axios ile hesap kontrolü isteği gönderiyoruz.
          const response = await axios.get(profileUrl, {
            headers: { Cookie: cookie },
            withCredentials: true
          });
    
          // Yanıtı analiz ederek kullanıcının premium olup olmadığını ve bant genişliğini alıyoruz.
          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';
    
          // Bilgileri döndürüyoruz.
          return { isPremium, bandwidthAvailable };
        } catch (error) {
          // Hata durumunda bir hata fırlatıyoruz.
          throw new Error(`Account check failed: ${error.message}`);
        }
      }
    
      // Dosya indirme işlevini tanımlıyoruz.
      async download(link, cookie) {
        try {
          // İndirme bağlantısını HEAD isteği ile kontrol ediyoruz.
          let response = await axios.head(link, { withCredentials: true, headers: { Cookie: cookie } });
    
          // Eğer yönlendirme varsa yeni bağlantıyı alıyoruz.
          if (response.status >= 300 && response.status < 400) {
            link = response.headers.location;
          }
    
          // Dosyayı indiriyoruz.
          response = await axios.get(link, {
            responseType: 'stream',
            headers: { Cookie: cookie },
            withCredentials: true
          });
    
          // İndirilen dosyanın verisini döndürüyoruz.
          return response.data;
        } catch (error) {
          // Hata durumunda bir hata fırlatıyoruz.
          throw new Error(`Download failed: ${error.message}`);
        }
      }
    }
    
    // RapidgatorHost sınıfını dışarıya aktarıyoruz.
    module.exports = RapidgatorHost;