def start(): sslcontext = ssl.create_default_context(cafile=certifi.where()) conn = aiohttp.TCPConnector(ssl_context=sslcontext) with ClientSession(connector=conn) as session: google_email = input("Enter Google email address: ") google_pass = getpass("Enter Google password: "******"Invalid Google username/password") sys.exit(1) uprint("Go to {0} and get an oauth token".format(OAUTH_URL)) spotify_token = input("Enter Spotify oauth token: ") s = SpotifyClient(session, spotify_token) logged_in = yield from s.loggedin() if not logged_in: uprint("Invalid Spotify token") sys.exit(1) playlists = yield from s.fetch_spotify_playlists() playlists = [l['uri'] for l in playlists] yield from app.transfer_playlists(None, s, g, playlists)
def start(): sslcontext = ssl.create_default_context(cafile=certifi.where()) conn = aiohttp.TCPConnector(ssl_context=sslcontext) with ClientSession(connector=conn) as session: google_email = input("Enter Google email address: ") google_pass = getpass("Enter Google password: "******"Invalid Google username/password") sys.exit(1) uprint("Go to {0} and get an oauth token".format(OAUTH_URL)) spotify_token = input("Enter Spotify oauth token: ") s = SpotifyClient(session, spotify_token) logged_in = yield from s.loggedin() if not logged_in: uprint("Invalid Spotify token") sys.exit(1) playlists = yield from s.fetch_spotify_playlists() yield from app.transfer_playlists(None, s, g, playlists)
def start(): sslcontext = ssl.create_default_context(cafile=certifi.where()) conn = aiohttp.TCPConnector(ssl_context=sslcontext) with ClientSession(connector=conn) as session: conf = dict( google_email=None, google_pass=None, spotify_token=None, ) try: with open(CONFIG_FILE, 'r') as f: conf.update(yaml.load(f)) except Exception as exc: if not os.path.exists(CONFIG_FILE): log.info('Could not load from config file {}: {}'.format( CONFIG_FILE, exc)) if not conf['google_email']: conf['google_email'] = input("Enter Google email address: ") if not conf['google_pass']: conf['google_pass'] = getpass("Enter Google password: "******"Invalid Google username/password") sys.exit(1) if not conf['spotify_token']: log.info("Go to {0} and get an oauth token".format(OAUTH_URL)) conf['spotify_token'] = input("Enter Spotify oauth token: ") s = SpotifyClient(session, conf['spotify_token']) logged_in = yield from s.loggedin() if not logged_in: log.info("Invalid Spotify token") sys.exit(1) log.info('Caching all playlists from Google') if os.path.exists('google_playlists.pickle'): with open('google_playlists.pickle', 'rb') as f: g._playlists = pickle.load(f) else: yield from g.cache_playlists() with open('google_playlists.pickle', 'wb') as f: pickle.dump(g._playlists, f) log.info('Fetching Spotify playlists') playlists = yield from s.fetch_spotify_playlists() log.info('Starting sync') done = yield from app.transfer_playlists(None, s, g, playlists) log.debug('done=%s', done) log.info('Success!')
def spotify_login(request): data = yield from request.json() oauth_token = data.get("oauthToken") with ClientSession() as session: c = SpotifyClient(session, oauth_token) logged_in = yield from c.loggedin() if not logged_in: return json_response(dict( status=400, message="login failed.", )) user_scope.spotify_token = oauth_token return json_response(dict(status=200, message="login successful."))
def spotify_login(request): data = yield from request.json() oauth_token = data.get("oauthToken") with ClientSession() as session: c = SpotifyClient(session, oauth_token) logged_in = yield from c.loggedin() if not logged_in: return json_response(dict( status=400, message="login failed.", )) user_scope.spotify_token = oauth_token return json_response(dict( status=200, message="login successful." ))
def start(): sslcontext = ssl.create_default_context(cafile=certifi.where()) conn = aiohttp.TCPConnector(ssl_context=sslcontext) with ClientSession(connector=conn) as session: google_email = input("Enter Google email address: ") google_pass = getpass("Enter Google password: "******"Invalid Google username/password") sys.exit(1) user_id = input("Enter Spotify User to copy playlist from: ") playlist = input( "Enter the User's Spotify playlist you want to copy: ") explicit = input("Enter Y if you want to include explicit songs: ") if explicit == 'Y': content_type = 'E' else: content_type = 'R' uprint("Go to {0} and get an oauth token".format(OAUTH_URL)) spotify_token = input("Enter Spotify oauth token: ") s = SpotifyClient(session, spotify_token, user_id) logged_in = yield from s.loggedin() if not logged_in: uprint("Invalid Spotify token") sys.exit(1) playlists = yield from s.fetch_spotify_playlists() yield from app.transfer_playlists(None, s, g, playlist, content_type, playlists)
def start(): sslcontext = ssl.create_default_context(cafile=certifi.where()) conn = aiohttp.TCPConnector(ssl_context=sslcontext) with ClientSession(connector=conn) as session: google_email = input("Enter Google email address: ") google_pass = getpass("Enter Google password: "******"Invalid Google username/password") sys.exit(1) user_id = input("Enter Spotify User to copy playlist from: ") playlist = input("Enter the User's Spotify playlist you want to copy: ") explicit = input("Enter Y if you want to include explicit songs: ") if explicit == 'Y': content_type = 'E' else: content_type = 'R' uprint("Go to {0} and get an oauth token".format(OAUTH_URL)) spotify_token = input("Enter Spotify oauth token: ") s = SpotifyClient(session, spotify_token, user_id) logged_in = yield from s.loggedin() if not logged_in: uprint("Invalid Spotify token") sys.exit(1) playlists = yield from s.fetch_spotify_playlists() yield from app.transfer_playlists(None, s, g, playlist, content_type, playlists)