sdushantha / kunst Goto Github PK
View Code? Open in Web Editor NEWDownload and display album art or display embedded album art
License: MIT License
Download and display album art or display embedded album art
License: MIT License
If sxiv is closed, kunst keeps running but seems to be rather a zombie process. It does not reopen sxiv on song change and there seems to be no use for the running process.
My proposal is to either terminate the kunst script if sxiv is closed or make the script recoverable (e.g. reopening sxiv on song change, prompting user to press a key to reopen sxiv).
Hello !
It seems the pictures in Kunst have a fixed resolution. If my cover.jpg is 5000x5000 for exemple and if I try to zoom in wih sxiv when using Kunst the image is blurry and low res.
I've tried to change the size value with the "--size" option but it only widens the terminal around the picture.
Is there a way around this ? Is it possible to use a higher resolution by default for the images ?
Thank you for the help and thank you for making kunst !
Hello,
I recently switched to mopidy from mpd to use Spotify,
but it feels lonely without Kunst to complement the player, i use bum but it is slow in changing the covert art compared to kunst.
do you have any plan to support mopidy in the future?
Thanks.
I only have flac files in my collection usually with just a cover.jpg file in the directory. I can see from the code it doesn't support this. So I used a program to embed the art into my flac files for a album and I'm still getting no art found errors.
error: file does not have an album art
kunst: swapped album art to Ghost - Life Eternal
I have a lot of my cover art in webp.
Would be nice to also find them.
For example show cover.webp
.
Currently, when the script ends, sxiv keeps on running. Maybe use a bash EXIT trap?
I have come up with and idea to make kunst
much better!
If the current song does not have en embedded album art AND there is an internet connection, download the album art from the internet using the Deezer API. If there is NO internet connection, THEN use the music note as the album art.
How would be get the album art?
Use the Deezer API.
We would use mpc current
to get the current music and use the output of that to put in the API and fetch the JSON data from Deezer.
Example:
http://api.deezer.com/search/autocomplete?q=Brian Crain - Song for Sienna
Then we would use jq
to parse the JSON data and fetch the first url to the album art image (the one which is 500x500). If there is no result returned, (maybe the current song does not exist on Deezer), then we would just show the music note.
@DragonGhost7 I just noticed that kunst
is outputting an error:
I have no idea what line in the code is doing this. I think you might know because I am not getting this error in the older version of kunst
.
Would be nice you could fix this. Dont rush, just take your time :)
imv
is another suckless/minimal image viewer, the main difference being that it works natively on Wayland as well as X11. It would be great if kunst could support imv
and other custom image viewers.
When using kunst from cli everything is fine, and I can even put command in Openbox rc.xml :
<action name="Execute">
<command>kunst --silent --music_dir ~/Music/ --size "240x135"</command>
</action>
</keybind>
But if I close instance of sxiv that was opened openbox way it will crash a lot of programs such as:
Seems like it hangs, let me know what additional information you need and I'll provide it.
user@host:/media/Music/A/A Flock of Seagulls$ kunst --music_dir .
kunst: inspecting ..
error: file does not have an album art
error: cover not found online
kunst: swapped album art to
-----------------------------------------------------------------------------------------------------------------------------------------------------
^C
I'd like to use Kunst with i3's scratchpad feature to open when I show ncmpcpp, but Kunst uses sxiv's default class name for the window it opens, making it impossible to do so without making all sxiv windows follow the same rule as Kunst's window.
It would be nice not to see an extra terminal lying around while enjoying the displayed album art.
I've installed kunst on my Ubuntu 19.04 laptop with mpd 0.21.4 (not a service). MPD works fine the majority of the time, as does ncmpcpp. However, running kunst produces (over and over; even ctrl-c won't stop it):
mpd error: Connection reset by peer
mpd error: Connection refused
I've had this problem before so it can't be specific to kunst. I can use mpc to access some music info at the CLI alright, but putting it into a script just gives me 'Connection refused' again. It's weird.
MPD config:
bind_to_address "127.0.0.1"
port "6601"
Any help would be appreciated. You don't know how long I've wanted an app like this:)
./Kunst --size 60x60 --silent
getopt: unrecognized option '--silent'
Due to the broadness of mpc idle player
, kunst currently runs every song change, play state change, or just seeking within a song. If you seek or skip tracks on albums often, it can needlessly run dozens of times when the cover hasn't changed once. This gets more wasteful if you're dealing with very large files or resolutions.
On some artwork (small ones it has to scale up?) I've noticed a flash of sxivs background color while its switching art, which gets really distracting at fullscreen when it happens every seek or song change.
To remedy these I've made mine only run when the album changes like so:
ALBUM="$(dirname "$(mpc current -f %file%)")"
mpc idle player &>/dev/null && (mpc status | grep "\[playing\]" &>/dev/null) && sleep .3 && if [ "$ALBUM" != "$(dirname "$(mpc current -f %file%)")" ]; then break; fi
This prevents the vast majority of find_album_art runs.
I'm using the album path for ALBUM as a personal preference, but a more universal way (since many people keep a bunch of random tracks in one dir) could be:
mpc current -f "[[%albumartist% - |%artist% - ]%album%]|%file%"
This should try AlbumArtist - Album to not update on every track change on multi-artist compilations, then Artist or just Album if they exist, or falls back to just file path on songs missing all tags (which updates on every track change).
Alternatively, to only fix the run-every-seek issue, you could keep track of song changes like "$SONG" != "$(mpc current -f %file%)"
. Though only running on album changes is much more efficient. Ideally there could be an option to toggle between or disable the feature.
I'm posting this as a suggestion not a PR because I'm a bash & git noob and I'm sure my if
method can be improved by someone. I added a sleep .3
in my example above because in some circumstances it was not detecting an album change (I'm not sure why, could be because my mpd is on another pc across the network), adding the delay seemed to fix mine.
The output from kunst
is
parse error: Invalid numeric literal at line 1, column 20
but I digged a little and it seems that `curl -s "$API_URL" is giving the following output:
<html><body><h1>400 Bad request</h1>
Your browser sent an invalid request.
</body></html>
I can wget "$API_URL"
and parse it correctly with jq
, tho. So it does not seem like a problem with the API having changed like in #36.
The URL in question was https://api.deezer.com/search/autocomplete?q=Björk%20-%20Cosmogony, form an mpc
query of Björk - Hollow
.
I suspect there could be an issue with the "ö", since I can curl
many other albums.
Arch linux, mopidy-spotify.
Randomly get this error, sometime it could work okay for 30 min, or this error could appear after second song. It just closes sxiv window but the kunst is keep working.
kunst: received event from mpd
kunst: inspecting /home/posaydone/Music/.
error: file does not have an album art
kunst: cover found online
sxiv: no more files to display, aborting
kunst: resized album art to 500x500
kunst: swapped album art to SQWOZ BAB - КУСЬ
Would be great if a fallback image could be provided in case no album art is found offline or online. This would ensure there is always an image displayed.
So I added dunst to the script
Can i make a PR or something?
Btw, i was also gonna add something that allowed kunst to override music metadata, but ffmpeg makes a new music file instead of directly overriding the music perse. If anyone knows a way to directly override the music being played that would be cool! With the added thingy I made one already has the artist name and such either from the music's metadata or from the deezer api (which sometimes gives the wrong artist, try Taylor Switf - I knew you were trouble and it will give some other artist for some reason and put Taylor Swift at the bottom of the list of found for whatever reason).
sxiv is now unmaintained: https://github.com/xyb3rt/sxiv
Replace it with https://nsxiv.codeberg.page/ which is a drop-in replacement for sxiv, maintaining its interface.
Hello there!
Kunst was practically not able to find any album art online, so I started looking at the source. I noticed that if I ask api.deezer.com for "Jon Hassell - Viva Sohona" I get the following JSON:
$ curl -s "$API_URL" | jq
{
"tracks": {
"data": [
{
"id": 904217522,
"readable": true,
"title": "Viva Shona",
"title_short": "Viva Shona",
"title_version": "",
"link": "https://www.deezer.com/track/904217522",
"duration": 425,
"rank": 109378,
"explicit_lyrics": false,
"explicit_content_lyrics": 0,
"explicit_content_cover": 2,
"preview": "https://cdns-preview-6.dzcdn.net/stream/c-64d271133c6ba5ca9029a4ab1bbb97c8-3.mp3",
"artist": {
"id": 78614,
"name": "Jon Hassell",
"link": "https://www.deezer.com/artist/78614",
"picture": "https://api.deezer.com/artist/78614/image",
"picture_small": "https://cdns-images.dzcdn.net/images/artist/16fcc0fe93055b0127d02ecb2c2a5b4a/56x56-000000-80-0-0.jpg",
"picture_medium": "https://cdns-images.dzcdn.net/images/artist/16fcc0fe93055b0127d02ecb2c2a5b4a/250x250-000000-80-0-0.jpg",
"picture_big": "https://cdns-images.dzcdn.net/images/artist/16fcc0fe93055b0127d02ecb2c2a5b4a/500x500-000000-80-0-0.jpg",
"picture_xl": "https://cdns-images.dzcdn.net/images/artist/16fcc0fe93055b0127d02ecb2c2a5b4a/1000x1000-000000-80-0-0.jpg",
"tracklist": "https://api.deezer.com/artist/78614/top?limit=50",
"type": "artist"
},
"album": {
"id": 136520012,
"title": "Vernal Equinox (Remastered)",
"cover": "https://api.deezer.com/album/136520012/image",
"cover_small": "https://cdns-images.dzcdn.net/images/cover/632f19ddec62e5c10e630138cd8eceba/56x56-000000-80-0-0.jpg",
"cover_medium": "https://cdns-images.dzcdn.net/images/cover/632f19ddec62e5c10e630138cd8eceba/250x250-000000-80-0-0.jpg",
"cover_big": "https://cdns-images.dzcdn.net/images/cover/632f19ddec62e5c10e630138cd8eceba/500x500-000000-80-0-0.jpg",
"cover_xl": "https://cdns-images.dzcdn.net/images/cover/632f19ddec62e5c10e630138cd8eceba/1000x1000-000000-80-0-0.jpg",
"tracklist": "https://api.deezer.com/album/136520012/tracks",
"type": "album"
},
"type": "track"
},
{
"id": 437135022,
"readable": true,
"title": "Viva Shona",
"title_short": "Viva Shona",
"title_version": "",
"link": "https://www.deezer.com/track/437135022",
"duration": 428,
"rank": 124406,
"explicit_lyrics": false,
"explicit_content_lyrics": 0,
"explicit_content_cover": 2,
"preview": "https://cdns-preview-a.dzcdn.net/stream/c-ace0381c4deb7ad2581a3ca3c3e0338a-4.mp3",
"artist": {
"id": 78614,
"name": "Jon Hassell",
"link": "https://www.deezer.com/artist/78614",
"picture": "https://api.deezer.com/artist/78614/image",
"picture_small": "https://cdns-images.dzcdn.net/images/artist/fa1444ca3abda89ebbaca1505f5f232b/56x56-000000-80-0-0.jpg",
"picture_medium": "https://cdns-images.dzcdn.net/images/artist/fa1444ca3abda89ebbaca1505f5f232b/250x250-000000-80-0-0.jpg",
"picture_big": "https://cdns-images.dzcdn.net/images/artist/fa1444ca3abda89ebbaca1505f5f232b/500x500-000000-80-0-0.jpg",
"picture_xl": "https://cdns-images.dzcdn.net/images/artist/fa1444ca3abda89ebbaca1505f5f232b/1000x1000-000000-80-0-0.jpg",
"tracklist": "https://api.deezer.com/artist/78614/top?limit=50",
"type": "artist"
},
"album": {
"id": 52861552,
"title": "Vernal Equinox",
"cover": "https://api.deezer.com/album/52861552/image",
"cover_small": "https://cdns-images.dzcdn.net/images/cover/f93aae93407edfb86df6eb7e1e6104f9/56x56-000000-80-0-0.jpg",
"cover_medium": "https://cdns-images.dzcdn.net/images/cover/f93aae93407edfb86df6eb7e1e6104f9/250x250-000000-80-0-0.jpg",
"cover_big": "https://cdns-images.dzcdn.net/images/cover/f93aae93407edfb86df6eb7e1e6104f9/500x500-000000-80-0-0.jpg",
"cover_xl": "https://cdns-images.dzcdn.net/images/cover/f93aae93407edfb86df6eb7e1e6104f9/1000x1000-000000-80-0-0.jpg",
"tracklist": "https://api.deezer.com/album/52861552/tracks",
"type": "album"
},
"type": "track"
}
]
},
"albums": {
"data": []
},
"artists": {
"data": []
},
"playlists": {
"data": []
},
"podcasts": {
"data": []
},
"radios": {
"data": []
},
"total": 2
}
Which has an empty playlists.data
field. The right album cover URL can be extracted with e.g.
$ curl -s "$API_URL" | jq -r '.tracks.data[0].album.cover_big'
I'm definitely not a deezer.com API connoisseur, has it changed lately?
Quite often the album art is not named cover.{jpg,png}
, but for example Folder.jpg
. #9 improved the feature but I think it should be further improved. kunst should imo detect cover
, folder
and front
by default, in png
and jpg
, case insensitive.
An environment variable to provide more allowed names and extensions would solve all naming and format issues sustainably, because users can override the variable.
Kunst log is keep going, but the artwork isn't changing in sxiv window.
So this may already be an option however I am still going to ask I notice kunst stores it's artwork in a temporary directory I am working on a widget for eww that needs to get the current albums picture. This works fine already using kunst however it would be nice to be able to disable the output. Forgive me if this is a dumb question. Fyi I added this my self just thought it may be nice in upstream
Would be nice to add a option to use the API to show the album art even though the current audio file has an embedded album art.
This is useful when testing functionality of the API.
While I was working on #13, I found out that there's still mixed indentation in this project... Even though I added EditorConfig in #4 a while ago 😢
Because world don't have any tool which lints bash scripts the way e.g ESLint does and developers doesn't pay enough attention to this, I think this repo should contain Pull Request template with little note "enforcing" them to check indents style or install editorconfig plugin to text editor of their choice.
Needs mpd
, which is not listed in the dependencies, at least under Mint 19.
Hi there, can you try to improve on this, so the album art can show in ncmpcpp split screen. Usually I have my ncmpcpp setup split so the left half shows me the tracks and the right half shows visualizer. Would be great if you can think of a way to show the album art in that visualizer screen instead.
Please see my screenshot as an example of the album art on ncmpcpp
as of title
I am trying to use this with my Raspberry pi mp3 player. when I try sudo ./kunst --size 180x180px --music_dir ~/Music
, I get error: file does not have an album art
and ./kunst: line 102: jq: command not found
. I know there is an Album art embedded with the file. Help Please.
I am getting some strange errors
And since there are many other programs which do auto tagging, I am thinking of removing the tagging feature because there is a risk already tagged files might get re-tagged.
It would be nicer to have kunst
only deal with album art.
@DragonGhost7
Hi ,
i think you should add imagemagick on the deps,
after adding all the necessary deps, the installation run fine but error when i try to run kunst.
~ kunst error: Could not find 'convert', is it installed? cat: /tmp/kunst.pid: No such file or directory ~
So i install imagemagick which provide convert,
this happened on fresh install artix i3 system.
Thanks i enjoyed this app 🤘
I think the MUSIC_NOTE fallback is currently breaking the script when using the default of kunst.jpg.
When I get error: cover not found online
it will write the music_note to /tmp/kunst.png, but sxiv is watching the .jpg, so the display will stay as the last found cover forever, while kunst then keeps writing future (undisplayed) covers as kunst.png. It only works as expected if I start kunst while playing a song with unfindable art, locking itself into using .png from the go, or if you set COVER to png at the top.
I got it working smoothly (while still using jpgs) by just commenting out line 216:
#COVER=/tmp/kunst.png
so it writes the music_note png as kunst.jpg, which sxiv still displays fine, but won't divert the whole thing into only writing pngs.
Many music organisers store their cover art along the album, instead of embedded inside the file. Typically, this file is called cover.jpg
.
Hi,
unfortunately, it doesnt work on my debian. I get this message: "error: Could not find 'convert', is it installed?"
What to do?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.