def METHOD_NAME(self):
    if not self.config.startswith(("http://", "https://")):
        # interpret location as keywords
        self.api_url = API_SAFE_SEARCH_URL % self.config
    else:
        # location is an URL, use it
        url = self.config.replace("http://", "https://")
        # Use Wallhaven API
        if url.startswith(API_SEARCH):
            self.api_url = url
        elif url.startswith(WEB_DOMAIN_SEARCH):
            self.api_url = url.replace(WEB_DOMAIN_SEARCH, API_SEARCH)
        elif url.startswith("https://wallhaven.cc/tag"):
            self.api_url = url.replace(
                "https://wallhaven.cc/tag/", "https://wallhaven.cc/api/v1/search?q=id:"
            )
        else:
            # we'll fallback to WallhavenLegacyDownloader
            self.api_url = None
    # make sure we use the API key, if provided
    if self.api_url and self.api_key and "&apikey=" not in self.api_url:
        self.api_url += "&apikey=" + self.api_key