JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 24.08.2021, 09:00
kkkira kkkira is offline
JD Fan
 
Join Date: Aug 2009
Posts: 70
Default any working cli tool for linux using the API

Hi, i just learned that there is an api for jd, and i'm wondering if there is any tool (maybe third party) that has basic functionality like checking download status from linux terminal, maybe in python or javascript.... or anything?
My google search didn't get much results...
Reply With Quote
  #2  
Old 24.08.2021, 16:10
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@kkkira: you can find several third party api clients on github, search for "github myjdownloader"
github.com/search?q=myjdownloader
You can also write own clients yourself or own tools based on other clients, see docs
my.jdownloader.org/developers/index.html

In case you need help/got questions, just ask
__________________
JD-Dev & Server-Admin
Reply With Quote
  #3  
Old 24.08.2021, 17:18
kkkira kkkira is offline
JD Fan
 
Join Date: Aug 2009
Posts: 70
Default

Thanks!! how simply, my search terms where a little more complicated lol...
where do i get an api key?
Reply With Quote
  #4  
Old 24.08.2021, 17:26
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

just use your email or github project or anything we can use to contact you in case your client/tool is getting messy
__________________
JD-Dev & Server-Admin
Reply With Quote
  #5  
Old 24.08.2021, 22:42
kkkira kkkira is offline
JD Fan
 
Join Date: Aug 2009
Posts: 70
Default

Here it is a little script using a python fork of the API, I use it with a python shebang for linux, but you can modify that

https://bit.ly/3sHqjy5

feel free to modify and add functionality, just let me know to test
Reply With Quote
  #6  
Old 25.08.2021, 11:58
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@kkkira: thanks for sharing your script
__________________
JD-Dev & Server-Admin
Reply With Quote
  #7  
Old 25.03.2023, 23:00
kkkira kkkira is offline
JD Fan
 
Join Date: Aug 2009
Posts: 70
Default

new version:
Code:
#!/usr/bin/python3

#Jdownloader wrapper V2.0
#necessary 
#pip3 install myjdapi

def main():   
   import myjdapi, datetime, json
   from sys import exit

   import argparse
   parser = argparse.ArgumentParser()

   deb = "dev"
   
   #jdownloader instance
   jd=myjdapi.Myjdapi()
   
   jd.connect("user","pass")
   
   jd.update_devices()
   
   try:
      device=jd.get_device("JDownloader@" + dev) 
   except myjdapi.exception.MYJDDeviceNotFoundException:
      print(json.dumps({"message":"device not found"}));
      exit() 
   
   #downloads
   full_query = device.downloads.query_packages([{
                   "bytesLoaded" : True,
                   "bytesTotal" : True,
                   "comment" : False,
                   "enabled" : True,
                   "eta" : True,
                   "priority" : False,
                   "finished" : True,
                   "running" : True,
                   "speed" : True,
                   "status" : True,
                   "childCount" : True,
                   "hosts" : True,
                   "saveTo" : False,
                   "maxResults" : -1,
                   "startAt" : 0,
                   "statusIconKey" : False,
                   "uuid" : True,
               }])
   
   if len(full_query) == 0 :
      print(json.dumps({"message":"No downloads found!"}));
      exit()
   
   #parsing
   downloads = []
   for download in full_query:
      download_info = {
        "uuid": download["uuid"],
        "name": download["name"],
        "hosts": download["hosts"][0] if "hosts" in download and len(download["hosts"]) > 0 else "",
        "childCount": download.get("childCount", ""),
        "eta": download.get("eta", ""),
        "speed": download.get("speed") / (2**20) if "speed" in download else "",
        "bytesLoaded": download.get("bytesLoaded", "") / 1000000,
        "bytesTotal": download.get("bytesTotal", "") / 1000000,
      }
   
   downloads.append(download_info)

   # print the final JSON structure
   print(json.dumps(downloads))

if __name__ == '__main__':
   main()

Last edited by pspzockerscene; 05.04.2023 at 18:10. Reason: Added CODE tag
Reply With Quote
  #8  
Old 05.04.2023, 17:57
notice notice is offline
JD Supporter
 
Join Date: Mar 2023
Posts: 505
Default

@kkkira: Thanks for the updated version.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 21:01.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.