Fetch and parse the service search category mapping.

        Standard Sonos search categories are 'all', 'artists', 'albums',
        'tracks', 'playlists', 'genres', 'stations', 'tags'. Not all are
        available for each music service
352699
def _get_search_prefix_map(self):
        
        # TuneIn does not have a pmap. Its search keys are is search:station,
        # search:show, search:host

        # Presentation maps can also define custom categories. See eg
        # http://sonos-pmap.ws.sonos.com/hypemachine_pmap.6.xml
        # <SearchCategories>
        # ...
        #     <CustomCategory mappedId="SBLG" stringId="Blogs"/>
        # </SearchCategories>
        # Is it already cached? If so, return it
        if self._search_prefix_map is not None:
            return self._search_prefix_map
        # Not cached. Fetch and parse presentation map
        self._search_prefix_map = {}
        # Tunein is a special case. It has no pmap, but supports searching
        if self.service_name == "TuneIn":
            self._search_prefix_map = {
                'stations': 'search:station',
                'shows': 'search:show',
                'hosts': 'search:host',
            }
            return self._search_prefix_map
        if self.presentation_map_uri is None:
            # Assume not searchable?
            return self._search_prefix_map
        log.info('Fetching presentation map from %s',
                 self.presentation_map_uri)
        pmap = requests.get(self.presentation_map_uri, timeout=9)
        pmap_root = XML.fromstring(pmap.content)
        # Search translations can appear in Category or CustomCategory elements
        categories = pmap_root.findall(".//SearchCategories/Category")
        if categories is None:
            return self._search_prefix_map
        for cat in categories:
            self._search_prefix_map[cat.get('id')] = cat.get('mappedId')
        custom_categories = pmap_root.findall(
            ".//SearchCategories/CustomCategory")
        for cat in custom_categories:
            self._search_prefix_map[cat.get('stringId')] = cat.get('mappedId')
        return self._search_prefix_map
845639
def find_category(category_name, options = {})
      categories = self.categories
      if categories.is_a?(Array)
        categories.detect { |c| c['name'] == category_name }
      else
        raise "Could not retrieve categories: #{categories}"
      end
    end
594603
def songs(options = {page: 1})
      songs_url = "/artists/#{@id}/songs/?page=#{options[:page]}"

      fetch(songs_url)["response"]["songs"].map do |song|
        Song.new(
          artist: Artist.new(
            name: song["primary_artist"]["name"],
            id: song["primary_artist"]["id"],
            type: :primary
          ),
          title: song["title"],
          id: song["id"]
        )
      end
    end
1106766
function extractServices(search, services) {
  if (!search) { return; }

  if (Array.isArray(search)) {
    // We got passed an array of nodes, process each one individualy
    search.forEach(function (item) {
      extractServices(item, services);
    });
  }

  else if (search.dir) {
    // We are a directory, recurse with the nodes
    extractServices(search.nodes, services);
  }

  else if (search.node) {
    // We are at the root of the search, recurse with the node's result
    extractServices(search.node, services);
  }

  else if (search.value) {
    // We are finaly at a leaf, extract the service info
    services[search.key] = search.value;
  }

  return;
}
16307
def get_categories(self):
        
        sdb_resp = get_with_retry(self.cerberus_url + '/v1/category',
                                headers=self.HEADERS)

        throw_if_bad_response(sdb_resp)
        return sdb_resp.json()
72356
def get_sonos_favorites(self, start=0, max_items=100):
        
        message = 'The output type of this method will probably change in '\
                  'the future to use SoCo data structures'
        warnings.warn(message, stacklevel=2)
        return self.__get_favorites(SONOS_FAVORITES, start, max_items)
483966
def playlist(self, playlist_id):
        '''
        
        '''
        playlist = self.connection.request(
            'getPlaylistByID',
            {'playlistID': playlist_id},
            self.connection.header('getPlaylistByID'))[1]
        return self._parse_playlist(playlist)
649187
function(category, filter) {
            var r = [];
            for (var i in this.registered_node_types) {
                var type = this.registered_node_types[i];
                if (filter && type.filter && type.filter != filter) {
                    continue;
                }

                if (category == "") {
                    if (type.category == null) {
                        r.push(type);
                    }
                } else if (type.category == category) {
                    r.push(type);
                }
            }

            return r;
        }
651205
def service_search(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_operator_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.search_services(**kwargs)
305954
@Override
    public Categories getCategories(final AtomRequest areq) throws AtomException {
        LOG.debug("getCollection");
        final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
        final String handle = pathInfo[0];
        final String collection = pathInfo[1];
        final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
        return col.getCategories(true).get(0);
    }
1111587
def get_categories(self, entry):
        
        try:
            return format_html_join(
                ', ', '<a href="{}" target="blank">{}</a>',
                [(category.get_absolute_url(), category.title)
                 for category in entry.categories.all()])
        except NoReverseMatch:
            return ', '.join([conditional_escape(category.title)
                              for category in entry.categories.all()])
1107943
def obtain_category(check = nil)
      segments = []
      if check.blank?
        return nil if  params[:slug].blank?
        segments = params[:slug].split('/')
      end

      # get the taxonomy name and search the database for the record with this as its slug
      t = obtain_term_check(check, segments, 'category')
      t if !t.blank?
    end
532572
function() {
      var categoriesDict = {};
      this.device.addCategoriesToDict(categoriesDict);
      this.kernel.addCategoriesToDict(categoriesDict);
      for (var pid in this.processes)
        this.processes[pid].addCategoriesToDict(categoriesDict);

      this.categories = [];
      for (var category in categoriesDict)
        if (category != '')
          this.categories.push(category);
    }
414662
def get_playlists(self, search, start=0, max_items=100):
        
        return self.get_music_service_information('playlists', search, start,
                                                  max_items)
599318
def list_categories(location_id, opts = {})
      data, _status_code, _headers = list_categories_with_http_info(location_id, opts)
      return data
    end
411194
def get_services(self, poc="lab"):
        
        bsc = api.get_tool("bika_setup_catalog")
        query = {
            "portal_type": "AnalysisService",
            "getPointOfCapture": poc,
            "is_active": True,
            "sort_on": "sortable_title",
        }
        services = bsc(query)
        categories = self.get_service_categories(restricted=False)
        analyses = {key: [] for key in map(lambda c: c.Title, categories)}

        # append the empty category as well
        analyses[""] = []

        for brain in services:
            category = brain.getCategoryTitle
            if category in analyses:
                analyses[category].append(brain)
        return analyses
879023
function categories() {
  return getCategories()
    .then((body) => {
      const $ = cheerio.load(body, { normalizeWhitespace: false });

      return Promise.resolve($('div.tagcloud01 ul li a').get().map(el => el.children[0].data));
    })
    .catch(err => err);
}