web
Module which contains the web server related function FastAPI routes/classes etc.
ApplicationState
¤
Class that holds the application state.
Client(websocket, 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
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 130 131 132 |
|
connect()
async
¤
Called when a new client connects to the websocket.
Source code in spotdl/utils/web.py
134 135 136 137 138 139 140 141 142 143 |
|
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
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
send_update(update)
async
¤
Send an update to the client.
Arguments¤
- update: The update to send.
Source code in spotdl/utils/web.py
145 146 147 148 149 150 151 152 153 |
|
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
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
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
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
check_update()
¤
Check for update.
Returns¤
- returns True if there is an update.
Source code in spotdl/utils/web.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
|
download_file(file, client=Depends(get_client), state=Depends(get_current_state))
async
¤
Download file using path.
Arguments¤
- file: The file path.
- client: The client's state.
Returns¤
- returns the file response, filename specified to return as attachment.
Source code in spotdl/utils/web.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
|
download_url(url, client=Depends(get_client), state=Depends(get_current_state))
async
¤
Download songs using Song url.
Arguments¤
- url: The url to download.
Returns¤
- returns the file path if the song was downloaded.
Source code in spotdl/utils/web.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
|
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
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
|
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
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
get_current_state()
¤
Get the current state of the application.
Returns¤
- returns the application state.
Source code in spotdl/utils/web.py
213 214 215 216 217 218 219 220 221 |
|
get_options()
¤
Get options model (possible settings).
Returns¤
- returns the options.
Source code in spotdl/utils/web.py
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 |
|
get_settings(client=Depends(get_client))
¤
Get client settings.
Arguments¤
- client: The client's state.
Returns¤
- returns the settings.
Source code in spotdl/utils/web.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
|
query_search(query)
¤
Parse search term and return list of Song objects.
Arguments¤
- query: The query to parse.
Returns¤
- returns a list of Song objects.
Source code in spotdl/utils/web.py
316 317 318 319 320 321 322 323 324 325 326 327 328 |
|
shutdown_event()
async
¤
Called when the server is shutting down.
Source code in spotdl/utils/web.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
song_from_url(url)
¤
Search for a song on spotify using url.
Arguments¤
- url: The url to search.
Returns¤
- returns the first result as a Song object.
Source code in spotdl/utils/web.py
285 286 287 288 289 290 291 292 293 294 295 296 297 |
|
update_settings(settings, client=Depends(get_client), state=Depends(get_current_state))
¤
Update client settings, and re-initialize downloader.
Arguments¤
- settings: The settings to change.
- client: The client's state.
- state: The application state.
Returns¤
- returns True if the settings were changed.
Source code in spotdl/utils/web.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
|
websocket_endpoint(websocket, client_id)
async
¤
Websocket endpoint.
Arguments¤
- websocket: The WebSocket instance.
Source code in spotdl/utils/web.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
|