Use unidecode to escape weird names

This commit is contained in:
Timothy Rae
2021-07-22 00:52:51 +12:00
parent ab9337edce
commit 57a74f6b13
2 changed files with 3 additions and 1 deletions

View File

@@ -2,3 +2,4 @@ spotipy==2.10.0
tidalapi==0.6.8 tidalapi==0.6.8
pyyaml==5.3.1 pyyaml==5.3.1
tqdm==4.45.0 tqdm==4.45.0
unidecode==1.2.0

View File

@@ -9,13 +9,14 @@ import spotipy
import tidalapi import tidalapi
import time import time
from tqdm import tqdm from tqdm import tqdm
from unidecode import unidecode
from urllib.parse import urljoin from urllib.parse import urljoin
import webbrowser import webbrowser
import yaml import yaml
def simple(input_string): def simple(input_string):
# only take the first part of a string before any hyphens or brackets to account for different versions # only take the first part of a string before any hyphens or brackets to account for different versions
return input_string.split('-')[0].strip().split('(')[0].strip().split('[')[0].strip() return unidecode(input_string).split('-')[0].strip().split('(')[0].strip().split('[')[0].strip()
def duration_match(tidal_track, spotify_track, tolerance=2): def duration_match(tidal_track, spotify_track, tolerance=2):
# the duration of the two tracks must be the same to within 2 seconds # the duration of the two tracks must be the same to within 2 seconds