diff --git a/README.md b/README.md index e3bd7806..104e9389 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ Install git, if you haven't already. Install python3/pip3 (usually raspberry pi OS already has it, run `python3 --version` to check): https://www.python.org/downloads/ +Python >= 3.8 is necessary Clone this repo: @@ -90,11 +91,13 @@ Run the setup script to install dependencies and set up the python env: If you're on a raspberry pi or debian system the setup script should have handled installing ffmpeg via apt. -If you're on OSX or another Linux distro, manually install FFMPEG from here: https://ffmpeg.org/download.html +If you're on OSX or another Linux distro, manually install FFMPEG 6.0 or greater from here: https://ffmpeg.org/download.html + +On Ubuntu, apt seemed to keep installing an old 4.X version of ffmpeg. I found better luck grabbing a pre-built version of ffmpeg 6.0+ and manually copying it to /usr/bin/. Pre-built releases were obtained from this repo: https://github.com/BtbN/FFmpeg-Builds/releases ### Windows -Manually install ffmpeg https://ffmpeg.org/download.html +Manually install ffmpeg 6.0 or greater https://ffmpeg.org/download.html Run the setup script to install python dependencies: @@ -147,7 +150,7 @@ May not be up to date, run `python3 app.py --help` for the latest: ``` usage: app.py [-h] [-p PORT] [-f FFMPEG_PORT] [-d DOWNLOAD_PATH] [-y YOUTUBEDL_PATH] [-v VOLUME] [-s SPLASH_DELAY] [-t SCREENSAVER_TIMEOUT] [-l LOG_LEVEL] [--hide-url] [--prefer-ip] [--hide-raspiwifi-instructions] [--hide-splash-screen] [--dual-screen] [--high-quality] - [--logo-path LOGO_PATH] [-u URL] [--hide-overlay] [--admin-password ADMIN_PASSWORD] + [--logo-path LOGO_PATH] [-u URL] [--hide-overlay] [--admin-password ADMIN_PASSWORD] [--window-size WIDTH,HEIGHT] options: -h, --help show this help message and exit @@ -167,7 +170,8 @@ options: -l LOG_LEVEL, --log-level LOG_LEVEL Logging level int value (DEBUG: 10, INFO: 20, WARNING: 30, ERROR: 40, CRITICAL: 50). (default: 20 ) --hide-url Hide URL and QR code from the splash screen. - --prefer-ip Show the IP instead of the fully qualified local domain name. Default: False + --prefer-hostname Use the local hostname instead of the IP as the connection URL. Use at your discretion: mDNS is not guaranteed to work on all + LAN configurations. Defaults to False --hide-raspiwifi-instructions Hide RaspiWiFi setup instructions from the splash screen. --hide-splash-screen, --headless @@ -180,6 +184,8 @@ options: --admin-password ADMIN_PASSWORD Administrator password, for locking down certain features of the web UI such as queue editing, player controls, song editing, and system shutdown. If unspecified, everyone is an admin. + --window-size WIDTH,HEIGHT + Explicitly set the width and height of the splash screen, where the WIDTH and HEIGHT values are specified in pixels. ``` ## Troubleshooting diff --git a/app.py b/app.py index 8201e369..13f9145b 100644 --- a/app.py +++ b/app.py @@ -616,23 +616,6 @@ def get_default_youtube_dl_path(platform): if platform == "windows": return os.path.join(os.path.dirname(__file__), ".venv\Scripts\yt-dlp.exe") return os.path.join(os.path.dirname(__file__), ".venv/bin/yt-dlp") - # if platform == "windows": - # choco_ytdl_path = r"C:\ProgramData\chocolatey\bin\yt-dlp.exe" - # scoop_ytdl_path = os.path.expanduser(r"~\scoop\shims\yt-dlp.exe") - # if os.path.isfile(choco_ytdl_path): - # return choco_ytdl_path - # if os.path.isfile(scoop_ytdl_path): - # return scoop_ytdl_path - # return r"C:\Program Files\yt-dlp\yt-dlp.exe" - # default_ytdl_unix_path = "/usr/local/bin/yt-dlp" - # if platform == "osx": - # if os.path.isfile(default_ytdl_unix_path): - # return default_ytdl_unix_path - # else: - # # just a guess based on the default python 3 install in OSX monterey - # return "/Library/Frameworks/Python.framework/Versions/3.10/bin/yt-dlp" - # else: - # return default_ytdl_unix_path def get_default_dl_dir(platform): @@ -661,7 +644,7 @@ def get_default_dl_dir(platform): default_splash_delay = 3 default_screensaver_delay = 300 default_log_level = logging.INFO - default_prefer_ip = False + default_prefer_hostname = False default_dl_dir = get_default_dl_dir(platform) default_youtubedl_path = get_default_youtube_dl_path(platform) @@ -676,6 +659,12 @@ def get_default_dl_dir(platform): default=default_port, required=False, ) + parser.add_argument( + "--window-size", + help="Desired window geometry in pixels, specified as width,height", + default=0, + required=False, + ) parser.add_argument( "-f", "--ffmpeg-port", @@ -736,9 +725,10 @@ def get_default_dl_dir(platform): required=False, ) parser.add_argument( - "--prefer-ip", + "--prefer-hostname", action="store_true", - help=f"Show the IP instead of the fully qualified local domain name. Default: {default_prefer_ip}", + help=f"Use the local hostname instead of the IP as the connection URL. Use at your discretion: mDNS is not guaranteed to work on all LAN configurations. Defaults to {default_prefer_hostname}", + default=default_prefer_hostname, required=False, ) parser.add_argument( @@ -842,6 +832,7 @@ def get_default_dl_dir(platform): url=args.url, ffmpeg_url=args.ffmpeg_url, prefer_ip=args.prefer_ip + prefer_hostname=args.prefer_hostname ) # Start the CherryPy WSGI web server @@ -865,6 +856,11 @@ def get_default_dl_dir(platform): else: service = None options = Options() + + if args.window_size: + options.add_argument("--window-size=%s" % (args.window_size)) + options.add_argument("--window-position=0,0") + options.add_argument("--kiosk") options.add_argument("--start-maximized") options.add_experimental_option("excludeSwitches", ['enable-automation']) diff --git a/constants.py b/constants.py index 9a8138ee..49bb2b2a 100644 --- a/constants.py +++ b/constants.py @@ -1,6 +1,6 @@ -VERSION = "1.1.2" +VERSION = "1.2" LANGUAGES = { "en": "English", "zh_CN": "Chinese", "pt_BR": "Brazilian Portuguese", -} \ No newline at end of file +} diff --git a/karaoke.py b/karaoke.py index f86415da..712e84e4 100644 --- a/karaoke.py +++ b/karaoke.py @@ -77,6 +77,7 @@ def __init__( url=None, ffmpeg_url=None, prefer_ip=False + prefer_hostname=True ): # override with supplied constructor args if provided @@ -94,7 +95,7 @@ def __init__( self.hide_overlay = hide_overlay self.screensaver_timeout = screensaver_timeout self.url_override = url - self.prefer_ip = prefer_ip + self.prefer_hostname = prefer_hostname # other initializations self.platform = get_platform() @@ -111,7 +112,7 @@ def __init__( http port: {self.port} ffmpeg port {self.ffmpeg_port} hide URL: {self.hide_url} - prefer IP: {self.prefer_ip} + prefer hostname: {self.prefer_hostname} url override: {self.url_override} hide RaspiWiFi instructions: {self.hide_raspiwifi_instructions} headless (hide splash): {self.hide_splash_screen} @@ -147,10 +148,10 @@ def __init__( logging.debug("Overriding URL with " + self.url_override) self.url = self.url_override else: - if (self.prefer_ip): - self.url = f"http://{self.ip}:{self.port}" - else: + if (self.prefer_hostname): self.url = f"http://{socket.getfqdn().lower()}:{self.port}" + else: + self.url = f"http://{self.ip}:{self.port}" self.url_parsed = urlparse(self.url) if ffmpeg_url is None: self.ffmpeg_url = f"{self.url_parsed.scheme}://{self.url_parsed.hostname}:{self.ffmpeg_port}" diff --git a/requirements.txt b/requirements.txt index 427cce04..0ae75548 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ CherryPy -Flask +Flask==2.2.5 qrcode psutil unidecode diff --git a/setup.sh b/setup.sh index ce8fc2b5..f85042a9 100755 --- a/setup.sh +++ b/setup.sh @@ -6,7 +6,7 @@ if [ $REPLY = "y" ] ## setup stuff -if [[ $(cat /etc/os-release | grep -i debian) != "" ]]; then +if [[ $(cat /etc/os-release | grep ^ID= | grep -i 'debian\|raspbian') != "" ]]; then echo "Client is a Debian-based system. Installing binaries"; echo echo "*** RUNNING APT-GET UPDATE ***"