Skip to content

Commit

Permalink
vicwomg#312 - default to IP url, fix Flask deps, fix ubuntu detection
Browse files Browse the repository at this point in the history
  • Loading branch information
vicwomg committed Jan 7, 2024
1 parent c10348d commit 1c016f6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 31 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,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
26 changes: 5 additions & 21 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 Down Expand Up @@ -736,9 +719,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 @@ -833,7 +817,7 @@ def get_default_dl_dir(platform):
hide_overlay=args.hide_overlay,
screensaver_timeout=args.screensaver_timeout,
url=args.url,
prefer_ip=args.prefer_ip
prefer_hostname=args.prefer_hostname
)

# Start the CherryPy WSGI web server
Expand Down
12 changes: 6 additions & 6 deletions karaoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(
hide_overlay=False,
screensaver_timeout = 300,
url=None,
prefer_ip=False
prefer_hostname=True
):

# override with supplied constructor args if provided
Expand All @@ -93,7 +93,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 @@ -110,7 +110,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 @@ -146,10 +146,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)

# get songs from download_path
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) != "" ]]; then
echo "Client is a Debian-based system. Installing binaries";
echo
echo "*** RUNNING APT-GET UPDATE ***"
Expand Down

0 comments on commit 1c016f6

Please sign in to comment.