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

Release 1.6.2 dev #442

Merged
merged 7 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,22 @@ jobs:

- name: Publish Python 🐍 distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
tags: vicwomg/pikaraoke:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dist/
songs/
qrcode.png
.DS_Store
docker-compose.yml
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use bullseye over bookworm for better image size and ffmpeg compatibility
FROM python:3.12-slim-bullseye

# Install required packages
RUN apt-get update --allow-releaseinfo-change
RUN apt-get install ffmpeg wireless-tools -y

WORKDIR /app

# Copy minimum required files into the image
COPY pyproject.toml ./
COPY pikaraoke ./pikaraoke
COPY docs ./docs

# Install pikaraoke
RUN pip install .

COPY docker/entrypoint.sh ./
RUN chmod +x entrypoint.sh

ENTRYPOINT ["./entrypoint.sh"]
14 changes: 14 additions & 0 deletions docker/docker-compose.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
pikaraoke:
image: pikaraoke:latest
container_name: PiKaraoke
# Below Host network mode may work better on some systems and replace manual IP configuration. Does not work on OSX
# network_mode: host
environment:
EXTRA_ARGS: --url http://<YOUR_LAN_IP>:5555 # Replace with your LAN IP or DNS url, not necesary if using network_mode: host
volumes:
- </PATH/TO/LOCAL/SONGS/DIR>:/app/pikaraoke-songs # Replace with local dir. Insures your songs are persisted outside the container
restart: unless-stopped
ports:
- "5555:5555" # Forward the port for the web interface
- "5556:5556" # Forward the port for the ffmpeg video stream interface
7 changes: 7 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# Run pikaraoke with necessary parameters
pikaraoke -d /app/pikaraoke-songs/ --headless $EXTRA_ARGS

# Keep the container running
tail -f /dev/null
6 changes: 5 additions & 1 deletion pikaraoke/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def home():
title="Home",
transpose_value=k.now_playing_transpose,
admin=is_admin(),
is_transpose_enabled=k.is_transpose_enabled,
)


Expand Down Expand Up @@ -164,6 +165,7 @@ def nowplaying():
"is_paused": k.is_paused,
"transpose_value": k.now_playing_transpose,
"volume": k.volume,
# "is_transpose_enabled": k.is_transpose_enabled,
}
rc["hash"] = hash_dict(rc) # used to detect changes in the now playing data
return json.dumps(rc)
Expand Down Expand Up @@ -439,7 +441,8 @@ def start_song():
def delete_file():
if "song" in request.args:
song_path = request.args["song"]
if song_path in k.queue:
exists = any(item.get("file") == song_path for item in k.queue)
if exists:
flash(
"Error: Can't delete this song because it is in the current queue: " + song_path,
"is-danger",
Expand Down Expand Up @@ -582,6 +585,7 @@ def info():
cpu=cpu,
disk=disk,
ffmpeg_version=k.ffmpeg_version,
is_transpose_enabled=k.is_transpose_enabled,
youtubedl_version=youtubedl_version,
platform=k.platform,
os_version=k.os_version,
Expand Down
3 changes: 3 additions & 0 deletions pikaraoke/karaoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
get_os_version,
get_platform,
is_raspberry_pi,
is_transpose_enabled,
supports_hardware_h264_encoding,
)

Expand Down Expand Up @@ -66,6 +67,7 @@ class Karaoke:
ffmpeg_process = None
ffmpeg_log = None
ffmpeg_version = get_ffmpeg_version()
is_transpose_enabled = is_transpose_enabled()
supports_hardware_h264_encoding = supports_hardware_h264_encoding()
normalize_audio = False

Expand Down Expand Up @@ -144,6 +146,7 @@ def __init__(
platform: {self.platform}
os version: {self.os_version}
ffmpeg version: {self.ffmpeg_version}
ffmpeg transpose support: {self.is_transpose_enabled}
hardware h264 encoding: {self.supports_hardware_h264_encoding}
youtubedl-version: {self.get_youtubedl_version()}
"""
Expand Down
26 changes: 19 additions & 7 deletions pikaraoke/lib/get_platform.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import io
import os
import platform
import re
Expand All @@ -21,15 +22,26 @@ def get_ffmpeg_version():
return "Unable to parse FFmpeg version"


def is_raspberry_pi():
def is_transpose_enabled():
try:
return (
(os.uname()[4][:3] == "arm" or os.uname()[4] == "aarch64")
and sys.platform != "darwin"
and not is_android()
)
except AttributeError:
filters = subprocess.run(["ffmpeg", "-filters"], capture_output=True)
except FileNotFoundError:
# FFmpeg is not installed
return False
except IndexError:
# Unable to parse FFmpeg filters
return False
return "rubberband" in filters.stdout.decode()


def is_raspberry_pi():
try:
with io.open("/sys/firmware/devicetree/base/model", "r") as m:
if "raspberry pi" in m.read().lower():
return True
except Exception:
pass
return False


def is_android():
Expand Down
2 changes: 1 addition & 1 deletion pikaraoke/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@

{% if get_flashed_messages() %}
{% for category, message in get_flashed_messages(with_categories=true) %}
<div id="notification" class="notification {{category}}" style="display: none">
<div id="notification" class="notification {{category}}">
<button id="notification-close" class="delete"></button>
<div class="flash">{{ message }}</div>
</div>
Expand Down
8 changes: 6 additions & 2 deletions pikaraoke/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@
$(".control-box").hide();

var slider = document.getElementById("transpose");
console.log("slider returned: ", slider)
var output = document.getElementById("semitones-label");
if (slider) {
console.log("output returned: ", output)
if (slider && output) {
output.innerHTML = getSemitonesLabel(slider.value);
// Update the current slider value (each time you drag the slider handle)
slider.oninput = function () {
Expand Down Expand Up @@ -230,6 +232,8 @@ <h4>{% trans %}Player Control{% endtrans %}</h4>
</div>
</div>
<hr />

{% if is_transpose_enabled %}
<div class="is-flex" style="justify-content: space-between">
<div>
{# MSG: Title of a control to change the key/pitch of the playing song. #}
Expand All @@ -242,7 +246,6 @@ <h4 id="semitones-label"></h4>
></a>
</div>
</div>

<div style="width: 100%">
<div class="is-flex">
<input
Expand All @@ -265,6 +268,7 @@ <h4 id="semitones-label"></h4>
</button>
</div>
</div>
{% endif %}
</div>
{% endif %}

Expand Down
2 changes: 1 addition & 1 deletion pikaraoke/templates/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h1>{% trans %}System Info{% endtrans %}</h1>
{# MSG: The version of the program "Youtube-dl". #}
<li><u>{% trans %}Youtube-dl (yt-dlp) version:{% endtrans %}</u> {{ youtubedl_version }}</li>
{# MSG: The version of the program "ffmpeg". #}
<li><u>{% trans %}FFmpeg version:{% endtrans %}</u> {{ ffmpeg_version }}</li>
<li><u>{% trans %}FFmpeg version:{% endtrans %}</u> {{ ffmpeg_version }} {% if not is_transpose_enabled %} (missing lib-rubberband, pitch shift is not supported) {% endif %}</li>
{# MSG: The version of Pikaraoke running right now. #}
<li><u>{% trans %}Pikaraoke version:{% endtrans %}</u> {{ pikaraoke_version }}</li>
</ul>
Expand Down
Loading
Loading