Use urllib2.quote() to fix encoding errors

This commit is contained in:
Ritiek
2017-06-16 20:53:30 +05:30
parent 1071eb3d75
commit 44f34555b4
5 changed files with 7 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -4,6 +4,11 @@ import os
from slugify import slugify
import spotipy.oauth2 as oauth2
try:
from urllib2 import quote
except:
from urllib.request import quote
def input_link(links):
while True:
try:
@@ -71,8 +76,7 @@ def generate_token():
return token
def generate_search_URL(song):
URL = "https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=" + \
song.replace(" ", "%20")
URL = "https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=" + quote(song)
return URL
def fix_encoding(query):

View File

@@ -22,7 +22,7 @@ def generate_songname(raw_song):
if misc.is_spotify(raw_song):
tags = generate_metadata(raw_song)
raw_song = tags['artists'][0]['name'] + ' - ' + tags['name']
return raw_song
return misc.fix_encoding(raw_song)
def generate_metadata(raw_song):
if misc.is_spotify(raw_song):