mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-12-08 20:39:08 +00:00
Add --manual option to download songs manually (#33)
Using this option will show all the available songs for a particular search term or list.
This commit is contained in:
36
spotdl.py
36
spotdl.py
@@ -20,23 +20,51 @@ open('list.txt', 'a').close()
|
|||||||
spotify = spotipy.Spotify()
|
spotify = spotipy.Spotify()
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-n", "--no-convert", help="skip the conversion process and meta-tags",
|
parser.add_argument("-n", "--no-convert", help="skip the conversion process and meta-tags", action="store_true")
|
||||||
action="store_true")
|
parser.add_argument("-m", "--manual", help="choose the song to download manually", action="store_true")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.no_convert:
|
if args.no_convert:
|
||||||
print("-n, --no-convert skip the conversion process and meta-tags")
|
print("-n, --no-convert skip the conversion process and meta-tags")
|
||||||
|
if args.manual:
|
||||||
|
print("-m, --manual choose the song to download manually")
|
||||||
|
|
||||||
def searchYT(number):
|
def searchYT(number):
|
||||||
items = (requests.request(method='GET', url=URL)).text
|
items = (requests.request(method='GET', url=URL)).text
|
||||||
items_parse = BeautifulSoup(items, "html.parser")
|
items_parse = BeautifulSoup(items, "html.parser")
|
||||||
first_result = items_parse.find_all(attrs={'class':'yt-uix-tile-link'})[0]['href']
|
|
||||||
check = 1
|
check = 1
|
||||||
|
if args.manual:
|
||||||
|
links = []
|
||||||
|
if isSpotify():
|
||||||
|
print((content['artists'][0]['name'] + ' - ' + content['name']).encode('utf-8'))
|
||||||
|
print('')
|
||||||
|
for x in items_parse.find_all('h3', {'class':'yt-lockup-title'}):
|
||||||
|
if not x.find('channel') == -1 or not x.find('googleads') == -1:
|
||||||
|
print(str(check) + '. ' + x.get_text())
|
||||||
|
links.append(x.find('a')['href'])
|
||||||
|
check += 1
|
||||||
|
is_error = True
|
||||||
|
print('')
|
||||||
|
while is_error:
|
||||||
|
try:
|
||||||
|
the_chosen_one = int(raw_input('>> Choose your number: '))
|
||||||
|
if the_chosen_one >= 1 and the_chosen_one <= len(links):
|
||||||
|
is_error = False
|
||||||
|
else:
|
||||||
|
print('Choose a valid number!')
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
graceQuit()
|
||||||
|
except:
|
||||||
|
print('Choose a valid number!')
|
||||||
|
print('')
|
||||||
|
first_result = links[the_chosen_one-1]
|
||||||
|
else:
|
||||||
|
first_result = items_parse.find_all(attrs={'class':'yt-uix-tile-link'})[0]['href']
|
||||||
while not first_result.find('channel') == -1 or not first_result.find('googleads') == -1:
|
while not first_result.find('channel') == -1 or not first_result.find('googleads') == -1:
|
||||||
first_result = items_parse.find_all(attrs={'class':'yt-uix-tile-link'})[check]['href']
|
first_result = items_parse.find_all(attrs={'class':'yt-uix-tile-link'})[check]['href']
|
||||||
check += 1
|
check += 1
|
||||||
del check
|
del check
|
||||||
full_link = "youtube.com" + first_result
|
full_link = "youtube.com" + first_result
|
||||||
#print(full_link)
|
|
||||||
global video
|
global video
|
||||||
video = pafy.new(full_link)
|
video = pafy.new(full_link)
|
||||||
global raw_title
|
global raw_title
|
||||||
|
|||||||
Reference in New Issue
Block a user