/// <summary> /// Fires a connection request to the api. /// </summary> /// <param name="email">Email of the User</param> /// <param name="password">Password of the User</param> /// <returns>Return if the Connection was succesfull</returns> public async Task <bool> Connect(string email, string password) { //Calculating the Login and Device secret _loginSecret = Utils.GetSecret(email, password, Utils.ServerDomain); _deviceSecret = Utils.GetSecret(email, password, Utils.DeviceDomain); //Creating the query for the connection request var connectQueryUrl = $"/my/connect?email={HttpUtility.UrlEncode(email)}&appkey={HttpUtility.UrlEncode(Utils.AppKey)}"; //Calling the query var response = await JDownloaderApiHandler.CallServer <LoginObject>(connectQueryUrl, _loginSecret); //If the response is null the connection was not successfull if (response == null) { return(false); } //Else we are saving the response which contains the SessionToken, RegainToken and the RequestId _loginObject = response; _loginObject.Email = email; _loginObject.Password = password; _loginObject.ServerEncryptionToken = Utils.UpdateEncryptionToken(_loginSecret, _loginObject.SessionToken); _loginObject.DeviceEncryptionToken = Utils.UpdateEncryptionToken(_deviceSecret, _loginObject.SessionToken); IsConnected = true; return(true); }
/// <summary> /// Lists all Devices which are currently connected to your my.jdownloader.org account. /// </summary> /// <returns>Returns a list of your currently connected devices.</returns> public async Task <List <DeviceObject>?> GetDevices() { if (_loginObject is null) { return(new List <DeviceObject>()); } var devices = new List <DeviceObject>(); var query = $"/my/listdevices?sessiontoken={HttpUtility.UrlEncode(_loginObject.SessionToken)}"; var response = await JDownloaderApiHandler.CallServer <DeviceJsonReturnObject>(query, _loginObject.ServerEncryptionToken); if (response == default) { return(devices); } devices = response.Devices; return(devices); }
/// <summary> /// Disconnects the your client from the api /// </summary> /// <returns>True if successfull else false</returns> public async Task <bool> Disconnect() { if (_loginObject is null) { return(false); } var query = $"/my/disconnect?sessiontoken={HttpUtility.UrlEncode(_loginObject.SessionToken)}"; var response = await JDownloaderApiHandler.CallServer <object>(query, _loginObject.ServerEncryptionToken); if (response == null) { return(false); } IsConnected = false; _loginObject = null; return(true); }
/// <summary> /// Tries to reconnect your client to the api. /// </summary> /// <returns>True if successfull else false</returns> public async Task <bool> Reconnect() { if (_loginObject is null) { return(false); } var query = $"/my/reconnect?appkey{HttpUtility.UrlEncode(Utils.AppKey)}&sessiontoken={HttpUtility.UrlEncode(_loginObject.SessionToken)}®aintoken={HttpUtility.UrlEncode(_loginObject.RegainToken)}"; var response = await JDownloaderApiHandler.CallServer <LoginObject>(query, _loginObject.ServerEncryptionToken); if (response == null) { return(false); } _loginObject = response; _loginObject.ServerEncryptionToken = Utils.UpdateEncryptionToken(_loginSecret, _loginObject.SessionToken); _loginObject.DeviceEncryptionToken = Utils.UpdateEncryptionToken(_deviceSecret, _loginObject.SessionToken); IsConnected = true; return(IsConnected); }
internal DeviceHandler(Device device, JDownloaderApiHandler apiHandler, LoginObject loginObject, bool useJdownloaderApi = false) { _device = device; _apiHandler = apiHandler; _loginObject = loginObject; Accounts = new Accounts(_apiHandler, _device); AccountsV2 = new AccountsV2(_apiHandler, _device); Captcha = new Captcha(_apiHandler, _device); CaptchaForward = new CaptchaForward(_apiHandler, _device); Config = new Config(_apiHandler, _device); Dialogs = new Dialogs(_apiHandler, _device); DownloadController = new DownloadController(_apiHandler, _device); DownloadsV2 = new DownloadsV2(_apiHandler, _device); Extensions = new Extensions(_apiHandler, _device); Extraction = new Extraction(_apiHandler, _device); LinkCrawler = new LinkCrawler(_apiHandler, _device); LinkgrabberV2 = new LinkGrabberV2(_apiHandler, _device); Update = new Update(_apiHandler, _device); Jd = new Jd(_apiHandler, _device); System = new Namespaces.System(_apiHandler, _device); DirectConnect(useJdownloaderApi); }
internal AccountsV2(JDownloaderApiHandler apiHandler, DeviceObject device) { ApiHandler = apiHandler; Device = device; }
internal Dialogs(JDownloaderApiHandler apiHandler, Device device) { ApiHandler = apiHandler; Device = device; }
internal LinkCrawler(JDownloaderApiHandler apiHandler, DeviceObject device) { ApiHandler = apiHandler; Device = device; }
internal System(JDownloaderApiHandler apiHandler, DeviceObject device) { ApiHandler = apiHandler; Device = device; }
internal LinkGrabberV2(JDownloaderApiHandler apiHandler, DeviceObject device) { ApiHandler = apiHandler; Device = device; }
internal Accounts(JDownloaderApiHandler apiHandler, Device device) { ApiHandler = apiHandler; Device = device; }
internal Config(JDownloaderApiHandler apiHandler, DeviceObject device) { ApiHandler = apiHandler; Device = device; }
internal DownloadController(JDownloaderApiHandler apiHandler, Device device) { ApiHandler = apiHandler; Device = device; }
internal Update(JDownloaderApiHandler apiHandler, DeviceObject device) { ApiHandler = apiHandler; Device = device; }
internal Captcha(JDownloaderApiHandler apiHandler, Device device) { ApiHandler = apiHandler; Device = device; }
internal CaptchaForward(JDownloaderApiHandler apiHandler, DeviceObject device) { ApiHandler = apiHandler; Device = device; }
internal Extensions(JDownloaderApiHandler apiHandler, Device device) { ApiHandler = apiHandler; Device = device; }
internal Extraction(JDownloaderApiHandler apiHandler, DeviceObject device) { ApiHandler = apiHandler; Device = device; }
internal DownloadsV2(JDownloaderApiHandler apiHandler, Device device) { ApiHandler = apiHandler; Device = device; }