summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjamos35
1 files changed, 25 insertions, 10 deletions
diff --git a/jamos b/jamos
index 12cfd07..bca6f0c 100755
--- a/jamos
+++ b/jamos
@@ -94,16 +94,32 @@ def get_video_urls_in_playlist(playlist_url, ytdl):
return urls
+def remove_special_characters_for_filename(filename):
+ special_chars = [
+ ['-', ' '],
+ ['(', ''],
+ [')', ''],
+ ['/', ' '],
+ ['/', ' '],
+ [' ', '_'],
+ ["'", ''],
+ ["&", 'and'],
+ [chr(8217), ''],
+ ['$', 's'],
+ ['.', '']
+ ]
+ new_name = filename
+
+ for char_set in special_chars:
+ new_name = new_name.replace(char_set[0], char_set[1])
+
+ return new_name.lower()
+
+
def move_file(file, metadata, output_directory):
- artist = metadata['artist'].replace(
- '-', ' ').replace("/", " ").replace(' ', '_').replace("'", "").replace(
- "&", "and").replace(chr(8217), "").lower()
- album = metadata['album'].replace(
- '-', ' ').replace("/", " ").replace(' ', '_').replace("'", "").replace(
- "&", "and").replace(chr(8217), "").lower()
- title = metadata['title'].replace(
- '-', ' ').replace("/", " ").replace(' ', '_').replace("'", "").replace(
- "&", "and").replace(chr(8217), "").lower()
+ artist = remove_special_characters_for_filename(metadata['artist'])
+ album = remove_special_characters_for_filename(metadata['album'])
+ title = remove_special_characters_for_filename(metadata['title'])
final_directory = os.path.join(
output_directory,
@@ -112,7 +128,6 @@ def move_file(file, metadata, output_directory):
Path(final_directory).mkdir(parents=True, exist_ok=True)
- # TODO: Include album title in filename
# TODO: Research converting to mp3 instead of just naming it such.
# TODO: Research better file formats over mp3?
os.rename(