Coder Social home page Coder Social logo

mydlink-api-python's People

Contributors

ageof avatar ageof2 avatar leonmarkacz 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mydlink-api-python's Issues

I want to get snapshot

Hi,

Thank you for your great code.
This is nice but I wanted to get snapshot.

So I tried to post https://mp-eu-openapi.auto.mydlink.com/v2/device/live/snapshot?access_token=<TOKEN> with this kind payload {data: {mydlink_id: "<MYDLINKID>", uid: 0, idx: 0, size: 2}} but What I got was 400 Error says "Client doesnt have privilege."

Do you know the way to get snapshot? if you know that, Can you add this function?
I'm thinking there is no way to do that. I guess..

Anyway, thank you for your code. I learned a lot :-)

More functions?

Are you planning to implement more functions such as retrieving live video feed from cameras? This could be a potential Integration in Home Assistant.

Let me know how can I help with it please.

You can close this issue, I did not know how to contact you :)

Integration in HomeAssistant

I'm trying to integrate the program in HomeAssistant but I'm not able to call the API from the configuration.yaml: could you kindly help provinding the code? Thank you

library error

Good afternoon. I tried your library with this code:
from mydlink_api.mydlink import MyDlink
mydlink = MyDlink(email="my_mydlink_mail", password="my_dlink_password")
device_id = "camera_id"

device_list = mydlink_client.get_device_list()
print(device_list)

the following error occurred:>>> %Run dlink.py
Traceback (most recent call last):
File "/home/pi/Desktop/dlink.py", line 1, in
from mydlink_api.mydlink import MyDlink
File "/home/pi/.local/lib/python3.9/site-packages/mydlink_api/mydlink.py", line 163, in
device_details = mydlink_client.get_device_details(mydlink_id, mac_address)
File "/home/pi/.local/lib/python3.9/site-packages/mydlink_api/mydlink.py", line 64, in get_device_details
openapi=self.login_params.get('api_site')[0],
TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'str' object

This error also occurs when using other functions.
Thank you in advance for your reply

API docs?

Hi!
I see that you used the API on https://api.auto.mydlink.com/. I want to use it for further development. Where did you find the documentation for that API? Can you send the source somehow?

P.S: Sorry for opening an "Issue" for this, I couldn't find any other way to contact you.

Wrong username/password combination

I'm porting your client to PHP but i'm stuck on the /oauth/authorize2 call.

I get the error Wrong username/password combination from dlink api.

My payload seems ok because dlink api would return Invalid field format. or Error validating this request if it wasn't..

I have double checked my login/password, i even changed it twice on the dlink website.

This is the url generated by my script :

https://api.auto.mydlink.com/oauth/authorize2?client_id=mydlinkuapandroid&redirect_uri=https%3A%2F%2Fmydlink.com&user_name=myemail%40gmail.com&password=MydlinkPassword&response_type=token&timestamp=1647437120&uc_id=bd36a6c011f1287e&uc_name=Yo&sig=70f951989671a71259928cb1d8ad5e15
define('OAUTH2_CLIENT_ID', 'mydlinkuapandroid');
define('OAUTH2_CLIENT_SECRET', '5259311fa8cab90f09f2dc1e09d2d8ee');
define('OAUTH2_ANDROID_ID', 'bd36a6c011f1287e');

$params = [
    'client_id' => OAUTH2_CLIENT_ID,
    'redirect_uri' => 'https://mydlink.com',
    'user_name' => '[email protected]',
    'password' => 'MydlinkPassword',
    'response_type' => 'token',
    'timestamp' => time(),
    'uc_id' => OAUTH2_ANDROID_ID,
    'uc_name' => "Yo",

];

$build = http_build_query($params);
$build .= '&sig=' . md5('/oauth/authorize2?' . $build . OAUTH2_CLIENT_SECRET);

$url = 'https://api.auto.mydlink.com/oauth/authorize2?' . $build;


$headers = [];
$headers[] = 'User-Agent: Mozilla/5.0';
$headers[] = 'connection: Keep-Alive';
$headers[] = 'accept: */*';
$headers[] = 'x-md-lang: de';
$headers[] = 'x-md-app-ver: 02.00.01.75';
$headers[] = 'x-md-os-type: android';
$headers[] = 'x-md-os-version: 7.0';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$return = curl_exec($ch);
var_dump($return);

print curl_error($ch);
curl_close($ch);

IndexError when downloading videos

Hi, i've tried your example for downloading the video's, but i get this output and error message

Request 1 von 33
Request 1 von 33
Request 1 von 33
Request 1 von 33
Request 1 von 33
Request 1 von 33
Request 1 von 33
Request 1 von 33
Request 1 von 33
Traceback (most recent call last):
File "test.py", line 18, in
mydlink.get_mydlink_cloud_recordings(year=2021, month=5, day=3)
File "C:\Users\luc.A-D-E\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mydlink_api\mydlink.py", line 98, in get_mydlink_cloud_recordings
self.__get_mydlink_cloud_recordings_file(all_events_details_json)
File "C:\Users\luc.A-D-E\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mydlink_api\mydlink.py", line 130, in __get_mydlink_cloud_recordings_file
json_object['subs_uid'] = data['act'][0]['subs_uid']
IndexError: list index out of range

Only getting the first 2 Video URLS

Hello,

i used the example code

import argparse
import logging

from mydlink_api.mydlink import MyDlink

if __name__ == "__main__":
    logger = logging.getLogger(None)
    logger.setLevel(logging.INFO)

    parser = argparse.ArgumentParser(
        description="API to Connect MyDlink Cloud Devices")
    parser.add_argument('-e', '--email', dest='email', help='MyDlink email example [email protected]')
    parser.add_argument('-p', '--password', dest='password', help='MyDlink password example Start123')
    args = parser.parse_args()

    mydlink = MyDlink(password=args.password, email=args.email, disable_unverified_https_warn=True)

    device_list_json = mydlink.get_device_list()
    device_info_json = mydlink.get_device_details(mac=device_list_json[0]['mac'],
                                                  mydlink_id=device_list_json[0]['mydlink_id'])

    date_list = [2023, 4, 12]
    events_list = mydlink.get_event_list_meta_infos(year=date_list[0], month=date_list[1], day=date_list[2])
    print(events_list)
    mydlink_event_recordings = mydlink.get_mydlink_cloud_recordings_urls(year=date_list[0], month=date_list[1],
                                                                         day=date_list[2])
    print(mydlink_event_recordings)

I only get the first two Links of Videos from that day... Is there a way to get all the Recordings from that day?

Also the feature to get images in an array does not seem to work.. If i just use your Examplecode i get the following error:

Traceback (most recent call last): File "/home/pi/bin/dlink/runner.py", line 30, in <module> cloud_img_list.append(mydlink.get_mydlink_cloud_img_url(mydlink_id=device_list_json[0]['mydlink_id'], File "/usr/local/lib/python3.9/dist-packages/mydlink_api/mydlink.py", line 154, in get_mydlink_cloud_img_url imagepath = response_content['data']['list'][0]['path'] IndexError: list index out of range

I can't install it

Hello,

I want to install your API for my DCS8300-LH camera, but i don't write pip install on my home assistant (pip command not found on terminal & SSH addon).
Can i have a solution for simply install ? like on HACS ?
Thanks !

Change Status of Power Switch

Hello, thanks for your great work. Is it possible to change the State of Power Switches (DSP-w118)? Thanks for your reply

Alex

Help: privacy control and PTZ setting

Hello and thanks for this good start for querying/setting data on Dlink cameras

I'm trying to modify the code to fetch the privacy settings and eventually set the PTZ. I was able to see which function was called by F12-ing the mydlink.com website and playing a little with controls.

First of all, I'm able to log in and get my camera standard info (device list and device info) with no problem thanks to the provided example. But when I call the control function I get a privilege error...

{'error': {'message': 'Client doesnt have privilege.', 'code': 31}}

I've found that to control and get the privacy settings and even play with PTZ, the entry point is

POST /v2/device/control?acces_token=ACCESSTOKEN

(note the v2, if I put me in place I get another same error {'error': {'message': 'Client doesnt have privilege.', 'code': 31, 'type': 'Device'}})

And then embed the JSON to the POST body to query the info

{"data":{"mydlink_id":"1234","uid":0,"idx":0,"ctrl_id":513}}

Or add a value to set the privacy

{"data": {"mydlink_id": "1234", "uid": 0, "idx": 0, "ctrl_id": 513, "value": {"value": 2}}}

Or PTZ

{"data": {"mydlink_id": "1234", "uid": 0, "idx": 0, "ctrl_id": 26, "value": {"p": 165, "t": 12, "z": 0}}}

Unfortuately I'm getting the error above, and not when I query the device list and info...

I'm SOOOO close of finding this, if you find anything that might help me a little thank you in advance!

Example of implementation of the get privacy function

def get_device_privacy(self, mydlink_id:str) -> json:
	device_privacy_url = "https://{openapi}/v2/device/control?access_token={access_token}".format(
		openapi=self.login_params.get('api_site')[0],
		access_token=self.login_params.get('access_token')[0]
	)
			
	json_object = {}
	json_object['mydlink_id'] = mydlink_id
	json_object['uid'] = 0
	json_object['idx'] = 0
	json_object['ctrl_id'] = 513

	json_object_final = {}
	json_object_final['data'] = json_object
			
	response = self.url_utils.get_request(url=device_privacy_url, type=self.url_utils.TYPE_POST,
										  input_json=json_object_final)

	device_privacy_json = Url.parse(response.content.decode('utf8'))
	print(device_privacy_json)
	return device_privacy_json['data']

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.