mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Small fixes
This commit is contained in:
@@ -9,6 +9,7 @@ try:
|
||||
except:
|
||||
from urllib.request import quote
|
||||
|
||||
# method to input (user playlists) and (track when using manual mode)
|
||||
def input_link(links):
|
||||
while True:
|
||||
try:
|
||||
@@ -22,6 +23,7 @@ def input_link(links):
|
||||
except ValueError:
|
||||
print('Choose a valid number!')
|
||||
|
||||
# remove first song from .txt
|
||||
def trim_song(file):
|
||||
with open(file, 'r') as fin:
|
||||
data = fin.read().splitlines(True)
|
||||
@@ -62,13 +64,15 @@ def is_spotify(raw_song):
|
||||
else:
|
||||
return False
|
||||
|
||||
# generate filename of the song to be downloaded
|
||||
def generate_filename(title):
|
||||
raw_title = title.replace(' ', '_')
|
||||
# slugify removes any special characters
|
||||
filename = slugify(raw_title, ok='-_()[]{}', lower=False)
|
||||
return fix_encoding(filename)
|
||||
|
||||
# please respect this user token :)
|
||||
def generate_token():
|
||||
# Please respect this user token :)
|
||||
creds = oauth2.SpotifyClientCredentials(
|
||||
client_id='4fe3fecfe5334023a1472516cc99d805',
|
||||
client_secret='0f02b7c483c04257984695007a4a8d5c')
|
||||
@@ -79,6 +83,7 @@ def generate_search_URL(song):
|
||||
URL = "https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=" + quote(song)
|
||||
return URL
|
||||
|
||||
# fix encoding issues in python2
|
||||
def fix_encoding(query):
|
||||
if sys.version_info > (3, 0):
|
||||
return query
|
||||
|
||||
Reference in New Issue
Block a user