tuijam-get-dev-id 737 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python3
  2. from gmusicapi import Mobileclient
  3. from os.path import join, expanduser
  4. import yaml
  5. config_file = join(expanduser('~'), '.config', 'tuijam', 'config.yaml')
  6. try:
  7. with open(config_file) as f:
  8. config = yaml.load(f.read())
  9. email = config['email']
  10. password = config['password']
  11. except Exception:
  12. raise ValueError('Invalid config file! Check README!')
  13. mc = Mobileclient()
  14. if not mc.login(email, password, mc.FROM_MAC_ADDRESS):
  15. print('Login failed, verify your email and password.')
  16. exit(1)
  17. for i, id in enumerate([
  18. d['id'][2:] if d['id'].startswith('0x') else d['id'].replace(':', '') # noqa
  19. for d in mc.get_registered_devices()
  20. ]):
  21. print('%d: %s' % (i + 1, id))