Skip to content

Commit

Permalink
Merge branch 'master' into background-music
Browse files Browse the repository at this point in the history
  • Loading branch information
lvmasterrj authored Jan 1, 2025
2 parents 24725ef + f254ae2 commit 4a9dcf0
Show file tree
Hide file tree
Showing 16 changed files with 506 additions and 687 deletions.
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 @@ -9,3 +9,4 @@ songs/
qrcode.png
.DS_Store
config.ini
docker-compose.yml
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{".":"1.6.1"}
{".":"1.7.0"}
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
16 changes: 16 additions & 0 deletions pikaraoke/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## [1.7.0](https://github.com/vicwomg/pikaraoke/compare/1.6.1...1.7.0) (2024-12-24)


### Features

* add arm64/amd64 docker builds to release-please ci ([a07265f](https://github.com/vicwomg/pikaraoke/commit/a07265fbece73b49cef95d99dbf54d4a4dd457e3))
* add dockerization support ([f93168f](https://github.com/vicwomg/pikaraoke/commit/f93168fa5413c6cdc20c265934dc05a42c728be2))


### Bug Fixes

* commitlint error ([69cb031](https://github.com/vicwomg/pikaraoke/commit/69cb03170b325a111d4384c150b725f427d23968))
* File was being deleted even if it was in queue ([86dae29](https://github.com/vicwomg/pikaraoke/commit/86dae29b8fb279e5b8a410d22127cf20564359dd))
* Notification not being shown using Flask Flash ([497196a](https://github.com/vicwomg/pikaraoke/commit/497196a78285831492dd7f166f33513d19c29117))
* Transposing hangs when ffmpeg does not have librubberband ([#435](https://github.com/vicwomg/pikaraoke/issues/435)) ([8939e60](https://github.com/vicwomg/pikaraoke/commit/8939e6030aa967a18baf391c8499757708b0a73e))

## [1.6.1](https://github.com/vicwomg/pikaraoke/compare/1.6.0...1.6.1) (2024-12-02)


Expand Down
6 changes: 5 additions & 1 deletion pikaraoke/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,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 @@ -166,6 +167,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 @@ -448,7 +450,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 @@ -594,6 +597,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 @@ -24,6 +24,7 @@
get_os_version,
get_platform,
is_raspberry_pi,
is_transpose_enabled,
supports_hardware_h264_encoding,
)

Expand Down Expand Up @@ -69,6 +70,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 @@ -166,6 +168,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 @@ -124,7 +124,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
2 changes: 1 addition & 1 deletion pikaraoke/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.6.1" # {x-release-please-version}
__version__ = "1.7.0" # {x-release-please-version}
Loading

0 comments on commit 4a9dcf0

Please sign in to comment.