This repository was archived by the owner on Jul 25, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ void main(List<String> arguments) async {
2424
2525 print ('YT video: $videoId ...' );
2626
27- final path = join ( // TODO Maybe fallback to /tmp
27+ final path = join (
28+ // TODO Maybe fallback to /tmp
2829 Platform .isWindows ? Platform .environment['TMP' ] : cacheHome.path,
2930 'yt-splitter' ,
3031 videoId,
@@ -81,7 +82,7 @@ void main(List<String> arguments) async {
8182
8283 final data = json.decode (File (jsonFilePath).readAsStringSync ());
8384
84- final album = data['title' ]. replaceAll ( '/' , '|' );
85+ final album = stripUnsafeCharacters ( data['title' ]);
8586
8687 final artist = data['artist' ] ?? data['uploader' ] ?? '' ;
8788
@@ -116,7 +117,7 @@ void main(List<String> arguments) async {
116117
117118 alreadySeenTitles.add (chapterTitle);
118119
119- chapterTitle = chapterTitle. replaceAll ( '/' , '|' );
120+ chapterTitle = stripUnsafeCharacters (chapterTitle );
120121
121122 tracknumber++ ;
122123
@@ -186,3 +187,7 @@ String renderDuration(int x) {
186187 }
187188 return str;
188189}
190+
191+ String stripUnsafeCharacters (String text) {
192+ return text.trim ().replaceAll (RegExp (r'\|\/\\\?":\*<>' ), '_' );
193+ }
You can’t perform that action at this time.
0 commit comments