[utils] Prevent hyphen at beginning of filename (Fixes #5035)
[youtube-dl] / youtube_dl / utils.py
index 475fad3c903f9a2923def9f186c746d067807a68..e2631dccda7a13679da2280b1e8d38301b7ffe47 100644 (file)
@@ -304,6 +304,8 @@ def sanitize_filename(s, restricted=False, is_id=False):
         # Common case of "Foreign band name - English song title"
         if restricted and result.startswith('-_'):
             result = result[2:]
+        if result.startswith('-'):
+            result = '_' + result[len('-'):]
         if not result:
             result = '_'
     return result