Heyo,
From the start:
I am pretty new to the python universe. My main goal is to program a basic voting system for my own housepartys via WhatsApp messages. (Definitly not easy, but I got time.)
Right now I am trying to get some basic spotiypy functions running to get used to the spotipy api.
My problem:
I got to the point where I try to connect the script with my Spotify device to add specific tracks to my playqueue. My question is connected to the following script:
def addQueue(spotify, object):
try:
spotify.add_to_queue(uri=object)
except:
print("Adding object to queue was canceled.")
After the execution I get redicted to my browser and the set "SPOTIPY_REDIRECT_URI" plus a code I understand as a verfication code of my process. At the same time the console asks for this url + code and wants this input by the user. I have to copy paste it manually right now.
Consoleoutput: Left - Spotipy request | Right - Input (duckduck...)
Since I want to automate it I need to implement a reading script of my browser or maybe catch it before even starting a tab in my browser.
My question
Is there any python friendly way to read / catch this url? Beside that what kind of libarys would you suggest for these actions. I don't want to ask for a script, but since I am learning maybe a good example or tutorial for this kind of implementation. I am open for any suggestions and are willing to look into new languages if necessary (my programming understanding is basic).
Thank you for reading and stay healthy. :)
Greets MrSchiller
By my understanding, the easiest way to go with this would be to use Selenium to automate this browser task of copying the url or the pyperclip (or clipboard module) to automate copying the string to the interactive prompt. If you choose to go with Selenium, I recommend you drop the user input strategy and choose to evaluate a variable's value that you retrieved using Selenium instead. If you need any clarification, please let me know.
Best of luck