1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
from gi.repository import Accounts
manager = Accounts.Manager.new_for_service_type("scrobbling")
# Monitor the creation/deletion/enabling of accounts
def on_enabled_event(manager, account_id):
account = manager.load_account(account_id)
for service in account.list_services():
account_service = Accounts.AccountService.new(account, service)
if account_service.get_enabled():
# handle the account
pass
manager.connect("enabled-event", on_enabled_event)
# Get the list of all the enabled accounts which support the
# "scrobbling" service type
for account_service in manager.get_enabled_account_services():
display_name = account_service.get_account().get_display_name()
provider_name = account_service.get_account().get_provider_name()
service_name = account_service.get_service().get_name()
print("Account %s - provider %s, service %s" %
(display_name, provider_name, service_name))
|