Skip to content

Commit

Permalink
Merge pull request #301 from nathanpalmer/proxy-url
Browse files Browse the repository at this point in the history
Adding an ffmpeg url parameter
  • Loading branch information
vicwomg authored Mar 6, 2024
2 parents 5d49929 + b33d734 commit 0b2e89c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,13 @@ def get_default_dl_dir(platform):
default=None,
required=False,
),
parser.add_argument(
"-m",
"--ffmpeg-url",
help="Override the ffmpeg address with a supplied URL.",
default=None,
required=False,
),
parser.add_argument(
"--hide-overlay",
action="store_true",
Expand Down Expand Up @@ -823,6 +830,7 @@ def get_default_dl_dir(platform):
hide_overlay=args.hide_overlay,
screensaver_timeout=args.screensaver_timeout,
url=args.url,
ffmpeg_url=args.ffmpeg_url,
prefer_hostname=args.prefer_hostname
)

Expand Down
7 changes: 6 additions & 1 deletion karaoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(
hide_overlay=False,
screensaver_timeout = 300,
url=None,
ffmpeg_url=None,
prefer_hostname=True
):

Expand Down Expand Up @@ -151,6 +152,10 @@ def __init__(
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}"
else:
self.ffmpeg_url = ffmpeg_url

# get songs from download_path
self.get_available_songs()
Expand Down Expand Up @@ -360,7 +365,7 @@ def get_youtube_id_from_url(self, url):
def play_file(self, file_path, semitones=0):
logging.info(f"Playing file: {file_path} transposed {semitones} semitones")
stream_uid = int(time.time())
stream_url = f"{self.url_parsed.scheme}://{self.url_parsed.hostname}:{self.ffmpeg_port}/{stream_uid}"
stream_url = f"{self.ffmpeg_url}/{stream_uid}"
# pass a 0.0.0.0 IP to ffmpeg which will work for both hostnames and direct IP access
ffmpeg_url = f"http://0.0.0.0:{self.ffmpeg_port}/{stream_uid}"

Expand Down

0 comments on commit 0b2e89c

Please sign in to comment.