Skip to content

Commit

Permalink
fix: modify files minimally to make it run
Browse files Browse the repository at this point in the history
Modifies the files minimally with correct imports as well as
a few minor fixes to make it run again.
  • Loading branch information
mariugul committed Aug 13, 2024
1 parent 3821bdc commit 168abbb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
26 changes: 10 additions & 16 deletions pikaraoke/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

import cherrypy
import flask_babel
import karaoke
import psutil
from constants import LANGUAGES, VERSION
from flask import (
Flask,
flash,
Expand All @@ -27,7 +25,6 @@
)
from flask_babel import Babel
from flask_paginate import Pagination, get_page_parameter
from lib.get_platform import get_platform, is_raspberry_pi
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
Expand All @@ -36,6 +33,10 @@
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

from pikaraoke import karaoke
from pikaraoke.constants import LANGUAGES, VERSION
from pikaraoke.lib.get_platform import get_platform, is_raspberry_pi

try:
from urllib.parse import quote, unquote
except ImportError:
Expand Down Expand Up @@ -685,12 +686,6 @@ def expand_fs():
signal.signal(signal.SIGTERM, lambda signum, stack_frame: k.stop())


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")


def get_default_dl_dir(platform):
if raspberry_pi:
return "~/pikaraoke-songs"
Expand All @@ -708,7 +703,7 @@ def get_default_dl_dir(platform):
return "~/pikaraoke-songs"


if __name__ == "__main__":
def main():
platform = get_platform()
default_port = 5555
default_ffmpeg_port = 5556
Expand All @@ -719,7 +714,7 @@ def get_default_dl_dir(platform):
default_prefer_hostname = False

default_dl_dir = get_default_dl_dir(platform)
default_youtubedl_path = get_default_youtube_dl_path(platform)
default_youtubedl_path = "yt-dlp"

# parse CLI args
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -864,11 +859,6 @@ def get_default_dl_dir(platform):
app.jinja_env.globals.update(filename_from_path=filename_from_path)
app.jinja_env.globals.update(url_escape=quote)

# check if required binaries exist
if not os.path.isfile(args.youtubedl_path):
print("Youtube-dl path not found! " + args.youtubedl_path)
sys.exit(1)

# setup/create download directory if necessary
dl_path = os.path.expanduser(arg_path_parse(args.download_path))
if not dl_path.endswith("/"):
Expand Down Expand Up @@ -953,3 +943,7 @@ def get_default_dl_dir(platform):
cherrypy.engine.exit()

sys.exit()


if __name__ == "__main__":
main()
7 changes: 4 additions & 3 deletions pikaraoke/karaoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@

import ffmpeg
import qrcode
from lib.file_resolver import FileResolver
from lib.get_platform import (
from unidecode import unidecode

from pikaraoke.lib.file_resolver import FileResolver
from pikaraoke.lib.get_platform import (
get_ffmpeg_version,
get_os_version,
get_platform,
is_raspberry_pi,
supports_hardware_h264_encoding,
)
from unidecode import unidecode


# Support function for reading lines from ffmpeg stderr without blocking
Expand Down
2 changes: 1 addition & 1 deletion pikaraoke/lib/file_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import shutil
import zipfile

from lib.get_platform import get_platform
from pikaraoke.lib.get_platform import get_platform


# Processes a given file path and determines the file format and file path, extracting zips into cdg + mp3 if necessary.
Expand Down
3 changes: 2 additions & 1 deletion pikaraoke/lib/vlcclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from threading import Timer

import requests
from lib.get_platform import get_platform, is_raspberry_pi

from pikaraoke.lib.get_platform import get_platform, is_raspberry_pi


def get_default_vlc_path(platform):
Expand Down

0 comments on commit 168abbb

Please sign in to comment.