mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Fix encoding problems hopefully
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from mutagen.easyid3 import EasyID3
|
||||
from mutagen.id3 import ID3, APIC
|
||||
from mutagen.mp4 import MP4, MP4Cover
|
||||
import sys
|
||||
|
||||
# urllib2 is urllib.request in python3
|
||||
try:
|
||||
@@ -25,6 +26,8 @@ def compare(file, metadata):
|
||||
return already_tagged
|
||||
|
||||
def embed(music_file, meta_tags, output_ext):
|
||||
if sys.version_info < (3, 0):
|
||||
music_file = music_file.encode('utf-8')
|
||||
if meta_tags is None:
|
||||
print('Could not find meta-tags')
|
||||
elif output_ext == '.m4a':
|
||||
|
||||
12
core/misc.py
12
core/misc.py
@@ -79,7 +79,8 @@ def feed_tracks(file, tracks):
|
||||
# generate filename of the song to be downloaded
|
||||
def generate_filename(title):
|
||||
# IMO python2 sucks dealing with unicode
|
||||
title = fix_encoding(title, decode=True)
|
||||
title = fix_encoding(title)
|
||||
title = fix_decoding(title)
|
||||
title = title.replace(' ', '_')
|
||||
# slugify removes any special characters
|
||||
filename = slugify(title, ok='-_()[]{}', lower=False)
|
||||
@@ -99,11 +100,14 @@ def generate_search_URL(song):
|
||||
return URL
|
||||
|
||||
# fix encoding issues in python2
|
||||
def fix_encoding(query, decode=False):
|
||||
def fix_encoding(query):
|
||||
if sys.version_info < (3, 0):
|
||||
query = query.encode('utf-8')
|
||||
if decode:
|
||||
query = query.decode('utf-8')
|
||||
return query
|
||||
|
||||
def fix_decoding(query):
|
||||
if sys.version_info < (3, 0):
|
||||
query = query.decode('utf-8')
|
||||
return query
|
||||
|
||||
def grace_quit():
|
||||
|
||||
Reference in New Issue
Block a user