def list_devices(show_desktop, show_mobile): """ List device IDs registered with Google Music. Defaults to showing both desktop and mobile IDs. """ from gmusicapi.clients import Webclient from keyring import get_password webclient = Webclient() email = app.config["GACCOUNT_EMAIL"] password = get_password("gmusicprocurator", email) if password is None: error("Password not set. Please run the set_password subcommand.") return success = webclient.login(email, password) if not success: error("Login failed.") return for device in webclient.get_registered_devices(): dname = device["name"] if len(device["name"]) > 0 else device["model"] if not show_desktop and device["type"] == "DESKTOP_APP": continue if not show_mobile and device["type"] == "PHONE": continue print(u"* {dname} ({type}): {id}".format(dname=dname, **device))
def list_devices(show_desktop, show_mobile): """ List device IDs registered with Google Music. Defaults to showing both desktop and mobile IDs. """ from gmusicapi.clients import Webclient from keyring import get_password webclient = Webclient() email = app.config['GACCOUNT_EMAIL'] password = get_password('gmusicprocurator', email) if password is None: error('Password not set. Please run the set_password subcommand.') return success = webclient.login(email, password) if not success: error('Login failed.') return for device in webclient.get_registered_devices(): dname = device['name'] if len(device['name']) > 0 else device['model'] if not show_desktop and device['type'] == 'DESKTOP_APP': continue if not show_mobile and device['type'] == 'PHONE': continue print(u'* {dname} ({type}): {id}'.format(dname=dname, **device))
def list_devices(show_desktop, show_mobile): """ List device IDs registered with Google Music. Defaults to showing both desktop and mobile IDs. """ from gmusicapi.clients import Webclient from keyring import get_password webclient = Webclient() email = app.config['GACCOUNT_EMAIL'] password = get_password('gmusicprocurator', email) if password is None: error('Password not set. Please run the set_password subcommand.') return success = webclient.login(email, password) if not success: error('Login failed.') return for device in webclient.get_registered_devices(): dname = device['name'] if len(device['name']) > 0 else device['model'] if not show_desktop and device['type'] == 'DESKTOP_APP': continue if not show_mobile and device['type'] == 'PHONE': continue print(u'* {dname} ({type}): {id}'.format(dname=dname, **device))
def _login_mc(self): APP_NAME = 'gmusic-sync-playlist' CONFIG_FILE = 'auth.cfg' config = SafeConfigParser({ 'username': '', 'device_id': '' }) config.read(CONFIG_FILE) if not config.has_section('auth'): config.add_section('auth') username = config.get('auth','username') password = None if username != '': password = keyring.get_password(APP_NAME, username) if password == None or not self.mc.login(username, password): while 1: username = raw_input("Username: "******"Password: "******"Sign-on failed." config.set('auth', 'username', username) with open(CONFIG_FILE, 'wb') as f: config.write(f) keyring.set_password(APP_NAME, username, password) device_id = config.get('auth', 'device_id') if device_id == '': wc = Webclient() if not wc.login(username, password): raise Exception('could not log in via Webclient') devices = wc.get_registered_devices() mobile_devices = [d for d in devices if d[u'type'] in (u'PHONE', u'IOS')] if len(mobile_devices) < 1: raise Exception('could not find any registered mobile devices') device_id = mobile_devices[0][u'id'] if device_id.startswith(u'0x'): device_id = device_id[2:] config.set('auth', 'device_id', device_id) with open(CONFIG_FILE, 'wb') as f: config.write(f) print('Device ID: {}'.format(device_id)) self.mc.device_id = device_id
def list_devices(show_desktop, show_mobile): """ List device IDs registered with Google Music. Defaults to showing both desktop and mobile IDs. """ from gmusicapi.clients import Webclient webclient = Webclient() success = webclient.login(app.config['GACCOUNT_EMAIL'], app.config['GACCOUNT_PASSWORD']) if not success: print('Login failed.', file=sys.stderr) return for device in webclient.get_registered_devices(): dname = device['name'] if len(device['name']) > 0 else device['model'] if not show_desktop and device['type'] == 'DESKTOP_APP': continue if not show_mobile and device['type'] == 'PHONE': continue print(u'* {dname} ({type}): {id}'.format(dname=dname, **device))
def list_devices(show_desktop, show_mobile): """ List device IDs registered with Google Music. Defaults to showing both desktop and mobile IDs. """ from gmusicapi.clients import Webclient webclient = Webclient() success = webclient.login(app.config['GACCOUNT_EMAIL'], app.config['GACCOUNT_PASSWORD']) if not success: print('Login failed.', file=sys.stderr) return for device in webclient.get_registered_devices(): dname = device['name'] if len(device['name']) > 0 else device['model'] if not show_desktop and device['type'] == 'DESKTOP_APP': continue if not show_mobile and device['type'] == 'PHONE': continue print(u'* {dname} ({type}): {id}'.format(dname=dname, **device))