@@ -125,6 +125,7 @@ def update_available(self):
125
125
resp = self .is_update_available ()
126
126
return resp
127
127
128
+
128
129
class DownloadController :
129
130
"""
130
131
Class that represents the download-controller of a Device
@@ -203,15 +204,15 @@ def clear_list(self):
203
204
resp = self .device .action (self .url + "/clearList" , http_action = "POST" )
204
205
return resp
205
206
206
- def move_to_downloadlist (self , links_ids , packages_ids ):
207
+ def move_to_downloadlist (self , link_ids , package_ids ):
207
208
"""
208
209
Moves packages and/or links to download list.
209
210
210
- :param packages: Packages UUID.
211
+ :param package_ids: Package UUID's .
211
212
:type: list of strings.
212
- :param links: Links UUID.
213
+ :param link_ids: Link UUID's .
213
214
"""
214
- params = [links_ids , packages_ids ]
215
+ params = [link_ids , package_ids ]
215
216
resp = self .device .action (self .url + "/moveToDownloadlist" , params )
216
217
return resp
217
218
@@ -280,15 +281,15 @@ def cleanup(self,
280
281
action ,
281
282
mode ,
282
283
selection_type ,
283
- links_ids = [],
284
- packages_ids = []):
284
+ link_ids = [],
285
+ package_ids = []):
285
286
"""
286
287
Clean packages and/or links of the linkgrabber list.
287
- Requires at least a packages_ids or links_ids list, or both.
288
+ Requires at least a package_ids or link_ids list, or both.
288
289
289
- :param packages_ids: Packages UUID.
290
+ :param package_ids: Package UUID's .
290
291
:type: list of strings.
291
- :param links_ids: Links UUID.
292
+ :param link_ids: link UUID's .
292
293
:type: list of strings
293
294
:param action: Action to be done. Actions: DELETE_ALL, DELETE_DISABLED, DELETE_FAILED, DELETE_FINISHED, DELETE_OFFLINE, DELETE_DUPE, DELETE_MODE
294
295
:type: str:
@@ -297,7 +298,7 @@ def cleanup(self,
297
298
:param selection_type: Type of selection to use. Types: SELECTED, UNSELECTED, ALL, NONE
298
299
:type: str:
299
300
"""
300
- params = [links_ids , packages_ids ]
301
+ params = [link_ids , package_ids ]
301
302
params += [action , mode , selection_type ]
302
303
resp = self .device .action (self .url + "/cleanup" , params )
303
304
return resp
@@ -316,33 +317,33 @@ def add_container(self, type_, content):
316
317
resp = self .device .action (self .url + "/addContainer" , params )
317
318
return resp
318
319
319
- def get_download_urls (self , links_ids , packages_ids , url_display_type ):
320
+ def get_download_urls (self , link_ids , package_ids , url_display_type ):
320
321
"""
321
322
Gets download urls from Linkgrabber.
322
323
323
- :param packages_ids: Packages UUID.
324
+ :param package_ids: Package UUID's .
324
325
:type: List of strings.
325
- :param Links_ids: Links UUID.
326
+ :param link_ids: link UUID's .
326
327
:type: List of strings
327
328
:param url_display_type: No clue. Not documented
328
329
:type: Dictionary
329
330
"""
330
- params = [packages_ids , links_ids , url_display_type ]
331
+ params = [package_ids , link_ids , url_display_type ]
331
332
resp = self .device .action (self .url + "/getDownloadUrls" , params )
332
333
return resp
333
334
334
- def set_priority (self , priority , links_ids , packages_ids ):
335
+ def set_priority (self , priority , link_ids , package_ids ):
335
336
"""
336
337
Sets the priority of links or packages.
337
338
338
- :param packages_ids: Packages UUID.
339
+ :param package_ids: Package UUID's .
339
340
:type: list of strings.
340
- :param links_ids: Links UUID.
341
+ :param link_ids: link UUID's .
341
342
:type: list of strings
342
343
:param priority: Priority to set. Priorities: HIGHEST, HIGHER, HIGH, DEFAULT, LOWER;
343
344
:type: str:
344
345
"""
345
- params = [priority , links_ids , packages_ids ]
346
+ params = [priority , link_ids , package_ids ]
346
347
resp = self .device .action (self .url + "/setPriority" , params )
347
348
return resp
348
349
@@ -488,6 +489,7 @@ def add_variant_copy(self):
488
489
"""
489
490
pass
490
491
492
+
491
493
class Toolbar :
492
494
"""
493
495
Class that represents the toolbar of a Device
@@ -518,6 +520,7 @@ def disable_downloadSpeedLimit(self):
518
520
if self .limit_enabled :
519
521
self .device .action (self .url + "/toggleDownloadSpeedLimit" )
520
522
523
+
521
524
class Downloads :
522
525
"""
523
526
Class that represents the downloads list of a Device
@@ -581,15 +584,15 @@ def cleanup(self,
581
584
action ,
582
585
mode ,
583
586
selection_type ,
584
- links_ids = [],
585
- packages_ids = []):
587
+ link_ids = [],
588
+ package_ids = []):
586
589
"""
587
590
Clean packages and/or links of the linkgrabber list.
588
- Requires at least a packages_ids or links_ids list, or both.
591
+ Requires at least a package_ids or link_ids list, or both.
589
592
590
- :param packages_ids: Packages UUID.
593
+ :param package_ids: Package UUID's .
591
594
:type: list of strings.
592
- :param links_ids: Links UUID.
595
+ :param link_ids: link UUID's .
593
596
:type: list of strings
594
597
:param action: Action to be done. Actions: DELETE_ALL, DELETE_DISABLED, DELETE_FAILED, DELETE_FINISHED, DELETE_OFFLINE, DELETE_DUPE, DELETE_MODE
595
598
:type: str:
@@ -598,7 +601,7 @@ def cleanup(self,
598
601
:param selection_type: Type of selection to use. Types: SELECTED, UNSELECTED, ALL, NONE
599
602
:type: str:
600
603
"""
601
- params = [links_ids , packages_ids ]
604
+ params = [link_ids , package_ids ]
602
605
params += [action , mode , selection_type ]
603
606
resp = self .device .action (self .url + "/cleanup" , params )
604
607
return resp
@@ -635,9 +638,9 @@ def __refresh_direct_connections(self):
635
638
response = self .myjd .request_api ("/device/getDirectConnectionInfos" ,
636
639
"POST" , None , self .__action_url ())
637
640
if response is not None \
638
- and 'data' in response \
639
- and 'infos' in response ["data" ] \
640
- and len (response ["data" ]["infos" ])!= 0 :
641
+ and 'data' in response \
642
+ and 'infos' in response ["data" ] \
643
+ and len (response ["data" ]["infos" ]) != 0 :
641
644
self .__update_direct_connections (response ["data" ]["infos" ])
642
645
643
646
def __update_direct_connections (self , direct_info ):
@@ -656,7 +659,7 @@ def __update_direct_connections(self, direct_info):
656
659
tmp .remove (i )
657
660
else :
658
661
direct_info .remove (i ['conn' ])
659
- #We add new connections
662
+ # We add new connections
660
663
for conn in direct_info :
661
664
tmp .append ({'conn' : conn , 'cooldown' : 0 })
662
665
self .__direct_connection_info = tmp
@@ -680,7 +683,7 @@ def action(self, path, params=(), http_action="POST"):
680
683
"""
681
684
action_url = self .__action_url ()
682
685
if not self .__direct_connection_enabled or self .__direct_connection_info is None \
683
- or time .time () < self .__direct_connection_cooldown :
686
+ or time .time () < self .__direct_connection_cooldown :
684
687
# No direct connection available, we use My.JDownloader api.
685
688
response = self .myjd .request_api (path , http_action , params ,
686
689
action_url )
@@ -691,7 +694,7 @@ def action(self, path, params=(), http_action="POST"):
691
694
# My.JDownloader Api worked, lets refresh the direct connections and return
692
695
# the response.
693
696
if self .__direct_connection_enabled \
694
- and time .time () >= self .__direct_connection_cooldown :
697
+ and time .time () >= self .__direct_connection_cooldown :
695
698
self .__refresh_direct_connections ()
696
699
return response ['data' ]
697
700
else :
@@ -724,11 +727,10 @@ def action(self, path, params=(), http_action="POST"):
724
727
if response is None :
725
728
# My.JDownloader Api failed too.
726
729
return False
727
- # My.JDownloader Api worked, lets refresh the direct connections and return
728
- # the response.
730
+ # My.JDownloader Api worked, lets refresh the direct connections and return
731
+ # the response.
729
732
self .__refresh_direct_connections ()
730
733
return response ['data' ]
731
- return False
732
734
733
735
def __action_url (self ):
734
736
return "/t_" + self .myjd .get_session_token () + "_" + self .device_id
@@ -992,14 +994,14 @@ def request_api(self,
992
994
if self .__server_encryption_token is None :
993
995
query += [
994
996
"signature=" \
995
- + str (self .__signature_create (self .__login_secret ,
996
- query [0 ] + "&" .join (query [1 :])))
997
+ + str (self .__signature_create (self .__login_secret ,
998
+ query [0 ] + "&" .join (query [1 :])))
997
999
]
998
1000
else :
999
1001
query += [
1000
1002
"signature=" \
1001
- + str (self .__signature_create (self .__server_encryption_token ,
1002
- query [0 ] + "&" .join (query [1 :])))
1003
+ + str (self .__signature_create (self .__server_encryption_token ,
1004
+ query [0 ] + "&" .join (query [1 :])))
1003
1005
]
1004
1006
query = query [0 ] + "&" .join (query [1 :])
1005
1007
encrypted_response = requests .get (api + query , timeout = 3 )
@@ -1047,9 +1049,9 @@ def request_api(self,
1047
1049
error_msg = json .loads (self .__decrypt (self .__device_encryption_token , encrypted_response .text ))
1048
1050
except json .JSONDecodeError :
1049
1051
raise MYJDException ("Failed to decode response: {}" , encrypted_response .text )
1050
- msg = "\n \t SOURCE: " + error_msg ["src" ]+ "\n \t TYPE: " + \
1051
- error_msg ["type" ]+ "\n ------\n REQUEST_URL: " + \
1052
- api + path
1052
+ msg = "\n \t SOURCE: " + error_msg ["src" ] + "\n \t TYPE: " + \
1053
+ error_msg ["type" ] + "\n ------\n REQUEST_URL: " + \
1054
+ api + path
1053
1055
if http_method == "GET" :
1054
1056
msg += query
1055
1057
msg += "\n "
0 commit comments