Compare commits

..

3 Commits

Author SHA1 Message Date
64a2c38eea 2.1.0 2024-05-02 23:25:17 +02:00
c75ec9d878 2.1.0 2024-05-02 23:24:19 +02:00
5c2f48e07c use argparse, use lowercase genius matching 2024-05-02 23:24:08 +02:00
6 changed files with 43 additions and 67 deletions

View File

@ -1,6 +1,6 @@
# Maintainer: Matthias Quintern <matthias(dot)quintern(at)posteo(dot)de> # Maintainer: Matthias Quintern <matthiasqui@protonmail.com>
pkgname=nicole pkgname=nicole
pkgver=2.1.0 pkgver=2.1
pkgrel=1 pkgrel=1
pkgdesc="Write lyrics from genius or azlyrics.com to a mp3-tag" pkgdesc="Write lyrics from genius or azlyrics.com to a mp3-tag"
arch=('any') arch=('any')
@ -8,8 +8,8 @@ url="https:/github.com/MatthiasQuintern/nicole"
license=('GPL3') license=('GPL3')
depends=('python-mutagen' 'python-beautifulsoup4') depends=('python-mutagen' 'python-beautifulsoup4')
source=(file://${PWD}/nicole/nicole.py _nicole.compdef.zsh nicole.1.man) source=(file://${PWD}/nicole/nicole.py _nicole.compdef.zsh nicole.1.man)
md5sums=('1cfc6bca38b8e1b8c28694226eebb31e' md5sums=('e7d1a3df7cb96798a7958018b28ed733'
'a0a390f36de74a366065ab65bfd1d8de' 'f3b46bdcaba5e7fc23bbacc6b2e153c0'
'8c3b8e5c90afdc8993ebab78d48f5668') '8c3b8e5c90afdc8993ebab78d48f5668')
package() { package() {

View File

@ -15,16 +15,16 @@ _nicole()
# option[description]:message:action # option[description]:message:action
# # -s allow stacking, eg -inr # # -s allow stacking, eg -inr
_arguments -s \ _arguments -s \
{--directory,-d}'[process directory]':directory:_directories \ '-d[process directory]':directory:_directories \
{--file,-f}'[process file]':file:_files \ '-f[process file]':file:_files \
{--recursive,-r}'[go through directories recursively]' \ '-r[go through directories recursively]' \
{--silent}'[silent]' \ '-s[silent]' \
{--ignore-history,-i}'[ignore history]' \ '-i[ignore history]' \
{--no-history,-n]}'[do not write to history]' \ '-n[do not write to history]' \
{--overwrite,-o}'[overwrite if the file already has lyrics]' \ '-o[overwrite if the file already has lyrics]' \
{--dry-run,-t}'[test, only print lyrics, dont write to tags]' \ '-t[test, only print lyrics, dont write to tags]' \
'--help[show this]' \ '-h[show this]' \
'--rm-explicit[remove the "Explicit" lyrics warning from the title tag]' \ '--rm_explicit[remove the "Explicit" lyrics warning from the title tag]' \
{--site,-s}'[specify lyrics site]':lyrics-site:_lyrics-site '--site[specify lyrics site]':lyrics-site:_lyrics-site
} }
_nicole "$@" _nicole "$@"

View File

@ -1,6 +1,6 @@
% NICOLE(1) nicole 2.1.0 % NICOLE(1) nicole 2.0
% Matthias Quintern % Matthias Quintern
% May 2024 % April 2022
# NAME # NAME
**N**ew-**I**ntrepid-**C**hief-**O**f-**L**yrics-**E**mbedders (obviously) **N**ew-**I**ntrepid-**C**hief-**O**f-**L**yrics-**E**mbedders (obviously)
@ -31,52 +31,56 @@ If you don't want your files in the history, add the `-n` option.
## genius ## genius
Nicole searches for lyrics using the genius api with the "title" and "artist" tags of the file. Nicole searches for lyrics using the genius api with the "title" and "artist" tags of the file.
If the title and artist names from genius are similar enough to the ones of the file, If the title and artist names from genius and the tags are similar, the lyrics are scraped from the url obtained through the api.
the lyrics are scraped from the url obtained through the api.
## azlyrics ## azlyrics
Nicole creates an azlyrics.com url from the "title" and "artist" tags of the file. Nicole creates an azlyrics.com url from the "title" and "artist" tags of the file.
The lyrics are extracted from the html document using regex. The lyrics are extracted from the html document using regex.
Unfortunately, there needs to be a 5 second delay between each request to azlyrics.com because Unfortunately, there needs to be a 5 second delay between each request to azlyrics.com because the site will block your ip for a while if you send many requests.
the site will block your ip for a while if you send many requests.
## Important Note
Since the lyrics are extracted from html pages and not from an api, the lyrics sites might temporarily block your ip address if you send too many requests.
If that is the case, wait a few hours and try again.
# USAGE # USAGE
## Command line options ## Command line options
**--directory**, **-d** directory **-d** directory
: process directory [directory] : process directory [directory]
**--file**, **-f** file **-f** file
: process file [file] : process file [file]
**--recursive**, **-r** **-r**
: go through directories recursively : go through directories recursively
**--silent** **-s**
: silent, no command-line output : silent, no command-line output
**--ignore-history**, **-i** **-i**
: ignore history : ignore history
**--no-history**, **-n** **-n**
: do not write to history : do not write to history
**--overwrite**, **-o** **-o**
: overwrite if the file already has lyrics : overwrite if the file already has lyrics
**--test**, **-t** **-t**
: test, do not write lyrics to file, but print to stdout : test, do not write lyrics to file, but print to stdout
**--rm-explicit** **-h**
: show this
**--rm_explicit**
: remove the "[Explicit]" lyrics warning from the song's title tag : remove the "[Explicit]" lyrics warning from the song's title tag
**--site**, **-s** site **--site** site
: onlysearch [site] for lyrics (genius or azlyrics) : onlysearch [site] for lyrics (genius or azlyrics)
One of `--file` and `--directory` must be given at least once. If you do not specify a directory or file, the program will ask you if you want to use the current working directory.
Example: `nicole -ior -d ~/music/artist --rm-explicit` Example: `nicole -ior -d ~/music/artist --rm_explicit`
# INSTALLATION AND UPDATING # INSTALLATION AND UPDATING
To update nicole, simply follow the installation instructions. To update nicole, simply follow the installation instructions.
@ -113,12 +117,6 @@ sudo chmod +x /usr/share/zsh/site-functions/_nicole
The dependencies will be automatically installed when using the either of the two installation options. The dependencies will be automatically installed when using the either of the two installation options.
# CHANGELOG # CHANGELOG
## 2.1.0
- Refactoring:
- use argparse
- use pyproject.toml
- Ignore case when matching a genius result
## 2.0 ## 2.0
- Nicole now supports lyrics from genius! - Nicole now supports lyrics from genius!
- Added man-page - Added man-page
@ -130,5 +128,5 @@ The dependencies will be automatically installed when using the either of the tw
- Files are now processed in order - Files are now processed in order
# COPYRIGHT # COPYRIGHT
Copyright © 2024 Matthias Quintern. License GPLv3+: GNU GPL version 3 <https://gnu.org/licenses/gpl.html>.\ Copyright © 2022 Matthias Quintern. License GPLv3+: GNU GPL version 3 <https://gnu.org/licenses/gpl.html>.\
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

View File

@ -1,5 +1,5 @@
#!/bin/python3 #!/bin/python3
# Copyright © 2024 Matthias Quintern. # Copyright © 2022 Matthias Quintern.
# This software comes with no warranty. # This software comes with no warranty.
# This software is licensed under the GPL3 # This software is licensed under the GPL3
@ -16,7 +16,7 @@ from os import path, getcwd, listdir, mkdir
from time import sleep from time import sleep
from sys import argv from sys import argv
version = "2.1.0" version = "2.1"
# Der Name Nicole ist frei erfunden und hat keine Bedeutung. # Der Name Nicole ist frei erfunden und hat keine Bedeutung.
# Jeglicher Zusammenhang mit einer Website der DHL wird hiermit ausdrücklich ausgeschlossen. # Jeglicher Zusammenhang mit einer Website der DHL wird hiermit ausdrücklich ausgeschlossen.
@ -450,7 +450,7 @@ class Nicole:
def main(): def main():
print(f"Nicole version {version}") print(f"Nicole version {version}")
parser = argparse.ArgumentParser(prog="nicole", description="lyrics scraper and embedder", epilog="https://github.com/MatthiasQuinter/nicole") parser = argparse.ArgumentParser("nicole")
parser.add_argument("--directory", "-d", action="append", help="process directory [directory]") parser.add_argument("--directory", "-d", action="append", help="process directory [directory]")
parser.add_argument("--file", "-f", action="append", help="process file [file]") parser.add_argument("--file", "-f", action="append", help="process file [file]")
parser.add_argument("--recursive", "-r", action="store_true", help="go through directories recursively") parser.add_argument("--recursive", "-r", action="store_true", help="go through directories recursively")
@ -462,6 +462,7 @@ def main():
parser.add_argument("--rm-explicit", action="store_true", help="remove the \"[Explicit]\" lyrics warning from the songs title tag") parser.add_argument("--rm-explicit", action="store_true", help="remove the \"[Explicit]\" lyrics warning from the songs title tag")
parser.add_argument("--site", "-s", action="store", help="use only [site]: azlyrics or genius", default="all") parser.add_argument("--site", "-s", action="store", help="use only [site]: azlyrics or genius", default="all")
args = parser.parse_args() args = parser.parse_args()
# Visit https://github.com/MatthiasQuintern/nicole for updates and further help."""
if args.file is None and args.directory is None: if args.file is None and args.directory is None:
parser.error("Either --directory or --file is required") parser.error("Either --directory or --file is required")

View File

@ -1,23 +0,0 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[tool.setuptools]
name = "nicole"
version = "2.1.0"
description = "Write lyrics from genius or azlyrics.com into a mp3-tag"
author = "Matthias Quintern"
author_email = "matthias.quintern@posteo.de"
url = "https://github.com/MatthiasQuintern/nicole.git"
license = "GPLv3"
packages = ["nicole"]
install_requires = ["mutagen", "beautifulsoup4"]
[tool.setuptools.entry-points]
console_scripts = ["nicole=nicole.nicole:main"]
[tool.setuptools.metadata]
description-file = "readme.md"
[tool.setuptools.packages.find]
where = "."

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup( setup(
name="nicole", name="nicole",
version="2.1.0", version="2.0",
description="Write lyrics from genius or azlyrics.com to a mp3-tag", description="Write lyrics from genius or azlyrics.com to a mp3-tag",
author="Matthias Quintern", author="Matthias Quintern",