Code Monkey home page Code Monkey logo

tapo-cli's Introduction

tapo-cli: Tapo TP-Link Cloud Video Downloader

tapo-cli is a command-line utility designed to streamline the process of batch-downloading your videos from the Tapo TP-Link Cloud.

Please note that this utility has not been tested on Windows systems. It is recommended to utilize the Windows Subsystem for Linux (WSL) for Windows users.

The utility is compatible with any Debian-based operating system that has python3 and pip3 installed.

Usage Instructions

To begin using Tapo-CLI, follow these steps:

git clone https://github.com/dimme/tapo-cli.git
cd tapo-cli
pip3 install -r requirements.txt
chmod +x tapo-cli.py
./tapo-cli.py login
./tapo-cli.py list-videos
./tapo-cli.py download-videos

For additional information and options, please refer to ./tapo-cli.py --help and ./tapo-cli.py [COMMAND] --help.

Automating Backups

Windows

To automate daily backups on Windows, create a .bat file with the following content and schedule it to run once per day using Task Scheduler:

ubuntu.exe run "/home/<user>/tapo-cli/tapo-cli.py download-videos --days 7 --path /mnt/c/TapoBackups --overwrite 0"

This process requires the Windows Subsystem for Linux (WSL). You may also choose to schedule the task to run upon system logon.

Linux

To automate daily backups on Linux, create a cron task by executing:

sudo crontab -e

Then, append a line similar to the one below, adjusted to match your specific paths:

30 4 * * *  <user> /home/<user>/tapo-cli/tapo-cli.py download-videos --days 7 --path /home/<user>/TapoBackups --overwrite 0

This will schedule the task to run at 4:30 AM every day.

tapo-cli's People

Contributors

akomelj avatar dimme 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

Watchers

 avatar  avatar  avatar

Forkers

havoclabs akomelj

tapo-cli's Issues

getting error code -20571 device is offline, even it is online

I have successfully logged in and obtained authorization.
It is capable of displaying my list of devices. However, when I attempt to list videos, it returns no results.
Furthermore, executing the command list-devices-info indicates that all devices are offline, despite them actually being online.

im using C210 camera

Traceback - KeyError: 'total'

Hello,

I have recently started getting a Traceback when downloading video files from my 2 cameras.

I am using the command : /opt/tapo-cli/tapo-cli.py download-videos --days 10 --path /Data/Tapo --overwrite 0

Which produces the below :

raceback (most recent call last):
File "/opt/tapo-cli/tapo-cli.py", line 366, in
tapo()
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/opt/tapo-cli/tapo-cli.py", line 326, in download_videos
print('\nFound ' + str(videos['total']) + ' videos for ' + dev['alias'] + ':')
KeyError: 'total'

Pretty sure it's related to the high number of videos the cameras have been producing lately due to a lot of motion detection in the zones. Using 7 days works now and reports about 1500 videos to download combined from the 2 cameras.

Is it possible to download SD card stored local videos?

I don't have a tapo cloud subscription but relying on local SD card recordings. It's possible to view those recordings on the tapo app.
So would it be possible to download them using the API? Would you know what endpoints to use? I think the current script supports only those videos that are stored in the "cloud" rather than local mounted sd card.

My plan is to have a cronjob download those local videos onto my linux server as a backup.
Any support or guidance would be really helpful.
Thanks

Downloading sometimes crashes on exceptions, traceback displayed

Hello,

sometimes happen that downloading of videos crashes on exceptions.

Traceback is displayed:

Traceback (most recent call last):
  File "/home/olivie/.local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/home/olivie/.local/lib/python3.10/site-packages/urllib3/util/connection.py", line 72, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/olivie/.local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 714, in urlopen
    httplib_response = self._make_request(
  File "/home/olivie/.local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 403, in _make_request
    self._validate_conn(conn)
  File "/home/olivie/.local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1053, in _validate_conn
    conn.connect()
  File "/home/olivie/.local/lib/python3.10/site-packages/urllib3/connection.py", line 363, in connect
    self.sock = conn = self._new_conn()
  File "/home/olivie/.local/lib/python3.10/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f1413e592a0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/home/olivie/.local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 798, in urlopen
    retries = retries.increment(
  File "/home/olivie/.local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='prd-tapo-care-euw1.s3.eu-west-1.amazonaws.com', port=443): Max retries exceeded with url: /19712897/2023-09-13.17-40-07.761.201973b6-37cb-4a56-86ee-8cf497b66386.1920-1080.29057.ts?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230928T201552Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=AKIA23OYBEOU7DOGUG4B%2F20230928%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Signature=f5a4eaa735bea6868e7205742751d3d21979e0be368277020d17ed2f61b6d382 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f1413e592a0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/olivie/tapo-cli/tapo-cli/tapo-cli.py", line 336, in <module>
    tapo()
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/olivie/tapo-cli/tapo-cli/tapo-cli.py", line 321, in download_videos
    download(url, file_path, file_name)
  File "/home/olivie/tapo-cli/tapo-cli/tapo-cli.py", line 99, in download
    res = requests.get(url)
  File "/usr/local/lib/python3.10/dist-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='prd-tapo-care-euw1.s3.eu-west-1.amazonaws.com', port=443): Max retries exceeded with url: /19712897/2023-09-13.17-40-07.761.201973b6-37cb-4a56-86ee-8cf497b66386.1920-1080.29057.ts?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230928T201552Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=AKIA23OYBEOU7DOGUG4B%2F20230928%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Signature=f5a4eaa735bea6868e7205742751d3d21979e0be368277020d17ed2f61b6d382 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f1413e592a0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

Please correct or suggest working solution.

Thank you and have a nice day.

Best regards
olivie

Cannot download videos, error codes -20651 'Token expired' and -20212 "Incorrect service entry address"

Hello,

when I try to download videos using the same command as usually: /home/olivie/tapo-cli/tapo-cli/tapo-cli.py download-videos --path /home/olivie/TapoBackups --overwrite 0 --days 1 I'm getting error message:
Something went wrong: ('error code': -20651, 'msg': 'Token expired')

I run command ./tapo-cli.py login and put my Tapo credentials but it also came to error:
Something went wrong: ( "appServerUrl": "https://n-euw1-wap-gw.tplinkcloud.com", "errorCode": "-20212", "errorMsg": "Incorrect service entry address" }

And when I tried to download videos, I got again error -20651.

Please correct or suggest working solution.

Thank you and have a nice day.

Best regards
olivie

Cannot download videos, error code -20212 "Incorrect service entry address", "Please login first."

Hello,

when I try to fill my Tapo credentials by command ./tapo-cli.py login and put my Tapo credentials, I got error:
Something went wrong: ( "appServerUrl": "https://n-euw1-wap-gw.tplinkcloud.com", "errorCode": "-20212", "errorMsg": "Incorrect service entry address" }

When I tried to download videos, I got error "Please login first."

Please correct or suggest working solution.

Thank you and have a nice day.

Best regards
olivie

Related to re-opened #3

Downloaded videos are invalid data.

Hii, everything was working properly until last days. I can download videos but can't open. I think TAPO changed format or something.
Someone have the same problem?
image

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.