def titles_match(gm_title: str, sp_title: str) -> bool: stripped_gm_title, _ = utils.strip_ft_artist_from_title(gm_title) stripped_sp_title, _ = utils.strip_ft_artist_from_title(sp_title) stripped_gm_title = utils.strip_str(stripped_gm_title) stripped_sp_title = utils.strip_str(stripped_sp_title) logger.debug( f'Comparing gm_title "{stripped_gm_title}" to "{stripped_sp_title}"') return stripped_gm_title == stripped_sp_title
def test_strip_ft_artist_one_ft_no_brackets(self): """ Given featuring one Artist not in brackets, should return stripped title and that one artist """ title = 'Tha Lyot Remix feat. DJ Roy' expected = ('Tha Lyot Remix', 'DJ Roy') actual = utils.strip_ft_artist_from_title(title) self.assertEqual(actual, expected)
def test_strip_ft_artist_no_fts(self): """ Should return the title as is with no featuring artists """ title = 'Defeat' expected = (title, '') actual = utils.strip_ft_artist_from_title(title) self.assertEqual(actual, expected)
def test_strip_ft_artist_one_ft_hyphen(self): """ Given featuring one Artist seperated by a hyphen instead of brackets Should return stripped title and that one artist """ title = 'Stretch Deep - feat. Eve Essex' expected = ('Stretch Deep', 'Eve Essex') actual = utils.strip_ft_artist_from_title(title) self.assertEqual(actual, expected)
def test_strip_ft_artist_one_ft_no_dot(self): """ Given featuring one Artist in brackets with no dot Should return stripped title and that one artist """ title = 'MMXXX (ft Moor Mother)' expected = ('MMXXX', 'Moor Mother') actual = utils.strip_ft_artist_from_title(title) self.assertEqual(actual, expected)
def test_strip_ft_artist_one_ft_brackets_more_content(self): """ Given featuring one Artist in brackets and more text after the Feat Should return stripped title and that one artist """ title = 'WYWD (feat. Kelela) (Remix)' expected = ('WYWD (Remix)', 'Kelela') actual = utils.strip_ft_artist_from_title(title) self.assertEqual(actual, expected)
def get_gm_track_artists(gm_track: gmusic.GMusicTrack) -> List[str]: artists = [] if '&' in gm_track.artist: artists = [artist.strip() for artist in gm_track.artist.split('&')] else: artists.append(gm_track.artist) _, ft_artists = utils.strip_ft_artist_from_title(gm_track.title) if ft_artists: artists.append(ft_artists) return sorted(artists)
def test_strip_ft_artist_one_ft_brackets(self): """ Given featuring one Artist in brackets, should return stripped title and that one artist """ title = 'Jim Jones At Botany Bay (From "The Hateful Eight" Soundtrack)\ (feat. Kurt Russell)' expected = ( 'Jim Jones At Botany Bay (From "The Hateful Eight" Soundtrack)', 'Kurt Russell') actual = utils.strip_ft_artist_from_title(title) self.assertEqual(actual, expected)