• MrKingDice

    @mikael sorry my error, I have modified it now lol
    I'll test and modify if needed, if I come with something useful I'll make a pull request

    posted in Pythonista read more
  • MrKingDice

    @mikael That is perfect for my use case, so I can create a converter to apple music song to spotify link for sharing purpuose
    Take a look if u want to integrate
    The shortcut:
    https://www.icloud.com/shortcuts/52b1231a7a294db9bc3b1900b96a48be
    and the script code:

    from spoter import Spoter
    import clipboard
    import webbrowser
    query=clipboard.get().splitlines()
    q='track:'+query[0]+' artist:'+query[1].replace('&','')+' album:'+query[2].replace('- Single','')
    #apple music put & when a song is made from 2 artists and add - Single in the album name
    q.replace(" ","%20")
    print(q)
    spot = Spoter(client_id='client_id', client_secret='client_secret')
    result = spot.search(q, 'track')
    clipboard.set(result['tracks']['items'][0]['external_urls']['spotify'])
    url = "music://x-callback-url/run--shortcut?name=[Test]&input=clipboard"
    #I Assume you are using the shortcut in share option in music app
    webbrowser.open(url)
    

    Is not perfect at 100% but I'm bad at finding "hard" testing cases

    posted in Pythonista read more
  • MrKingDice

    @mikael, I'll try that code but I think the second option is more viable, I'll just need more time to get the things done

    posted in Pythonista read more
  • MrKingDice

    Thank you I’ve resolved partially, I’ve moved the problem in client.py in the spotipy api,

    Pythonista3/Documents/site-packages-3/spotipy/client.py", line 151, in _internal_call
        method, url, headers=headers, proxies=self.proxies, **args
    AttributeError: __enter__
    

    posted in Pythonista read more
  • MrKingDice

    Hi guys im new in the pythonista world, Im not a very good english writer so I’ll try to be short
    I have a small idea of a script in python but I need to work with Spotipy, but when I try to start the script says the client_id is not set, I don’t understand where I have to set it, I tried to modify the oauth2.py in the variables, but doesn’t work, where I set the environment variable?
    This is an example code i need to make work (sesrch.py on spotipy github page)

    from spotipy.oauth2 import SpotifyClientCredentials
    import spotipy
    if len(sys.argv) > 1:
        search_str = sys.argv[1]
    else:
        search_str = 'Radiohead'
    
    sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
    result = sp.search(search_str)
    pprint.pprint(result)
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!