From df09e43118962c0638b4786adb043e6fe1db1a8e Mon Sep 17 00:00:00 2001 From: Sven337 Date: Mon, 9 Dec 2024 10:48:55 +0100 Subject: [PATCH] download: use the Playback command instead of Download On my TrackMix Wifi, both API commands work the same way, but Download is limited to about 800kB/s, while Playback hits about 4MB/s. So, replace the Download command with Playback by default for get_file. The "method" optional argument can be used to switch back to Download for people who need it. --- reolinkapi/handlers/api_handler.py | 2 +- reolinkapi/mixins/download.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/reolinkapi/handlers/api_handler.py b/reolinkapi/handlers/api_handler.py index 85bf8b5..2ef7464 100644 --- a/reolinkapi/handlers/api_handler.py +++ b/reolinkapi/handlers/api_handler.py @@ -121,7 +121,7 @@ def _execute_command(self, command: str, data: List[Dict], multi: bool = False) try: if self.token is None: raise ValueError("Login first") - if command == 'Download': + if command == 'Download' or command == 'Playback': # Special handling for downloading an mp4 # Pop the filepath from data tgt_filepath = data[0].pop('filepath') diff --git a/reolinkapi/mixins/download.py b/reolinkapi/mixins/download.py index ebd1603..3580930 100644 --- a/reolinkapi/mixins/download.py +++ b/reolinkapi/mixins/download.py @@ -1,18 +1,21 @@ class DownloadAPIMixin: """API calls for downloading video files.""" - def get_file(self, filename: str, output_path: str) -> bool: + def get_file(self, filename: str, output_path: str, method = 'Playback') -> bool: """ Download the selected video file + On at least Trackmix Wifi, it was observed that the Playback method + yields much improved download speeds over the Download method, for + unknown reasons. :return: response json """ body = [ { - "cmd": "Download", + "cmd": method, "source": filename, "output": filename, "filepath": output_path } ] - resp = self._execute_command('Download', body) + resp = self._execute_command(method, body) return resp