add new lyrics package

This commit is contained in:
Gabriel Fontes
2023-09-18 09:15:03 -03:00
parent 01d69cafb6
commit 2e357d9b82
5 changed files with 136 additions and 34 deletions
+1
View File
@@ -8,6 +8,7 @@
./git.nix
./gpg.nix
./jujutsu.nix
./lyrics.nix
./nix-index.nix
./pfetch.nix
./ranger.nix
+32
View File
@@ -0,0 +1,32 @@
{ pkgs, ... }:
{
home.packages = [ pkgs.lyrics ];
xdg.configFile."lyrics-in-terminal/lyrics.cfg".text = ''
[OPTIONS]
alignment=left
source=google
interval=1500
autoswitch=on
player=
mpd_host=
mpd_port=
mpd_pass=
[BINDINGS]
up=k
down=j
left=i
center=o
right=p
step-up=arrow_up
step-down=arrow_down
step-size=5
google=R
azLyrics=r
autoswitchtoggle=a
delete=d
edit=e
help=h
quit=q
'';
}
+1 -1
View File
@@ -15,7 +15,7 @@
pass-wofi = pkgs.callPackage ./pass-wofi { };
primary-xwayland = pkgs.callPackage ./primary-xwayland { };
wl-mirror-pick = pkgs.callPackage ./wl-mirror-pick { };
lyrics = pkgs.callPackage ./lyrics { };
lyrics = pkgs.python3Packages.callPackage ./lyrics { };
xpo = pkgs.callPackage ./xpo { };
tly = pkgs.callPackage ./tly { };
hyprslurp = pkgs.callPackage ./hyprslurp { };
+15 -33
View File
@@ -1,37 +1,19 @@
# Fetches current playing song lyrics from makeitpersonal.co
{ lib, writeShellApplication, curl, less, playerctl, gnused }: (writeShellApplication {
name = "lyrics";
runtimeInputs = [ playerctl curl less gnused ];
{ fetchFromGitHub, buildPythonPackage, dbus-python }:
text = /* bash */ ''
# Exit the script if not playing
playerctl -s status > /dev/null
buildPythonPackage rec {
pname = "lyrics";
version = "1.5.0";
artist="$(playerctl metadata artist)"
title="$(playerctl metadata title)"
prefix="$artist - "
title="''${title#"$prefix"}"
suffix=" - $artist"
title="''${title%"$suffix"}"
# Cleanup featurings
title="$(echo "$title" | sed -E 's/ ?\(fe?a?t\.?[^\)]*\)//')"
artist="$(echo "$artist" | sed -E 's/ ?\(fe?a?t\.?[^\)]*\)//')"
content="$(curl -f -s --get "https://makeitpersonal.co/lyrics" \
--data-urlencode "artist=$artist" --data-urlencode "title=$title")"
echo -e "$artist - $title\n$content" | less
'';
}) // {
meta = with lib; {
description = "Lyrics fetcher script";
license = licenses.mit;
platforms = platforms.all;
# The makeitpersonal API stopped working :(
# TODO: look for alternatives
broken = true;
src = fetchFromGitHub {
owner = "jugran";
repo = "lyrics-in-terminal";
rev = version;
hash = "sha256-61l4W7X66WHm1k/M/JM55dNj+mMh4R9ohKbByk9dIVA=";
};
propagatedBuildInputs = [ dbus-python ];
doCheck = false;
patches = [ ./fix-config-in-build-phase.diff ];
}
@@ -0,0 +1,87 @@
diff --git a/lyrics/__init__.py b/lyrics/__init__.py
index da6fc52..d1d3329 100644
--- a/lyrics/__init__.py
+++ b/lyrics/__init__.py
@@ -5,15 +5,3 @@ CACHE_PATH = Path.home().joinpath('.cache', 'lyrics')
CONFIG_PATH = Path.home().joinpath('.config', 'lyrics-in-terminal','lyrics.cfg')
__version__ = '1.5.0'
-
-if not CONFIG_PATH.exists():
- from shutil import copy
- import os
-
- dirname = Path(__file__).parent
- src = dirname.joinpath('lyrics.cfg')
-
- if not CONFIG_PATH.parent.exists():
- os.makedirs(CONFIG_PATH.parent)
-
- copy(src, CONFIG_PATH)
diff --git a/setup.py b/setup.py
index 10743d4..e7f0ded 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
from setuptools.command.install import install
import os
-from lyrics import __version__, CONFIG_PATH
+from lyrics import __version__
this_directory = os.path.abspath(os.path.dirname(__file__))
@@ -10,44 +10,6 @@ with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
-class PostInstallConfigUpdate(install):
- """Post-installation for config update"""
-
- def run(self):
- install.run(self)
- self.updateConfigFile()
-
- def updateConfigFile(self):
- if CONFIG_PATH.exists():
- from configparser import ConfigParser
-
- old_config = ConfigParser()
- old_config.read(CONFIG_PATH)
-
- new_config = ConfigParser()
- new_config.read('lyrics/lyrics.cfg')
-
- skip = True
-
- for section in old_config.sections():
- old_keys = {o for o in old_config[section]}
- new_keys = {n for n in new_config[section]}
-
- new_options = new_keys - old_keys
-
- if len(new_options) == 0:
- continue
- else:
- skip = False
-
- for option in new_options:
- old_config[section][option] = new_config[section][option]
-
- if not skip:
- with open(CONFIG_PATH, 'w') as file:
- old_config.write(file)
-
-
setup(
name='lyrics-in-terminal',
version=__version__,
@@ -77,8 +39,5 @@ setup(
'full': ['python-mpd2']
},
python_requires='>=3.6',
- cmdclass={
- 'install': PostInstallConfigUpdate
- },
include_package_data=True
)