mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
removed an extra variable
This commit is contained in:
22
spotdl.py
22
spotdl.py
@@ -25,9 +25,16 @@ spotify = spotipy.Spotify()
|
|||||||
|
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
|
def windowfy(x):
|
||||||
|
if not os.name == 'nt':
|
||||||
|
return x
|
||||||
|
else:
|
||||||
|
return x.replace('/', '\\')
|
||||||
|
|
||||||
|
|
||||||
def Main():
|
def Main():
|
||||||
Title = ''
|
Title = ''
|
||||||
label = ''
|
song = ''
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
for m in os.listdir('Music/'):
|
for m in os.listdir('Music/'):
|
||||||
@@ -52,10 +59,10 @@ def Main():
|
|||||||
br.set_handle_robots(False)
|
br.set_handle_robots(False)
|
||||||
br.addheaders = [("User-agent","Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13")]
|
br.addheaders = [("User-agent","Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13")]
|
||||||
if not Title == '':
|
if not Title == '':
|
||||||
if label == '':
|
if song == '':
|
||||||
link = 'https://duckduckgo.com/html/?q=' + Title.replace(' ', '+') + '+musixmatch'
|
link = 'https://duckduckgo.com/html/?q=' + Title.replace(' ', '+') + '+musixmatch'
|
||||||
else:
|
else:
|
||||||
link = 'https://duckduckgo.com/html/?q=' + label.replace(' ', '+') + '+musixmatch'
|
link = 'https://duckduckgo.com/html/?q=' + song.replace(' ', '+') + '+musixmatch'
|
||||||
page = br.open(link)
|
page = br.open(link)
|
||||||
page = page.read()
|
page = page.read()
|
||||||
soup = BeautifulSoup(page, 'html.parser')
|
soup = BeautifulSoup(page, 'html.parser')
|
||||||
@@ -84,8 +91,8 @@ def Main():
|
|||||||
#song = songie.replace(songie[-1:], "")
|
#song = songie.replace(songie[-1:], "")
|
||||||
song = songie
|
song = songie
|
||||||
content = spotify.track(song)
|
content = spotify.track(song)
|
||||||
label = (content['artists'][0]['name'] + ' - ' + content['name']).replace(" ", "%20").encode('utf-8')
|
song = (content['artists'][0]['name'] + ' - ' + content['name']).replace(" ", "%20").encode('utf-8')
|
||||||
URL = "https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=" + label
|
URL = "https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=" + song
|
||||||
else:
|
else:
|
||||||
song = songie.replace(" ", "%20")
|
song = songie.replace(" ", "%20")
|
||||||
URL = "https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=" + song
|
URL = "https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=" + song
|
||||||
@@ -178,10 +185,11 @@ def Main():
|
|||||||
br.addheaders = [("User-agent","Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13")]
|
br.addheaders = [("User-agent","Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13")]
|
||||||
if (len(raw_song) == 22 and raw_song == song) or (raw_song.find('spotify') > -1):
|
if (len(raw_song) == 22 and raw_song == song) or (raw_song.find('spotify') > -1):
|
||||||
content = spotify.track(song)
|
content = spotify.track(song)
|
||||||
label = (content['artists'][0]['name'] + ' - ' + content['name']).replace(" ", "%20").encode('utf-8')
|
song = (content['artists'][0]['name'] + ' - ' + content['name']).replace(" ", "%20").encode('utf-8')
|
||||||
URL = "https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=" + label
|
URL = "https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=" + song
|
||||||
else:
|
else:
|
||||||
URL = "https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=" + song
|
URL = "https://www.youtube.com/results?sp=EgIQAQ%253D%253D&q=" + song
|
||||||
|
song = ''
|
||||||
items = br.open(URL)
|
items = br.open(URL)
|
||||||
items = items.read()
|
items = items.read()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user