web
Module which contains the web server related function FastAPI routes/classes etc.
ApplicationState
¤
Class that holds the application state.
Client(client_id)
¤
Holds the client's state.
- websocket: The WebSocket instance.
- client_id: The client's ID.
- downloader_settings: The downloader settings.
Source code in spotdl/utils/web.py
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 | |
connect()
async
¤
Called when a new client connects to the websocket.
Source code in spotdl/utils/web.py
121 122 123 124 125 126 127 128 129 130 131 132 133 | |
disconnect()
async
¤
Called when a client disconnects from the websocket.
Source code in spotdl/utils/web.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
disconnect_now()
¤
Disconnect the client.
Source code in spotdl/utils/web.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
get_instance(client_id)
classmethod
¤
Get the WebSocket instance for a client.
Arguments¤
- client_id: The client's ID.
Returns¤
- returns the WebSocket instance.
Source code in spotdl/utils/web.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
send_update(update)
async
¤
Send an update to the client.
Arguments¤
- update: The update to send.
Source code in spotdl/utils/web.py
166 167 168 169 170 171 172 | |
song_update(progress_handler, message)
¤
Called when a song updates.
Arguments¤
- progress_handler: The progress handler.
- message: The message to send.
Source code in spotdl/utils/web.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
SPAStaticFiles
¤
Bases: StaticFiles
Override the static files to serve the index.html and other assets.
get_response(path, scope)
async
¤
Serve static files from the SPA.
Arguments¤
- path: The path to the file.
- scope: The scope of the request.
Returns¤
- returns the response.
Source code in spotdl/utils/web.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
fix_mime_types()
¤
Fix incorrect entries in the mimetypes registry.
On Windows, the Python standard library's mimetypes reads in
mappings from file extension to MIME type from the Windows
registry. Other applications can and do write incorrect values
to this registry, which causes mimetypes.guess_type to return
incorrect values, which causes spotDL to fail to render on
the frontend.
This method hard-codes the correct mappings for certain MIME
types that are known to be either used by TensorBoard or
problematic in general.
Source code in spotdl/utils/web.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
get_client(client_id=Query(default=None))
¤
Get the client's state.
Arguments¤
- client_id: The client's ID.
Returns¤
- returns the client's state.
Source code in spotdl/utils/web.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
get_current_state()
¤
Get the current state of the application.
Returns¤
- returns the application state.
Source code in spotdl/utils/web.py
237 238 239 240 241 242 243 244 245 | |
validate_search_term(search_term)
¤
Validate the search term to check if it is a valid Spotify URL.
Arguments¤
- search_term: The search term to validate.
Returns¤
- True if the search term is valid, False otherwise.
Source code in spotdl/utils/web.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |