Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

download: use the Playback command instead of Download #86

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

sven337
Copy link
Contributor

@sven337 sven337 commented Dec 9, 2024

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 for get_file.

Copy link
Member

@Benehiko Benehiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit hesitant to just replace something that's already working. Maybe we could create a new file called mixins/playback.py, copy & paste most of the code from mixins/download.py and then inside the api_handler.py do an if with an or to run on both Download and Playback.

I know it's a bit extra work, but it would prevent potentially breaking behavior for others that rely on download.py.

@sven337
Copy link
Contributor Author

sven337 commented Dec 11, 2024

Understood.
I can do what you ask, but I suggest a less verbose alternative. We keep the download mixin and add an optional "method" argument. I can default it to Download if you like. It seems more elegant to me, but let me know what you prefer.

diff --git a/reolinkapi/mixins/download.py b/reolinkapi/mixins/download.py
index 7289cdc..7ffa9e4 100644
--- a/reolinkapi/mixins/download.py
+++ b/reolinkapi/mixins/download.py
@@ -1,18 +1,18 @@
 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
         :return: response json
         """
         body = [
             {
-                "cmd": "Playback",
+                "cmd": method,
                 "source": filename,
                 "output": filename,
                 "filepath": output_path
             }
         ]
-        resp = self._execute_command('Playback', body)
+        resp = self._execute_command(method, body)
 
         return resp

@Benehiko
Copy link
Member

Understood. I can do what you ask, but I suggest a less verbose alternative. We keep the download mixin and add an optional "method" argument. I can default it to Download if you like. It seems more elegant to me, but let me know what you prefer.

diff --git a/reolinkapi/mixins/download.py b/reolinkapi/mixins/download.py
index 7289cdc..7ffa9e4 100644
--- a/reolinkapi/mixins/download.py
+++ b/reolinkapi/mixins/download.py
@@ -1,18 +1,18 @@
 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
         :return: response json
         """
         body = [
             {
-                "cmd": "Playback",
+                "cmd": method,
                 "source": filename,
                 "output": filename,
                 "filepath": output_path
             }
         ]
-        resp = self._execute_command('Playback', body)
+        resp = self._execute_command(method, body)
 
         return resp

@sven337 SGTM

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.
@sven337
Copy link
Contributor Author

sven337 commented Dec 11, 2024

Done.

@Benehiko Benehiko merged commit ba170de into ReolinkCameraAPI:master Dec 11, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants