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: 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: 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 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 Hypem username: "******"Enter Hypem password: "******"Enter Y if you want to include explicit songs: ") if explicit == 'Y': content_type = 'E' else: content_type = 'R' h = HypemClient(session, user_id, password) # now fetch the json for the hypem popular top 50 playlist = yield from h.fetch_popular() # uprint("playlist", playlist) yield from app.transfer_hypem_playlist(None, h, g, playlist, content_type)
def transfer_start(request): lists = yield from request.json() lists = [l['uri'] for l in lists] if not user_scope.google_token: return json_response({ "status": 401, "message": "Google: not logged in.", }) if not user_scope.spotify_token: return json_response({ "status": 402, "message": "Spotify: not logged in.", }) if not lists: return json_response({ "status": 403, "message": "Please select at least one playlist.", }) sslcontext = ssl.create_default_context(cafile=certifi.where()) conn = aiohttp.TCPConnector(ssl_context=sslcontext) with ClientSession(connector=conn) as session: g = Mobileclient(session, user_scope.google_token) s = SpotifyClient(session, user_scope.spotify_token) yield from transfer_playlists(request, s, g, lists) return json_response({ "status": 200, "message": "transfer will start.", })
def google_login(request): data = yield from request.json() email = data.get("email") password = data.get("password") with ClientSession() as session: g = Mobileclient(session) token = yield from g.login(email, password) if not token: return json_response(dict( status=400, message="login failed.", )) user_scope.google_token = token return json_response(dict(status=200, message="login successful."))
def google_login(request): data = yield from request.json() email = data.get("email") password = data.get("password") with ClientSession() as session: g = Mobileclient(session) token = yield from g.login(email, password) if not token: return json_response(dict( status=400, message="login failed.", )) user_scope.google_token = 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 google_login(request): data = yield from request.json() email = data.get("email") password = data.get("password") log.info('Logging into Google as %s', email) with ClientSession() as session: g = Mobileclient(session) token = yield from g.login(email, password) if not token: return json_response(dict( status=400, message="login failed.", )) user_scope.google_token = token log.info('Caching all playlists from Google') yield from g.cache_playlists() 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)
async def start(): sslcontext = ssl.create_default_context(cafile=certifi.where()) conn = aiohttp.TCPConnector(ssl_context=sslcontext) with ClientSession(connector=conn) as session: g = Mobileclient(session) logged_in = await g.login(google_email, google_pass) if not logged_in: uprint("Invalid Google username/password") sys.exit(1) s = SpotifyClient(session, spotify_token) logged_in = await s.loggedin() if not logged_in: uprint("Invalid Spotify token") sys.exit(1) await test_percent_search(g) await test_playlist(s, g) return # di = await g.fetch_playlists() # import pprint # pprint.pprint(di['data']['items']) # # # playlist_id = await g.create_playlist("Test Playlist") # playlist_id = "2c02eca1-429e-4ce0-a4a8-819415cdee3a" # await g.add_songs_to_playlist( # playlist_id, # ['Twqujxontbfftlzi7hextragxyu'], # # ['ba3a473e-6309-3814-8c05-b8b6619f38f3'], # ) playlists = await s.fetch_spotify_playlists() playlists = [l['uri'] for l in playlists] await app.transfer_playlists(None, s, g, playlists)