Beispiel #1
0
 def search_getResults(self, **ka):
     self._check_ka(ka, ['query'], ['type', 'limit', 'offset'])
     mandatory = ['query', 'type']
     for label in mandatory:
         if label not in ka:
             raise exception.MissingParameter(label)
     return self._api_request(ka, '/search/getResults')
Beispiel #2
0
 def playlist_subscribe(self, **ka):
     mandatory = ['playlist_id']
     found = None
     for label in mandatory:
         if label in ka:
             found = label
     if not found:
         raise exception.MissingParameter('playlist_id')
     return self._api_request(ka, '/playlist/subscribe')
Beispiel #3
0
 def favorite_delete(self, **ka):
     mandatory = ['artist_ids', 'album_ids', 'track_ids']
     found = None
     for label in mandatory:
         if label in ka:
             found = label
     if not found:
         raise exception.MissingParameter('artist_ids|albums_ids|track_ids')
     return self._api_request(ka, '/favorite/delete')
Beispiel #4
0
 def _check_ka(cls, ka, mandatory, allowed=None):
     '''Checking parameters before sending our request
     - if mandatory parameter is missing raise error
     - if a given parameter is neither in mandatory or allowed
     raise error (Creating exception class like MissingParameter
     may be a good idea)
     '''
     if allowed is None:
         allowed = []
     for label in mandatory:
         if label not in ka:
             raise exception.MissingParameter(label)
     for label in ka:
         if label not in mandatory and label not in allowed:
             raise exception.InvalidParameter(label)
 def add(self, **ka):
     """Add menu entry
         Parameters:
             path: string, <section>/<id> (id juste need to be unique)
             cmd: string, xbmc command to run
             color: string, override default color
             pos: int, position in menu
     """
     for key in ['label', 'cmd']:
         if key not in ka:
             raise exception.MissingParameter(key)
     section, path = self.get_section_path(**ka)
     root = self.data
     pos = 0
     if 'pos' in ka:
         pos = ka['pos']
     cmd = ''
     if 'cmd' in ka:
         cmd = ka['cmd']
     color = ''
     if 'color' in ka:
         color = ka['color']
     if section not in root:
         root[section] = {
             'label': section,
             'childs': [],
             'pos': pos,
             'cmd': cmd,
             'color': color
         }
     if not path:
         root[section]['label'] = ka['label']
         root[section]['cmd'] = cmd
         root[section]['pos'] = pos
         root[section]['color'] = color
     else:
         item = {
             'label': ka['label'],
             'cmd': cmd,
             'pos': pos,
             'color': color
         }
         root[section]['childs'].append(item)
     return root
Beispiel #6
0
 def playlist_delete(self, **ka):
     self._check_ka(ka, ['playlist_id'])
     if 'playlist_id' not in ka:
         raise exception.MissingParameter('playlist_id')
     return self._api_request(ka, '/playlist/delete')
Beispiel #7
0
 def send(cls, request):
     if not request:
         raise exception.MissingParameter('equest')
     return JsonResponse(xbmc.executeJSONRPC(request.to_json()))