Skip to content

Commit d46e7ed

Browse files
authored
Merge pull request #176 from fronzbot/slug
Slugify filenames in video download to ensure OS interoperability
2 parents f67f0dd + 00395b3 commit d46e7ed

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Diff for: blinkpy/blinkpy.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from requests.structures import CaseInsensitiveDict
2323
from dateutil.parser import parse
24+
from slugify import slugify
2425

2526
from blinkpy import api
2627
from blinkpy.sync_module import BlinkSyncModule
@@ -310,7 +311,8 @@ def _parse_downloaded_items(self, result, camera, path, debug):
310311
continue
311312

312313
clip_address = "{}{}".format(self.urls.base_url, address)
313-
filename = "{}_{}.mp4".format(camera_name, created_at)
314+
filename = "{}-{}".format(camera_name, created_at)
315+
filename = "{}.mp4".format(slugify(filename))
314316
filename = os.path.join(path, filename)
315317

316318
if not debug:
@@ -325,5 +327,6 @@ def _parse_downloaded_items(self, result, camera, path, debug):
325327

326328
_LOGGER.info("Downloaded video to %s", filename)
327329
else:
328-
print("Camera: {}, Timestamp: {}, Address: {}".format(
329-
camera_name, created_at, address))
330+
print(("Camera: {}, Timestamp: {}, "
331+
"Address: {}, Filename: {}").format(
332+
camera_name, created_at, address, filename))

Diff for: requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
python-dateutil==2.7.5
22
requests>=2.20.0
3+
python-slugify==3.0.2
34
testtools==2.3.0

0 commit comments

Comments
 (0)