Skip to content

sliderkz

SliderKZ module for downloading and searching songs.

SliderKZ ¤

Bases: AudioProvider

Slider.kz audio provider class

get_results(search_term, *_args, **_kwargs) ¤

Get results from slider.kz

Arguments¤
  • search_term: The search term to search for.
  • args: Unused.
  • kwargs: Unused.
Returns¤
  • A list of slider.kz results if found, None otherwise.
Source code in spotdl/providers/audio/sliderkz.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
def get_results(self, search_term: str, *_args, **_kwargs) -> List[Result]:
    """
    Get results from slider.kz

    ### Arguments
    - search_term: The search term to search for.
    - args: Unused.
    - kwargs: Unused.

    ### Returns
    - A list of slider.kz results if found, None otherwise.
    """

    search_results = None
    max_retries = 0

    while not search_results and max_retries < 3:
        try:
            search_response = requests.get(
                url="https://slider.kz/vk_auth.php?q=" + search_term,
                headers=HEADERS,
                timeout=5,
            )

            # Check if the response is valid
            if len(search_response.text) > 30:
                # Set the search results to the json response
                # effectively breaking out of the loop
                search_results = search_response.json()

        except Exception as exc:
            logger.debug(
                "Slider.kz search failed for query %s with error: %s. Retrying...",
                search_term,
                exc,
            )

        max_retries += 1

    if not search_results:
        logger.debug("Slider.kz search failed for query %s", search_term)
        return []

    results = []
    for result in search_results["audios"][""]:
        # urls from slider.kz sometimes are relative, so we need to add the domain
        if "https://" not in result["url"]:
            result["url"] = "https://slider.kz/" + result["url"]

        results.append(
            Result(
                source="slider.kz",
                url=result.get("url"),
                verified=False,
                name=result.get("tit_art"),
                duration=int(result.get("duration", -9999)),
                author="slider.kz",
                result_id=result.get("id"),
                views=1,
            )
        )

    return results