From 4b43155480cb28d2349882058ddbeefc828c0d52 Mon Sep 17 00:00:00 2001
From: Robert Goldmann <deadlocker@gmx.de>
Date: Tue, 14 Apr 2020 19:56:28 +0200
Subject: [PATCH] only allow ascii filename; replace slashes in filename as
 this would lead to folder creation

---
 SaveMyPlaylist.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/SaveMyPlaylist.py b/SaveMyPlaylist.py
index 6963372..14ec3c0 100644
--- a/SaveMyPlaylist.py
+++ b/SaveMyPlaylist.py
@@ -60,7 +60,7 @@ class SaveMyPlaylist:
     TITLE = 1
     VIDEO_ID = 2
 
-    ILLEGAL_CHARS = ['NUL', '\',''//', ':', '*', '"', '<', '>', '|']
+    ILLEGAL_CHARS = ['NUL', '\\', '/', ':', '*', '"', '<', '>', '|']
 
     def __init__(self, apiKey, playlistId):
         with open('version.json', 'r', encoding='utf-8') as f:
@@ -174,6 +174,11 @@ class SaveMyPlaylist:
         for char in self.ILLEGAL_CHARS:
             fileName = fileName.replace(char, '')
 
+        try:
+            fileName = fileName.encode('ascii', 'ignore').decode('ascii')
+        except Exception as e:
+            logger.error(f'Error while converting filenem "{fileName}" to ascii', exc_info=e)
+
         return fileName
 
 
-- 
GitLab