Skip to content

Commit

Permalink
Merge pull request #176 from fronzbot/slug
Browse files Browse the repository at this point in the history
Slugify filenames in video download to ensure OS interoperability
  • Loading branch information
fronzbot authored May 21, 2019
2 parents f67f0dd + 00395b3 commit d46e7ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions blinkpy/blinkpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from requests.structures import CaseInsensitiveDict
from dateutil.parser import parse
from slugify import slugify

from blinkpy import api
from blinkpy.sync_module import BlinkSyncModule
Expand Down Expand Up @@ -310,7 +311,8 @@ def _parse_downloaded_items(self, result, camera, path, debug):
continue

clip_address = "{}{}".format(self.urls.base_url, address)
filename = "{}_{}.mp4".format(camera_name, created_at)
filename = "{}-{}".format(camera_name, created_at)
filename = "{}.mp4".format(slugify(filename))
filename = os.path.join(path, filename)

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

_LOGGER.info("Downloaded video to %s", filename)
else:
print("Camera: {}, Timestamp: {}, Address: {}".format(
camera_name, created_at, address))
print(("Camera: {}, Timestamp: {}, "
"Address: {}, Filename: {}").format(
camera_name, created_at, address, filename))
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
python-dateutil==2.7.5
requests>=2.20.0
python-slugify==3.0.2
testtools==2.3.0

0 comments on commit d46e7ed

Please sign in to comment.