Skip to content

Commit

Permalink
Merge branch 'master' into proxy-url
Browse files Browse the repository at this point in the history
  • Loading branch information
vicwomg authored Mar 6, 2024
2 parents abc4a60 + 5d49929 commit 0136d42
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 33 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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:

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
36 changes: 16 additions & 20 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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",
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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'])
Expand Down
4 changes: 2 additions & 2 deletions constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION = "1.1.2"
VERSION = "1.2"
LANGUAGES = {
"en": "English",
"zh_CN": "Chinese",
"pt_BR": "Brazilian Portuguese",
}
}
11 changes: 6 additions & 5 deletions karaoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(
url=None,
ffmpeg_url=None,
prefer_ip=False
prefer_hostname=True
):

# override with supplied constructor args if provided
Expand All @@ -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()
Expand All @@ -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}
Expand Down Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CherryPy
Flask
Flask==2.2.5
qrcode
psutil
unidecode
Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ***"
Expand Down

0 comments on commit 0136d42

Please sign in to comment.