diff options
author | pukkandan <pukkandan@users.noreply.github.com> | 2021-01-23 17:48:12 +0530 |
---|---|---|
committer | pukkandan <pukkandan@gmail.com> | 2021-01-23 17:53:17 +0530 |
commit | 0202b52a0c0a15da6073a122aae7ed6693e18f01 (patch) | |
tree | 46a819bbb1c97649216ff0a040468a7d0d73ef29 /youtube_dlc/utils.py | |
parent | b8f6bbe68a6ff1f733a8d71d991b03008dfaf621 (diff) | |
download | hypervideo-pre-0202b52a0c0a15da6073a122aae7ed6693e18f01.tar.lz hypervideo-pre-0202b52a0c0a15da6073a122aae7ed6693e18f01.tar.xz hypervideo-pre-0202b52a0c0a15da6073a122aae7ed6693e18f01.zip |
#29 New option `-P`/`--paths` to give different paths for different types of files
Syntax: `-P "type:path" -P "type:path"`
Types: home, temp, description, annotation, subtitle, infojson, thumbnail
Diffstat (limited to 'youtube_dlc/utils.py')
-rw-r--r-- | youtube_dlc/utils.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/youtube_dlc/utils.py b/youtube_dlc/utils.py index 1ec30bafd..6740f0cdb 100644 --- a/youtube_dlc/utils.py +++ b/youtube_dlc/utils.py @@ -5893,3 +5893,15 @@ _HEX_TABLE = '0123456789abcdef' def random_uuidv4(): return re.sub(r'[xy]', lambda x: _HEX_TABLE[random.randint(0, 15)], 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx') + + +def make_dir(path, to_screen=None): + try: + dn = os.path.dirname(path) + if dn and not os.path.exists(dn): + os.makedirs(dn) + return True + except (OSError, IOError) as err: + if callable(to_screen) is not None: + to_screen('unable to create directory ' + error_to_compat_str(err)) + return False |