Git Product home page Git Product logo

my.jdownloader-api-python-library's Introduction

My.Jdownloader-API-Python-Library

This a module for Python 2/3 to interact with My.Jdownloader. This is in a WIP project.You're free to use it following the MIT license and any collaboration is appreciated.

Is this dead?

No, it's true that I don't actively develop it, as in there are still functions not implemented. But if you find something missing, feel free to open an issue and I will take a look asap or even better, if you know how to add it feel free to do it and do a PR and I will merge it asap once I have test it.

Basically I develop it as in on demand kind of thing, if something is broken or something new is needed I take a look at it and try to fix it or add it.

Common Issues

⚠️ Are you having problems adding links? Are your links not getting their correct download folder or similar?

99,99% of the times is not an issue of the library, it is due the JDownloader Packagizer check this closed issue to understand why it happens and how you can make it work: #36

How to use the api?

NEW: Now you can install it using pip from the pypi repo.

pip install myjdapi

Example:

#First of all you have to make an instance of the Myjdapi class and set your APPKey:
import myjdapi

jd=myjdapi.Myjdapi()
jd.set_app_key("EXAMPLE")

"""
After that you can connect.
Now you can only connect using username and password.
This is a problem because you can't remember the session between executions
for this reason i will add a way to "connect" which is actually not connecting,
but adding the old tokens you saved. This way you can use this between executions
as long as your tokens are still valid without saving the username and password.
"""

jd.connect("email","password")

# When connecting it gets the devices also, so you can use them but if you want to
# gather the devices available in my.jdownloader later you can do it like this

jd.update_devices()

# Now you are ready to do actions with devices. To use a device you get it like this:
device=jd.get_device("TEST")
# The parameter by default is the device name, but you can also use the device_id.
device=jd.get_device(device_id="43434")

# After that you can use the different API functions.
# For example i want to get the packages of the downloads list, the API has a function under downloads called queryPackages,
# you can use it with this library like this:
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" : True,
                "maxResults" : -1,
                "startAt" : 0,
            }])

DOCUMENTATION

Sadly currently broken. In any case the documentation was generated with the pydoc comments inside the code itself so checking the code should be enough for now.

http://myjdownloader-api-python-library.readthedocs.org/en/latest/myjdapi.html#module-myjdapi

PROJECTS USING THE LIBRARY

Here are example of projects currently using the library. If you want to add your project feel free to open a PR so it gets added.

⚠️ WARNING: I am not endorsing or curating these projects and neither I am responsible nor liable for any problems, losses or damages caused by any of those libraries. Take your own precautions.

LICENSE

The MIT License (MIT)

Copyright (c) 2015 Marc Marquez Santamaria

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

my.jdownloader-api-python-library's People

Contributors

dix0nym avatar mmarquezs avatar neox387 avatar niggggggo avatar nyaran avatar oribafi avatar replexxx avatar rix1337 avatar saviq avatar slix69 avatar ssxdan avatar verybadsoldier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

my.jdownloader-api-python-library's Issues

Linkgrabber.add_links not working

I used this code, but the only parameter that seems to work is "links". Because when I open Jdownlader, the link is added but everything is set by default.

lincs=myjdapi.myjdapi.Linkgrabber(device) #objeto del Linkgrabber

url='https://www.youtube.com/watch?v=d6DP_u6ogqc' 
youtuber = 'Ciudadano Z'
fecha = time.ctime()
lincs.add_links([{
                      "autostart": False,
                      "links": url,
                      "packageName": 'tu vieja',
                      "extractPassword": None,
                      "priority": "DEFAULT",
                      "downloadPassword": None,
                      "destinationFolder": r'C:\Users\MARIANO\\' ,#Downloads\Jdownloader\\'+ youtuber + '\\' + fecha,
                      "overwritePackagizerRules": False
                  }])

Basic Downloads.cleanup() call results Internal server error

I am using your mydownloader api to send links for downloads just fine. However, recently, the following function

jd = Myjdapi()
jd.connect('hidden', 'hidden')
jd.update_devices()
device = jd.get_device(r'hidden') 
device.downloads.cleanup(action='DELETE_FINISHED',  mode='REMOVE_LINKS_ONLY', selection_type='ALL')

results in

MYJDException: 
	SOURCE: DEVICE
	TYPE: INTERNAL_SERVER_ERROR

I tried to debug it to no avail. It would be great if you had a quick a look at it, it probably would not take you long to figure it out. I spent almost two days to figure out what is wrong and I can't. The list of parameters expected by the API did not change.

Thanks in advance,

Compatibility with the depprecated API

Hi,

Is this package compatible with the deprecated API? I have JDownloader running in a NAS on my LAN, so I can use the Deprecated API to connect directly without going through encription nor an external server. I've been trying to user the linkgrabberv2/addLinks endpoint with requests but I have been unsuccessful. I was thinking that maybe this package could work, but by looking at the code it doesn't seem so.

This is what I have been trying to do:

payload = {
'assignJobID': True,
 'autoExtract': False,
 'autostart': True,
 'dataURLs': [],
 'deepDecrypt': True,
 'destinationFolder': '',
 'downloadPassword': '',
 'extractPassword': '',
 'links': 'https://downmagaz.net/out.php?f=x&down=7751125400',
 'overwritePackagizerRules': True,
 'packageName': 'test',
 'priority': 'DEFAULT',
 'sourceUrl': ''
}
posturl = "http://NAS_IP:3128/linkgrabberv2/addLinks"

r = requests.post(
    posturl, 
    data=payload,
    headers={"Content-Type": "application/json; charset=utf-8"}
                 )

and I always get a 400 with

{
 "src"  : "DEVICE",
 "data" : "/linkgrabberv2/addLinks",
 "type" : "BAD_PARAMETERS"
}

I've tried multiple variations of data=json.dumps(payload) and so on. Nothing seems to work. Any ideas?

Thank you in advance.

Change api endpoint to HTTPS

Hello,

I'm using your version from PIP install and I saw it use old HTTP protocol. If it's possible change to HTTPS as it's written on official documentation.

Thanks

no issue but request

Hi Marc,

thanks for that great python Library. it works like a charm.
I've a little problem. I would like to use your library for an KODI addon. But you use pycrypto.
this will not work on KODU, unfortunatelly. so I tried to use cryptopy... so i changed line 674 as follow:
decryptor = aes_cbc.AES_CBC(key=key, keySize=16)

but I get the following error:
jd.connect("xxx","yyy") File "D:\lib\myjdapi\myjdapi.py", line 714, in connect response = self.request_api("/my/connect", "GET",[("email", email), ("appkey", self.__app_key)]) File "D:\lib\myjdapi\myjdapi.py", line 854, in request_api response = self.__decrypt(self.__login_secret, encrypted_response.text) File "D:\lib\myjdapi\myjdapi.py", line 678, in __decrypt decrypted_data = UNPAD(decryptor.decrypt(base64.b64decode(data))) File "D:\lib\myjdapi\myjdapi.py", line 32, in UNPAD return s[0:-ord(s[-1])] IndexError: string index out of range

maybe you have a idea...

How to print results

Hello, i'm very new to python. I got the example working without error but nothing is displayed... how do i print the results of device.downloads.query_packages()?
Regards,

Add support for Concurrency/Threading

I'm seeing some errors(false responses) while making much requests ( without all the direct connection code :p )

tracked it to this:
if jsondata['rid'] != self.__request_id:

How does this happen ?
is this because multiple requests at same time and it answers for a previous one ?

seems the request_id is always higher then the jsondata rid for example
jsondata rid = 1504376192
request_id = 1504376197

How to Rename Package ?

Hi

Adding and renaming links is working fine...
but for jd.linkgrabber.rename_package()
"No idea what parameters i have to pass and/or i don't know what it does. If i find out i will implement it :P "

It is used to name the package which is contain the links, same as Folder of the files.

Any possibility to implement/fix it ?

Also, specifying destination Folder when adding link doesn't work or i didn't know how to use it !!
Here is how i used it when adding links:
jd.linkgrabber.add_links("autostart": False, "links": "https://www.youtube.com/watch?v=xxxxxxxx&ab_channel=xxxxxxxx", "packageName": "Cooking", "destinationFolder": "D:\\Downloads\\CookingFolder")

Thank you...

functions not returning True/false

connect/reconnect/disconnect etc

docstring say :returns: boolean -- True if successful, False if there was any error.
but they are not returning anything

Reconnect

Another question,

Atm when my app starts it does a connect.

Everytime there is a Download I try to reconnect

Is that right? I do this in case my connection isn't valid anymore, because there could be a day between the initial connect and adding links again.

Downloads.query_links

Using development branch on python 2.7.11

Api interface not found error

Need to get download stats of a package actually but seems they have no info on what parameters that needs :/

Allso on link grabber. Add_links I can't get destination folder to work "C:\test" etc tried with different slashes

Invalid request not decrypted

When response != 200 the response does not get encrypted and the json-loading fails.

Line 837
error_msg=json.loads(encrypted_response.text)
should be
error_msg=json.loads(self.__decrypt(self.__device_encryption_token,encrypted_response.text))

TOKEN_INVALID response after a while

When I'm connected and did a get_device() everything works but after some idle time('not sure how long) and trying to use something else with the same myjd instance (like downloads.queryLinks) I'm getting the following responds:
"src":"MYJD"
403 TOKEN_INVALID

seems 'some' token expired ? the old docs say to reconnect.
tought something like this was a good idea

        if encrypted_response.status_code != 200:
            if 'TOKEN_INVALID' in encrypted_response.text and path != "/my/reconnect" and path != "/my/connect":
                response = self.reconnect()
                if response:
                    response = self.request_api(path, http_method, params, action, api)
                    return response
            else:
                  ...

but then I get a 403 AUTH_FAILED. =( so seems it cannot be solved without doing a connect() with email/pw again from outside myjdapi.

this also relates to issue #12 & #13

How to change jdwonloader setting?

Hi,

I use your library and it works perfectly.
Good Job !
I am looking to change the speed limit in the jdownloader settings.
that is possible?
what should I use?

Best regards

Error while login

Got the following error while trying to login:

  File "/Users/me/Documents/workspace/RemoteSystemsTempFiles/192.168.1.70/usr/script/testing/jd/jdtest.py", line 5, in <module>
    jd.connect("[email protected]","test123")
  File "/Users/me/Documents/workspace/RemoteSystemsTempFiles/192.168.1.70/usr/script/testing/jd/myjdapi.py", line 591, in connect
    text=self.call("/my/connect","GET",rid=True,params=[("email",email),("appkey",self.appkey)])
  File "/Users/me/Documents/workspace/RemoteSystemsTempFiles/192.168.1.70/usr/script/testing/jd/myjdapi.py", line 758, in call
    response=self.__decrypt(self.loginSecret,encryptedresp.text) 
  File "/Users/me/Documents/workspace/RemoteSystemsTempFiles/192.168.1.70/usr/script/testing/jd/myjdapi.py", line 556, in __decrypt
    decrypted_data = unpad(decryptor.decrypt(base64.b64decode(data)))
  File "/Users/me/Documents/workspace/RemoteSystemsTempFiles/192.168.1.70/usr/script/testing/jd/myjdapi.py", line 16, in <lambda>
    unpad = lambda s : s[0:-s[-1]]
TypeError: bad operand type for unary -: 'str'

Logging

Could you add a logger something like:

import logging
logging.basicConfig()
logger = logging.getLogger('myjdapi')

Cause I don't see the exceptions when using myjdapi as an import module, guess it can be done somehow but idk :)

creating a logger.error or debug with the error message and returning False might be more useful then aborting in a raise ?

Linkgrabber.add_links destinationFolder argument not working

Hello,

It seems that the destinationFolder argument is not working.
When using this instruction device.linkgrabber.add_links([{"autostart": True, "links": "SomeURL", "destinationFolder": "/someDestination"}]), the file is downloaded at DefaultFolder/FilenameWithoutExtention/

Am I doing it wrong, or is it a bug?

Thx

Documentations

Hello,

Where i can find the documentations ?
I try to make it but nothing.

Yours sincerely.

code unreachable

line 697: return False

I guess this line can be removed havent looked into it, will try your changes to direct connection after those 2 PR =D

Parameters

Hey,

This line is causing issues :

params_request+=[str(param).replace("'",'"').replace("True","true").replace("False","false").replace('None',"null")]

This needs to not happen on destinationFolder and links parameters else it will fail

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.