Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
fde738910d | |||
546d921ec4 | |||
cb292a56b1 | |||
132cabf434 | |||
4617f83f5c | |||
047d09ffb1 | |||
b9444658fb | |||
0c45cbe1f6 | |||
ca78aa9e22 | |||
2b8ecf124d | |||
1009b29995 |
@ -13,7 +13,7 @@ A set of simple API endpoints and ready-to-go clients to interface with the [Grz
|
||||
|
||||
## How to run this
|
||||
|
||||
pip install --user git+https://github.com/Programvareverkstedet/grzegorz_clients.git#master
|
||||
pip install --user git+https://git.pvv.ntnu.no/Grzegorz/grzegorz-clients.git#master
|
||||
|
||||
### cli
|
||||
|
||||
@ -23,7 +23,7 @@ A set of simple API endpoints and ready-to-go clients to interface with the [Grz
|
||||
|
||||
As the user intended to run the server:
|
||||
|
||||
pip install --user git+https://github.com/Programvareverkstedet/grzegorz_clients.git#master
|
||||
pip install --user git+https://git.pvv.ntnu.no/Grzegorz/grzegorz-clients.git#master
|
||||
grzegorz-webui --host-name 0.0.0.0 --port 80
|
||||
|
||||
It's rather insecure and could use a reverse proxy and some whitelisting. ;)
|
||||
|
6
flake.lock
generated
6
flake.lock
generated
@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1711703276,
|
||||
"narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=",
|
||||
"lastModified": 1726755586,
|
||||
"narHash": "sha256-PmUr/2GQGvFTIJ6/Tvsins7Q43KTMvMFhvG6oaYK+Wk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d8fe5e6c92d0d190646fb9f1056741a229980089",
|
||||
"rev": "c04d5652cfa9742b1d519688f65d1bbccea9eb7e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
18
flake.nix
18
flake.nix
@ -57,14 +57,28 @@
|
||||
nativeBuildInputs = [ poetry-core ];
|
||||
propagatedBuildInputs = [ setuptools flakes.self.pkgs.remi requests typer rich urllib3 ];
|
||||
};
|
||||
default = flakes.self.pkgs.grzegorz-clients;
|
||||
grzegorzctl = pkgs.runCommandNoCCLocal "grzegorzctl" (
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.installShellFiles ];
|
||||
} //
|
||||
{ inherit (flakes.self.pkgs.grzegorz-clients) meta; } //
|
||||
{ meta.mainProgram = "grzegorzctl"; }
|
||||
)''
|
||||
mkdir -p $out/bin
|
||||
ln -s "${flakes.self.pkgs.grzegorz-clients}/bin/grzegorzctl" $out/bin/grzegorzctl
|
||||
installShellCompletion --cmd grzegorzctl \
|
||||
--bash <($out/bin/grzegorzctl --show-completion bash) \
|
||||
--zsh <($out/bin/grzegorzctl --show-completion zsh) \
|
||||
--fish <($out/bin/grzegorzctl --show-completion fish)
|
||||
'';
|
||||
default = flakes.self.pkgs.grzegorzctl;
|
||||
});
|
||||
|
||||
apps = forAllSystems ({ system, ...}: rec {
|
||||
grzegorz-webui.type = "app";
|
||||
grzegorz-webui.program = "${self.packages.${system}.grzegorz-clients}/bin/grzegorz-webui";
|
||||
grzegorzctl.type = "app";
|
||||
grzegorzctl.program = "${self.packages.${system}.grzegorz-clients}/bin/grzegorzctl";
|
||||
grzegorzctl.program = "${self.packages.${system}.grzegorzctl}/bin/grzegorzctl";
|
||||
default = grzegorzctl;
|
||||
});
|
||||
|
||||
|
@ -64,7 +64,7 @@ def _add(
|
||||
api.playlist_goto(current_index if put_pre else current_index + 1)
|
||||
api.set_playing(True)
|
||||
|
||||
@cli.command(help="Add one ore more items to the playlist")
|
||||
@cli.command(help="Add one or more items to the playlist")
|
||||
def play(
|
||||
urls: list[str],
|
||||
pre: bool = False,
|
||||
@ -72,14 +72,14 @@ def play(
|
||||
):
|
||||
_add(urls, put_post=not pre, put_pre=pre, play=True, api_base=api_base)
|
||||
|
||||
@cli.command(help="Add one ore more items to the playlist")
|
||||
@cli.command(help="Add one or more items to the playlist")
|
||||
def next(
|
||||
urls: list[str],
|
||||
api_base: str = DEFAULT_API_BASE,
|
||||
):
|
||||
_add(urls, put_post=True, api_base=api_base)
|
||||
|
||||
@cli.command(help="Add one ore more items to the playlist")
|
||||
@cli.command(help="Add one or more items to the playlist")
|
||||
def queue(
|
||||
urls: list[str],
|
||||
play: bool = True,
|
||||
@ -107,6 +107,12 @@ def pause( api_base: str = DEFAULT_API_BASE ):
|
||||
api.set_endpoint(api_base)
|
||||
rich.print(api.set_playing(False), file=sys.stderr)
|
||||
|
||||
@cli.command(help="Toggle playback")
|
||||
def toggle(api_base: str = DEFAULT_API_BASE):
|
||||
api.set_endpoint(api_base)
|
||||
playing = api.is_playing()
|
||||
rich.print(api.set_playing(not playing), file=sys.stderr)
|
||||
|
||||
@cli.command(help="Goto next item in playlist")
|
||||
def skip( api_base: str = DEFAULT_API_BASE ):
|
||||
api.set_endpoint(api_base)
|
||||
@ -154,11 +160,21 @@ def status(
|
||||
|
||||
@cli.command(help="Set the playback volume")
|
||||
def set_volume(
|
||||
volume: int,
|
||||
volume: str,
|
||||
api_base: str = DEFAULT_API_BASE,
|
||||
):
|
||||
api.set_endpoint(api_base)
|
||||
rich.print(api.set_volume(volume), file=sys.stderr)
|
||||
|
||||
volume = volume.removesuffix("%")
|
||||
|
||||
if volume.startswith("+") or volume.startswith("-"):
|
||||
current_volume = api.get_volume()
|
||||
new_volume = max(0, min(100, current_volume + int(volume)))
|
||||
new_volume = int(new_volume)
|
||||
else:
|
||||
new_volume = int(volume)
|
||||
|
||||
rich.print(api.set_volume(new_volume), file=sys.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -294,7 +294,7 @@ class RemiApp(App):
|
||||
except api.APIError:
|
||||
playback_pos = None
|
||||
|
||||
if playback_pos:
|
||||
if playback_pos and isinstance(playback_pos, dict) and playback_pos["current"] and playback_pos["total"]:
|
||||
slider_pos = playback_pos["current"] / playback_pos["total"] * 100
|
||||
current = seconds_to_timestamp(playback_pos["current"])
|
||||
total = seconds_to_timestamp(playback_pos["total"])
|
||||
|
Loading…
Reference in New Issue
Block a user