From 42b5818d1b38f22f367829f1d47eae24b683efb4 Mon Sep 17 00:00:00 2001 From: Kepoor Hampond Date: Fri, 17 Mar 2017 23:25:44 -0700 Subject: [PATCH] Fixed issue #11 --- irs/metadata.py | 8 ++++---- irs/ripper.py | 5 +++-- irs/utils.py | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/irs/metadata.py b/irs/metadata.py index eb49472..3232d69 100644 --- a/irs/metadata.py +++ b/irs/metadata.py @@ -33,12 +33,12 @@ class Metadata: self.location = location #self.mp3 = MP3(self.location, ID3=EasyID3) self.mp3 = EasyID3(self.location) - + def add_tag(self, tag, data): # For valid tags: `EasyID3.valid_keys.keys()` self.mp3[tag] = data self.mp3.save() - + def read_tag(self, tag): try: return self.mp3[tag] @@ -57,7 +57,7 @@ class Metadata: ) ) mp3.save() - + def find_album_and_track(song, artist): tracks = spotipy.Spotify().search(q=song, type="track")["tracks"]["items"] for track in tracks: @@ -65,7 +65,7 @@ def find_album_and_track(song, artist): if blank_include(track["artists"][0]["name"], artist): return track["album"], track return False, False - + def parse_genre(genres): if genres != []: genres.reverse() diff --git a/irs/ripper.py b/irs/ripper.py index 1df7879..cd7e03a 100644 --- a/irs/ripper.py +++ b/irs/ripper.py @@ -288,8 +288,9 @@ class Ripper: if data == {}: data = self.parse_song_data(song, artist) - song = data["name"] - artist = data["artist"] + if data != {}: + song = data["name"] + artist = data["artist"] if "file_prefix" not in data: data["file_prefix"] = "" diff --git a/irs/utils.py b/irs/utils.py index 104aa51..d2b06c4 100644 --- a/irs/utils.py +++ b/irs/utils.py @@ -40,7 +40,7 @@ def blank(string, downcase=True): regex = re.compile('[^a-zA-Z0-9\ ]') string = regex.sub('', string) if downcase: string = string.lower() - return string + return ' '.join(string.split()) def blank_include(this, includes_this): this = blank(this) @@ -300,10 +300,10 @@ from .config import CONFIG def check_sources(ripper, key, default=None, environment=False, where=None): tmp_args = ripper.args if where != None and ripper.args.get(where): - tmp_args = ripper.args.get(where) + tmp_args = ripper.args.get("where") - if tmp_args.get(key): - return tmp_args.get(key) + if ripper.args.get(key): + return ripper.args.get(key) elif CONFIG.get(key): return CONFIG.get(key) elif os.environ.get(key) and environment == True: