def __init__(self, soco, username, service_type): super(DeezerSocoPlugin, self).__init__(soco) account = Account() account.username = username account.service_type = service_type self.__ms = MusicService('Deezer', account=account) self.__dz = deezer.Client()
def __init__(self, service_name, account=None): """Initialise the instance. Args: service_name (str): The name of the music service, as returned by `get_all_music_services_names()`, eg 'Spotify', or 'TuneIn' account (Account): The account to use to access this service. If none is specified, one will be chosen automatically if possible. Raises: MusicServiceException """ self.service_name = service_name # Look up the data for this service data = self.get_data_for_name(service_name) self.uri = data['Uri'] self.secure_uri = data['SecureUri'] self.capabilities = data['Capabilities'] self.version = data['Version'] self.container_type = data['ContainerType'] self.service_id = data['Id'] # Auth_type can be 'Anonymous', 'UserId, 'DeviceLink' self.auth_type = data['Auth'] self.presentation_map_uri = data.get('PresentationMapUri', None) self._search_prefix_map = None self.service_type = data['ServiceType'] if account is not None: self.account = account elif service_name == "TuneIn": # TuneIn is always present, but will have no account data, so we # need to handle it specially. Create a dummy account self.account = Account() else: # try to find an account for this service for acct in Account.get_accounts().values(): if acct.service_type == self.service_type: self.account = acct break else: raise MusicServiceException( "No account found for service: '%s'" % service_name) self.soap_client = MusicServiceSoapClient( endpoint=self.secure_uri, timeout=9, # The default is 60 music_service=self)