Skip to content

Commit

Permalink
download: use the Playback command instead of Download (#86)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sven337 authored Dec 11, 2024
1 parent b0bcb9f commit ba170de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion reolinkapi/handlers/api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
9 changes: 6 additions & 3 deletions reolinkapi/mixins/download.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ba170de

Please sign in to comment.