You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Make sure .m3u file's special characters are converted
18
+
Replace most commont HTML exclamations"""
19
+
lineOfPlaylist=lineOfPlaylist.replace("%20", " ")
20
+
lineOfPlaylist=lineOfPlaylist.replace("%21", "!")
21
+
lineOfPlaylist=lineOfPlaylist.replace("%22", '"')
22
+
lineOfPlaylist=lineOfPlaylist.replace("%23", "#")
23
+
lineOfPlaylist=lineOfPlaylist.replace("%24", "$")
24
+
lineOfPlaylist=lineOfPlaylist.replace("%25", "%")
25
+
lineOfPlaylist=lineOfPlaylist.replace("%26", "&")
26
+
lineOfPlaylist=lineOfPlaylist.replace("%27", "'")
27
+
lineOfPlaylist=lineOfPlaylist.replace("%28", "(")
28
+
lineOfPlaylist=lineOfPlaylist.replace("%29", ")")
29
+
lineOfPlaylist=lineOfPlaylist.replace("%2A", "*")
30
+
lineOfPlaylist=lineOfPlaylist.replace("%2B", "+")
31
+
lineOfPlaylist=lineOfPlaylist.replace("%2C", ",")
32
+
lineOfPlaylist=lineOfPlaylist.replace("%2D", "-")
33
+
lineOfPlaylist=lineOfPlaylist.replace("%2E", ".")
34
+
lineOfPlaylist=lineOfPlaylist.replace("%2F", "/")
35
+
lineOfPlaylist=lineOfPlaylist.replace("%3A", ":")
36
+
lineOfPlaylist=lineOfPlaylist.replace("%3B", ";")
37
+
lineOfPlaylist=lineOfPlaylist.replace("%3C", "<")
38
+
lineOfPlaylist=lineOfPlaylist.replace("%3D", "=")
39
+
lineOfPlaylist=lineOfPlaylist.replace("%3E", ">")
40
+
lineOfPlaylist=lineOfPlaylist.replace("%3F", "?")
41
+
returnlineOfPlaylist
42
+
43
+
defquitWithMessage(messageString):
44
+
"""Quits script gracefully with message"""
45
+
print(messageString)
46
+
input("Press Enter to quit...")
47
+
sys.exit()
48
+
49
+
print("\
50
+
Starting Conversion script for structuring files for DFplayerMini.\n\
51
+
This script analyzes .m3u playlists and restructures their contents to a format\n\
52
+
readable by the DFmini mp3 module.\n\n")
53
+
54
+
# folder names
13
55
plFldrName="PlayListsM3U"
14
56
crdFldrName="SDcardFolders"
15
-
#player's maximum accepted file cnt
57
+
#player's maximum accepted file cnt
16
58
maxFldrCnt=99
17
59
maxFileCnt=255
60
+
listOfPlaylists=None
18
61
19
-
#get current working directory
62
+
#get current working directory
20
63
myPath=os.getcwd()
21
-
#create directories for playlists and target folders
64
+
#create directories for playlists and target folders
22
65
plPath=os.path.join(os.sep, myPath, plFldrName)
23
66
crdPath=os.path.join(os.sep, myPath, crdFldrName)
24
-
listOfPlaylists=None
25
67
tgtFldrPath=-1
26
68
tgtFileName=-1
27
69
28
-
#Check for playlist path
70
+
print("Hooked to current working directory: %s"%myPath)
71
+
72
+
# Check for playlist path
29
73
ifnotos.path.exists(plFldrName):
30
-
print("Did not find folder containing m3u playlists.\nTrying to create folder 'PlayListsM3U' for you.\nPlease move your playlists to this place before restarting the script.")
74
+
print("\
75
+
Did not find folder containing m3u playlists.\n\
76
+
Trying to create folder 'PlayListsM3U' for you.")
31
77
try:
32
78
os.makedirs(plFldrName)
33
79
except:
34
-
print("Couldn't create folder. Is directory read-only?")
35
-
input("Press Enter to quit...")
36
-
quit()
80
+
quitWithMessage("Couldn't create folder. Is directory read-only?")
81
+
quitWithMessage("\
82
+
Playlist folder successfully created: %s\n\
83
+
Please move your playlists to this place before restarting the script."%plFldrName)
37
84
else:
38
-
#if Playlist folder exists, print playlists to be evaluated.
85
+
#if Playlist folder exists, print playlists to be evaluated.
39
86
listOfPlaylists=os.listdir(plFldrName)
40
87
listOfPlaylists.sort()
41
88
print("Folder containing playlists found. Will try creating DFplayer folders and files for:")
42
89
print(listOfPlaylists)
43
-
#input("Press Enter to continue...")
44
-
45
-
#Check for album(folder) path
90
+
# input("Press Enter to continue...")
91
+
92
+
#Check for album(folder) path
46
93
ifnotos.path.exists(crdFldrName):
47
-
print("Did not find folder containing SD card MP3 folders.\nTrying to create folder 'SDcardFolders' for you.\nYou will find the files to transfer to Tonuino in this folder.")
94
+
print("\
95
+
Did not find folder containing SD card MP3 folders.\n\
96
+
Trying to create folder 'SDcardFolders' for you.\n\
97
+
You will find the files to transfer to your DFplayerMini's SD card in this folder.")
48
98
try:
49
99
os.makedirs(crdFldrName)
50
100
except:
51
-
print("Couldn't create folder. Is directory read-only?")
52
-
input("Press Enter to quit...")
53
-
quit()
101
+
quitWithMessage("Couldn't create folder. Is directory read-only?")
54
102
else:
55
-
#if Playlist folder exists, print playlists to be evaluated.
103
+
#if Playlist folder exists, print playlists to be evaluated.
56
104
listOfCardFolders=os.listdir(crdFldrName)
57
105
print("Folder containing SDcard MP3 folders found. Will modify folder structure based on playlist input.")
0 commit comments