Skip to content

sliderkz

SliderKZ module for downloading and searching songs.

SliderKZ(output_format='mp3', cookie_file=None, search_query=None, filter_results=True, yt_dlp_args=None) ¤

Bases: AudioProvider

Slider.kz audio provider class

Source code in spotdl/providers/audio/base.py
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
def __init__(
    self,
    output_format: str = "mp3",
    cookie_file: Optional[str] = None,
    search_query: Optional[str] = None,
    filter_results: bool = True,
    yt_dlp_args: Optional[str] = None,
) -> None:
    """
    Base class for audio providers.

    ### Arguments
    - output_directory: The directory to save the downloaded songs to.
    - output_format: The format to save the downloaded songs in.
    - cookie_file: The path to a file containing cookies to be used by YTDL.
    - search_query: The query to use when searching for songs.
    - filter_results: Whether to filter results.
    """

    self.output_format = output_format
    self.cookie_file = cookie_file
    self.search_query = search_query
    self.filter_results = filter_results

    if self.output_format == "m4a":
        ytdl_format = "bestaudio[ext=m4a]/bestaudio/best"
    elif self.output_format == "opus":
        ytdl_format = "bestaudio[ext=webm]/bestaudio/best"
    else:
        ytdl_format = "bestaudio/best"

    yt_dlp_options = {
        "format": ytdl_format,
        "quiet": True,
        "no_warnings": True,
        "encoding": "UTF-8",
        "logger": YTDLLogger(),
        "cookiefile": self.cookie_file,
        "outtmpl": str((get_temp_path() / "%(id)s.%(ext)s").resolve()),
        "retries": 5,
        "extractor_args": {},
    }

    yt_dlp_options.update(get_local_deno_yt_dlp_options())

    if yt_dlp_args:
        yt_dlp_options = args_to_ytdlp_options(
            shlex.split(yt_dlp_args), yt_dlp_options
        )

    self.audio_handler = YoutubeDL(yt_dlp_options)

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
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
93
94
95
96
97
98
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://hayqbhgr.slider.kz/vk_auth.php?q=" + search_term,
                headers=HEADERS,
                timeout=5,
                proxies=GlobalConfig.get_parameter("proxies"),
            )

            # 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://hayqbhgr.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