Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A lot of improvements, fixes and polishing #3

Open
wants to merge 41 commits into
base: master
Choose a base branch
from

Conversation

firetech
Copy link
Contributor

@firetech firetech commented May 6, 2023

  • Switch to yt-dlp as youtube-dl is abandoned and now broken.
  • Make startup.sh executable.
  • Use tempfile.mkstemp() for uploaded files.
  • Handle (and show) upload errors without closing websocket connection.
  • Go to next song when playing fails, instead of just going silent until an admin skips.
  • Remove all uploaded files on SIGINT/SIGTERM, and actually exit, without requiring a second signal.
  • Add "c" and "p" as console commands, for clearing the queue and pausing/unpausing, respectively.
  • Use new in-page error message instead of alert().
  • Attempt to preserve upload order when uploading multiple files (read commit message in c6f97ba for details).
  • Increase max upload size to 1GB (from the 100MB default), and read/write file uploads in chunks, reducing memory usage for large uploaded files.
  • Allow video/* file uploads (since at least Firefox identifies OGG audio files as video/ogg) and move type checks to backend.
  • Handle some common issues with drag & drop handling, modernizing the drag & drop JS while at it.
  • Fix some issues caused by slightly improper thread handling (tornado isn't thread-safe).
  • Show skip button based on IP from backend, instead of nick (actually matching what the backend allows you to do).
  • Attempt to automatically reconnect websocket on failure.
  • Add startup options for HTTP server port and bind IP, and support using X-Forwarded-For header instead of actual client IP (for use when running reverse proxied through another HTTP server to get around permission issues).
  • Improve drag & drop overlay logic, it tended to get stuck in some situations.
  • Add file/link upload buttons, for (at least some) compatibility with mobile browsers, and add meta tag to trigger mobile browsers into rendering more mobile-friendly.
  • Extract stream URLs for links just before playing, instead of when adding (Soundcloud URLs seem to be time-limited).
  • Reduce number of unnecessarily generated random numbers in dubstep playing logic.
  • Queue up WebSocket messages while socket is down, send them when it gets back up.
  • Add script to install as a system service.
  • Add Chromecast output support (if pychromecast is installed).
  • Add a favicon.

firetech added 21 commits May 6, 2023 13:29
Avoids clogging the file system long time when the system is restarted.
Instead of going silent.
Remove all uploaded files on SIGINT/SIGTERM, and actually exit, without
requiring a second signal.

Also:
* Restructure main program flow slightly (to enable the above).
* Add "c" as new console command, for clearing the queue.
File uploads will get a semi-random ID attached to them, with subsequent
files referencing that ID as "parent", when adding files to the juggler,
and the parent ID isn't in the list yet, the file will wait for the
parent to be added first, for up to 30 seconds. If the 30 seconds pass,
the file will not be added.
At least Firefox identifies .ogg as video/ogg, even if it's only audio.
Tornado isn't thread safe, and pushing messages from any thread causes a
lot of error messages in the log, especially when stopping the server.
Specifically handle issues where the browser fails to include any data
in the drag, but also modernizes the drag and drop code.
Changes song identifier to a UUID, and reduces the amount of data sent
to the client. Also queued links are downloaded through the new
/download endpoint, making it possible to avoid double-queueing by
accidentally dragging the download links.
Actually matching what the backend allows you to do. The backend will
tell you what it thinks your IP is on connection.
* Port number (default 80)
* Bind IP (default any)
* Option to use X-Forwarded-For header instead of actual client IP.
  (usable if running reverse proxied to get around permission issues).

Also some minor restructuring to handle startup errors (unable to bind
to the HTTP server port, specifically) without starting the player, and
remove implicit sudo from startup.sh.
Now uses the path instead of a query param to supply the id, and
includes the file extension in the id to improve compatibility with wget
and similar tools.
* Between [X] and song link.
* Between nick and IP.
firetech added 8 commits May 8, 2023 22:27
Could get stuck in some situations.
Mainly intended for mobile browsers.
Refactors upload handling to handle this cleaner.
It seems the URLs extracted by yt-dlp for at least Soundcloud links are
time-limited, so extracting them when adding and not using them until
possibly much later doesn't work.

To solve this, fetch the URL from yt-dlp just before playing instead.
Was generating (unused) random numbers a bit too often.
Send them when it's up again.
Makes it possible to load changes to index.html without restarting
backend. Leaving it enabled causes unnecessary load, though.
firetech added 8 commits May 9, 2023 22:42
Move start and stop code to functions outside "__main__" block.
Same issue as in 7a6920c, where it wasn't properly solved.
* No reason to create Media objects when MediaPlayer.set_mrl works just
  as well.
* Prefix all internal attributes with _ (or just make them local
  variables in some cases).
* Move static media MRLs to class constants.
If pychromecast is installed (handled cleanly if not installed), two new
options are available:
* -C/--chromecast-list for listing available Chromecasts (and -groups).
* -c/--chromecast for selecting a Chromecast (or -group) to cast to.

With -c, VLC's Chromecast support is used for the actual casting.
Was a known issue, just didn't matter until now.
@firetech firetech changed the title A number of improvements, fixes and polishing A lot of improvements, fixes and polishing May 13, 2023
firetech added 4 commits May 13, 2023 11:37
* Switch to PUT requests, which is more appropriate for the format.
* Use @stream_request_body to read and write uploaded file in chunks,
  reducing memory usage for large files.
* Increase max file size to 1GiB, but also don't allow files to fill
  more than half of remaining free space in temporary storage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant