This commit is contained in:
Peder Bergebakken Sundt 2024-05-10 19:57:29 +02:00
parent df0a64f7c9
commit 3841cda1cd
5 changed files with 14 additions and 5 deletions

9
.envrc
View File

@ -3,9 +3,11 @@
# It enters you into the poetry venv, removing the need for `poetry run`. # It enters you into the poetry venv, removing the need for `poetry run`.
if command -v nix >/dev/null; then if command -v nix >/dev/null; then
use nix -p poetry use flake
fi fi
export GRZEGORZ_IS_DEBUG=1 # mpv does not start in fullscreen
# Instead of using the flake, we use poetry to manage a development venv # Instead of using the flake, we use poetry to manage a development venv
# We only use poetry2nix for deployment # We only use poetry2nix for deployment
@ -18,4 +20,9 @@ PATH_add "$VIRTUAL_ENV/bin"
if ! command -v sanic >/dev/null; then if ! command -v sanic >/dev/null; then
poetry install poetry install
# patchelf the venv on nixos
if ! test -s /lib64/ld-linux-x86-64.so.2 || { uname -a | grep -qi nixos; }; then
#nix run github:GuillaumeDesforges/fix-python -- --venv "$VIRTUAL_ENV" #--libs .nix/libs.nix
fix-python --venv "$VIRTUAL_ENV" #--libs .nix/libs.nix
fi
fi fi

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ config.py
*.socket *.socket
result result
result-* result-*
.direnv

View File

@ -47,7 +47,7 @@ PLAYLIST_DATA_CACHE = PlaylistDataCache(auto_fetch_data=True)
@openapi.exclude(True) @openapi.exclude(True)
@response_text @response_text
async def root(request: Request): async def root(request: Request):
return "Hello friend, I hope you're having a lovely day" return "Hello friend, I hope you're having a lovely day\n"
@bp.post("/load") @bp.post("/load")
@openapi.summary("Add item to playlist") @openapi.summary("Add item to playlist")

View File

@ -9,6 +9,7 @@ from pathlib import Path
from . import nyasync from . import nyasync
IS_DEBUG = os.environ.get("GRZEGORZ_IS_DEBUG", "0") != "0"
class MPV: class MPV:
# TODO: move this to /tmp or /var/run ? # TODO: move this to /tmp or /var/run ?
@ -27,7 +28,7 @@ class MPV:
f'--input-ipc-server={str(cls._ipc_endpoint)}', f'--input-ipc-server={str(cls._ipc_endpoint)}',
'--idle', '--idle',
'--force-window', '--force-window',
'--fullscreen', *(('--fullscreen',) if not IS_DEBUG else ()),
'--no-terminal', '--no-terminal',
'--load-unsafe-playlists', '--load-unsafe-playlists',
'--keep-open', # Keep last frame of video on end of video '--keep-open', # Keep last frame of video on end of video

View File

@ -60,11 +60,11 @@ class UnixConnection:
@classmethod @classmethod
async def from_path(cls, path): async def from_path(cls, path):
endpoints = await asyncio.open_unix_connection(path) endpoints = await asyncio.open_unix_connection(path, limit=2**24) # default is 2**16
return cls(*endpoints) return cls(*endpoints)
def __aiter__(self): def __aiter__(self):
return self.reader.__aiter__() return self.reader.__aiter__() # readline
def write(self, data): def write(self, data):
self.writer.write(data) self.writer.write(data)