mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Fix getting input in python3
This commit is contained in:
@@ -13,7 +13,7 @@ except:
|
|||||||
def input_link(links):
|
def input_link(links):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
the_chosen_one = int(raw_input('>> Choose your number: '))
|
the_chosen_one = int(user_input('>> Choose your number: '))
|
||||||
if the_chosen_one >= 1 and the_chosen_one <= len(links):
|
if the_chosen_one >= 1 and the_chosen_one <= len(links):
|
||||||
return links[the_chosen_one - 1]
|
return links[the_chosen_one - 1]
|
||||||
elif the_chosen_one == 0:
|
elif the_chosen_one == 0:
|
||||||
@@ -23,6 +23,12 @@ def input_link(links):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
print('Choose a valid number!')
|
print('Choose a valid number!')
|
||||||
|
|
||||||
|
def user_input(string=''):
|
||||||
|
if sys.version_info > (3, 0):
|
||||||
|
return input(string)
|
||||||
|
else:
|
||||||
|
return raw_input(string)
|
||||||
|
|
||||||
# remove first song from .txt
|
# remove first song from .txt
|
||||||
def trim_song(file):
|
def trim_song(file):
|
||||||
with open(file, 'r') as fin:
|
with open(file, 'r') as fin:
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ def check_exists(music_file, raw_song, islist):
|
|||||||
return True
|
return True
|
||||||
# if downloading only single song, prompt to re-download
|
# if downloading only single song, prompt to re-download
|
||||||
else:
|
else:
|
||||||
prompt = raw_input('Song with same name has already been downloaded. Re-download? (y/n): ').lower()
|
prompt = misc.user_input('Song with same name has already been downloaded. Re-download? (y/n): ').lower()
|
||||||
if prompt == "y":
|
if prompt == "y":
|
||||||
os.remove("Music/" + file)
|
os.remove("Music/" + file)
|
||||||
return False
|
return False
|
||||||
@@ -313,10 +313,6 @@ def grab_single(raw_song, number=None):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
# python 3 compatibility
|
|
||||||
if sys.version_info > (3, 0):
|
|
||||||
raw_input = input
|
|
||||||
|
|
||||||
os.chdir(sys.path[0])
|
os.chdir(sys.path[0])
|
||||||
if not os.path.exists("Music"):
|
if not os.path.exists("Music"):
|
||||||
os.makedirs("Music")
|
os.makedirs("Music")
|
||||||
|
|||||||
Reference in New Issue
Block a user