Skip to content

Bulk asynchronous downloader for multiple file hosts

fix api entrypoint getting override

NTFSvolume73e681caafcf
diff --git a/cyberdrop_dl/managers/real_debrid/api.py b/cyberdrop_dl/managers/real_debrid/api.py
index e27fc0261..7f0c70094 100755
--- a/cyberdrop_dl/managers/real_debrid/api.py
+++ b/cyberdrop_dl/managers/real_debrid/api.py
@@ -39,7 +39,7 @@ class RealDebridApi:
self._session = Session()
self._last_request_time = 0
self._convert_special_types = convert_special_types
- self.auth = OAuth(self)
+ #self.auth = OAuth(self)
self.system = System(self)
self.user = User(self)
self.unrestrict = Unrestrict(self)
@@ -52,7 +52,7 @@ class RealDebridApi:
self.update_token(api_token)
def get(self, path: str, **query_params):
- response = self._session.get(self.API_ENTRYPOINT / path , params= query_params)
+ response = self._session.get(url = self.API_ENTRYPOINT / path, params= query_params)
return self.handle_response(response)
def post(self, path: str, **data):
@@ -105,7 +105,7 @@ class OAuth:
def get_devide_code(self, client_id: str, new_credentials:bool=False) -> dict:
"""Get authentication data"""
- JSONResp = self.api.get('/device/code', client_id= client_id, new_credentials=new_credentials)
+ JSONResp = self.api.get('device/code', client_id= client_id, new_credentials=new_credentials)
if self.api._convert_special_types:
JSONResp['expires_in'] = timedelta(seconds=JSONResp['expires_in'])
JSONResp['verification_url'] = URL(JSONResp['verification_url'])
@@ -113,11 +113,11 @@ class OAuth:
def get_credentials(self, client_id: str, device_code: str):
"""Verify authentication data and get credentials"""
- return self.api.get('/device/credentials', client_id = client_id, code=device_code)
+ return self.api.get('device/credentials', client_id = client_id, code=device_code)
def get_token(self, client_id: str, client_secret: str, device_code: str):
"""Get token from credentials"""
- JSONResp = self.api.post('/token', client_id= client_id, client_secret=client_secret, code=device_code, grant_type = self.grant_type)
+ JSONResp = self.api.post('token', client_id= client_id, client_secret=client_secret, code=device_code, grant_type = self.grant_type)
if self.api._convert_special_types:
JSONResp['expires_in'] = timedelta(seconds=JSONResp['expires_in'])
self.api.update_token(JSONResp['access_token'])
@@ -137,18 +137,18 @@ class System:
def disable_token(self) -> None:
'''Disable current access token, returns 204 HTTP code'''
- return self.api.get('/disable_access_token')
+ return self.api.get('disable_access_token')
def time(self):
'''Get server time. This request does not require authentication'''
- date_str = self.api.get('/time')
+ date_str = self.api.get('time')
if self.api._convert_special_types:
return datetime.strptime(date_str, DATE_FORMAT)
return date_str
def iso_time(self):
'''Get server time as ISO (with timezone). This request does not require authentication'''
- date_str = self.api.get('/time/iso')
+ date_str = self.api.get('time/iso')
if self.api._convert_special_types:
return datetime.strptime(date_str, DATE_ISO_FORMAT)
return date_str
@@ -159,7 +159,7 @@ class User:
def get(self) -> dict:
'''Returns information about the current user'''
- JSONResp = self.api.get('/user')
+ JSONResp = self.api.get('user')
if self.api._convert_special_types:
JSONResp['avatar'] = URL(JSONResp['avatar'])
JSONResp['premium'] = timedelta(seconds=JSONResp['avatar'])
@@ -173,23 +173,23 @@ class Unrestrict:
def check(self, link: URL, password: Optional[str] =None):
"""Check if a file is downloadable on the concerned hoster. This request does not require authentication"""
- return self.api.post('/unrestrict/check', link=link, password=password)
+ return self.api.post('unrestrict/check', link=link, password=password)
def link(self, link: URL, password: Optional[str] = None, remote: bool=None) -> dict:
"""Unrestrict a hoster link and get a new unrestricted link"""
- return self.api.post('/unrestrict/link', link=link, password=password, remote=remote)
+ return self.api.post('unrestrict/link', link=link, password=password, remote=remote)
def folder(self, link: URL) -> list:
"""Unrestrict a hoster folder link and get individual links, returns an empty array if no links found"""
- return self.api.post('/unrestrict/folder', link=link)
+ return self.api.post('unrestrict/folder', link=link)
def container_file(self, filepath: Path) -> dict:
"""Decrypt a container file (RSDF, CCF, CCF3, DLC)"""
- return self.api.put('/unrestrict/containerFile', filepath=filepath)
+ return self.api.put('unrestrict/containerFile', filepath=filepath)
def container_link(self, link: URL) -> dict:
"""Decrypt a container file from a link"""
- return self.api.post('/unrestrict/containerLink', link=link)
+ return self.api.post('unrestrict/containerLink', link=link)
class Traffic:
def __init__(self, api: RealDebridApi):
@@ -197,11 +197,11 @@ class Traffic:
def get(self):
"""Get traffic informations for limited hosters (limits, current usage, extra packages)"""
- return self.api.get('/traffic')
+ return self.api.get('traffic')
def details(self, start: date = None, end: date=None):
"""Get traffic details on each hoster used during a defined period"""
- JSONResp = self.api.get('/traffic/details', start=start, end=end)
+ JSONResp = self.api.get('traffic/details', start=start, end=end)
if self.api._convert_special_types:
JSONResp = {datetime.strptime(key, "%Y-%m-%d").date(): value
for key, value in JSONResp.items()}
@@ -225,7 +225,7 @@ class Downloads:
def get(self, offset: int =None, page: int=None, limit:int=None ):
"""Get user downloads list"""
- JSONResp = self.api.get('/downloads', offset=offset, page=page, limit=limit)
+ JSONResp = self.api.get('downloads', offset=offset, page=page, limit=limit)
if self.api._convert_special_types:
for download in JSONResp:
download['generated'] = datetime.strptime(download['generated'], DATE_JSON_FORMAT)
@@ -242,7 +242,7 @@ class Torrents:
def get(self, offset:int=None, page:int=None, limit:int=None, filter: str=None ):
"""Get user torrents list"""
- JSONResp: list[dict] = self.api.get('/torrents', offset=offset, page=page, limit=limit, filter=filter)
+ JSONResp: list[dict] = self.api.get('torrents', offset=offset, page=page, limit=limit, filter=filter)
if self.api._convert_special_types:
for torrent in JSONResp:
torrent['added'] = datetime.strptime(torrent['added'], DATE_JSON_FORMAT)
@@ -266,25 +266,25 @@ class Torrents:
"""
Get list of instantly available file IDs by hoster, {hash} is the SHA1 of the torrent.
You can test multiple hashes adding multiple /{hash} at the end of the request"""
- return self.api.get('/torrents/instantAvailability/' + "/".join(*hash))
+ return self.api.get('torrents/instantAvailability/' + "/".join(*hash))
def active_count(self):
"""Get currently active torrents number and the current maximum limit"""
- return self.api.get('/torrents/activeCount')
+ return self.api.get('torrents/activeCount')
def available_hosts(self):
"""Get available hosts to upload the torrent to"""
- return self.api.get('/torrents/availableHosts')
+ return self.api.get('torrents/availableHosts')
def add_file(self, filepath:Path, host:Optional[str]=None):
"""Add a torrent file to download, return a 201 HTTP code"""
- return self.api.put('/torrents/addTorrent', filepath=filepath, host=host)
+ return self.api.put('torrents/addTorrent', filepath=filepath, host=host)
def add_magnet(self, magnet:str, host:Optional[str]=None):
"""Add a magnet link to download, returns a 201 HTTP code"""
if MAGNET_PREFIX not in magnet:
magnet = f"{MAGNET_PREFIX}{magnet}"
- return self.api.post('/torrents/addMagnet', magnet=magnet, host=host)
+ return self.api.post('torrents/addMagnet', magnet=magnet, host=host)
def select_files(self, id:str, *files:str):
"""Select files of a torrent to start it, returns 204 HTTP code
@@ -302,11 +302,11 @@ class Hosts:
def get(self):
"""Get supported hosts. This request does not require authentication"""
- return self.api.get('/hosts')
+ return self.api.get('hosts')
def status(self):
"""Get status of supported hosters or not and their status on competitors"""
- JSONResp: dict[dict] = self.api.get('/hosts/status')
+ JSONResp: dict[dict] = self.api.get('hosts/status')
if self.api._convert_special_types:
for host in JSONResp:
host['check_time'] = datetime.strptime(host['check_time'], DATE_JSON_FORMAT)
@@ -318,15 +318,15 @@ class Hosts:
def regex(self) -> list:
"""Get all supported links Regex, useful to find supported links inside a document. This request does not require authentication"""
- return self.api.get('/hosts/regex')
+ return self.api.get('hosts/regex')
def regex_folder(self) -> list:
"""Get all supported folder Regex, useful to find supported links inside a document. This request does not require authentication"""
- return self.api.get('/hosts/regexFolder')
+ return self.api.get('hosts/regexFolder')
def domains(self):
"""Get all hoster domains supported on the service. This request does not require authentication"""
- return self.api.get('/hosts/domains')
+ return self.api.get('hosts/domains')
class Settings:
def __init__(self, api: RealDebridApi):
@@ -334,25 +334,25 @@ class Settings:
def get(self):
"""Get current user settings with possible values to update"""
- return self.api.get('/settings')
+ return self.api.get('settings')
def update(self, setting_name: str, setting_value:str):
"""Update a user setting, returns 204 HTTP code"""
- return self.api.post('/settings/update', setting_name=setting_name, setting_value=setting_value)
+ return self.api.post('settings/update', setting_name=setting_name, setting_value=setting_value)
def convert_points(self):
"""Convert fidelity points, returns 204 HTTP code"""
- return self.api.post('/settings/convertPoints')
+ return self.api.post('settings/convertPoints')
def change_password(self):
"""Send the verification email to change the password, returns 204 HTTP code"""
- return self.api.post('/settings/changePassword')
+ return self.api.post('settings/changePassword')
def avatar_file(self, filepath:Path):
"""Upload a new user avatar image, returns 204 HTTP code"""
- return self.api.put('/settings/avatarFile', filepath=filepath)
+ return self.api.put('settings/avatarFile', filepath=filepath)
def avatar_delete(self):
"""Reset user avatar image to default, returns 204 HTTP code"""
- return self.api.delete('/settings/avatarDelete')
+ return self.api.delete('settings/avatarDelete')