• MrKingDice

    @mikael I know but I cant they accept only https redirects urls

    posted in Pythonista read more
  • MrKingDice

    @mikael I already do it, I launch my script open the access_code url and I press authrize, then redirect me to the right https://localhost:8090/oauth2callback plus the code in the URL, but this is the trace

    127.0.0.1 - - [05/May/2020 18:55:17] code 400, message Bad request version ('\x15:}\x824\x8cL\xb33\x96Q\x11\x86\xcflG5\xf9\xbc\x00\xdaR')
    127.0.0.1 - - [05/May/2020 18:55:18] code 400, message Bad request syntax ('\x16\x03\x01\x02\x00\x01\x00\x01\xfc\x03\x03/\xe4tH\xed`\xf7\xeds3N\x82\x0b\xef\x14\xc7/\x12\xb41\x8c\xfc\xfc?\xca0\xce\x1a\xb3\x95\xf2\xc0 (\x9e\x1c\xceI\xccmW\xd1M\xae\xa2+\xf5O\xef_+\xa3K\xd6\xd3\xa0\xefy\x04\x8f7\xc8\x9e\xbb\xb9\x00"ZZ\x13\x01\x13\x02\x13\x03\xc0+\xc0/\xc0,\xc00\xcc\xa9\xcc\xa8\xc0\x13\xc0\x14\x00\x9c\x00\x9d\x00/\x005\x00')```
    I think is because I must use httpS and not http (instagram rules), I tried a very basic script with flask and https enable and return me sort of code
    

    EDIT:
    After some digging I try a very basic script using flask and I get sort of code:

    import os
    from flask import Flask, request
    app = Flask(__name__)
    
    @app.route('/oauth2callback')
    def show_info():
        code=request.args.get('code')
        return code
    if __name__ == "__main__":
      port = int(os.environ.get("PORT", 8090))
      app.run(host='localhost', port=port,ssl_context='adhoc')
      print(show_info())
    

    And the trace

     * Serving Flask app "server" (lazy loading)
     * Environment: production
       WARNING: This is a development server. Do not use it in a production deployment.
       Use a production WSGI server instead.
     * Debug mode: off
     * Running on https://localhost:8090/ (Press CTRL+C to quit)
    127.0.0.1 - - [05/May/2020 19:40:42] "GET /oauth2callback?code=//code HTTP/1.1" 200 -
    

    posted in Pythonista read more
  • MrKingDice

    @mikael okay I think this api will not take me anywhere, but for my exercise I'm trying to versioning the spotify client but maybe I will need ur support if u want, I cannot get the code in the uri when redirected in https://localhost:8090/oauth2callback

    posted in Pythonista read more
  • MrKingDice

    Okay I've read it and make it until step 6, now I have my access_token valid for 1 hour, I need to put steps 4 to 6 in a automated script right? and then? I see there is long live token that can be more convenient
    Moreover I dont find a field/request/method to get a list of followers/following in the documentation, did I lost something?

    posted in Pythonista read more
  • MrKingDice

    Hello I have a project to write a python script to check who I am following that not follow me back, I search the instagram API on github page but TLTR say it will be deprecated in few months and to use the API Instagram Basic Display on the facebook for developer page, but I dont understand how to use it and how to connect to a python script, someone can help me or have any ideas?

    posted in Pythonista read more
  • 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!