Slugify filenames in video download to ensure OS interoperability
This commit is contained in:
+6
-3
@@ -21,6 +21,7 @@ from shutil import copyfileobj
|
|||||||
|
|
||||||
from requests.structures import CaseInsensitiveDict
|
from requests.structures import CaseInsensitiveDict
|
||||||
from dateutil.parser import parse
|
from dateutil.parser import parse
|
||||||
|
from slugify import slugify
|
||||||
|
|
||||||
from blinkpy import api
|
from blinkpy import api
|
||||||
from blinkpy.sync_module import BlinkSyncModule
|
from blinkpy.sync_module import BlinkSyncModule
|
||||||
@@ -310,7 +311,8 @@ class Blink():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
clip_address = "{}{}".format(self.urls.base_url, address)
|
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)
|
filename = os.path.join(path, filename)
|
||||||
|
|
||||||
if not debug:
|
if not debug:
|
||||||
@@ -325,5 +327,6 @@ class Blink():
|
|||||||
|
|
||||||
_LOGGER.info("Downloaded video to %s", filename)
|
_LOGGER.info("Downloaded video to %s", filename)
|
||||||
else:
|
else:
|
||||||
print("Camera: {}, Timestamp: {}, Address: {}".format(
|
print(("Camera: {}, Timestamp: {}, "
|
||||||
camera_name, created_at, address))
|
"Address: {}, Filename: {}").format(
|
||||||
|
camera_name, created_at, address, filename))
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
python-dateutil==2.7.5
|
python-dateutil==2.7.5
|
||||||
requests>=2.20.0
|
requests>=2.20.0
|
||||||
|
python-slugify==3.0.2
|
||||||
testtools==2.3.0
|
testtools==2.3.0
|
||||||
|
|||||||
Reference in New Issue
Block a user