Giter Club home page Giter Club logo

kunst's Introduction


✨ Download and display album art or display embedded album art ✨

kunst is a daemon that extracts the album art from the songs playing in mpd and displays them in the a little window. It doesn't loop on a timer, instead it waits for mpd to send a player event. When it receives a player event, it wakes up and extracts the album art of the current playing track. This makes kunstreally lightweight and makes it idle at ~0% CPU usage. If there no embbeded album art, it will try to fetch the album art from the internet.

Dependencies

  • sxiv
  • bash
  • ffmpeg
  • mpc
  • jq
  • mpd

Installation

Install using make

# Clone the repo
$ git clone https://github.com/sdushantha/kunst

# Change your current directory to kunst
$ cd kunst

# Install it
$ sudo make install

Install it locally

# Download the kunst source code, save as kunst, make it executeable
# and then move it to ~/.local/bin
$ curl -L git.io/raw-kunst > kunst && chmod +x kunst && mv kunst ~/.local/bin

Usage

$ kunst --help
usage: kunst [-h] [--size px] [--music_dir path/to/dir] [--silent] [--version]

┬┌─┬ ┬┌┐┌┌─┐┌┬┐
├┴┐│ ││││└─┐ │
┴ ┴└─┘┘└┘└─┘ ┴
Download and display album art or display embedded album art

optional arguments:
   -h, --help            show this help message and exit
   --size                what size to display the album art in
   --position            the position where the album art should be displayed
   --music_dir           the music directory which MPD plays from
   --silent              dont show the output
   --version             show the version of kunst you are using

Configure

You can configure kunst through environment variables.

# The size of the album art to be displayed
export KUNST_SIZE="250x250"

# The position where the album art should be displayed
export KUNST_POSITION="+0+0"

# Where your music is located
export KUNST_MUSIC_DIR="/home/username/Music/"

License

MIT License

Copyright © 2019 Siddharth Dushantha

kunst's People

Contributors

abbadanor avatar aeres-u99 avatar bachoseven avatar codewithma avatar deepjyoti30 avatar dragonghost7 avatar hyperupcall avatar imgbotapp avatar keeganjk avatar mateossh avatar rubdos avatar sdushantha avatar seirdy avatar travonted avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

kunst's Issues

Connection refused mpd error

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:)

"No more files to display, aborting"

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 - КУСЬ

error: could not find "convert"

Hi,
unfortunately, it doesnt work on my debian. I get this message: "error: Could not find 'convert', is it installed?"
What to do?

Run less frequently (only on album change)

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.

Help needed with my project

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.

Recognize more type of cover art names

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.

Closing sxiv in openbox crash

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:

  • Network manager
  • Firefox
  • ClipIt
  • etc
    except from terminals, tint2, mpv.
    I can't really show error log or output of kunst because if was summoned via hotkey

imagemagick dependencies

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 🤘

Screenshot from 2020-07-17 00-10-45

Support imv image viewer

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.

Kunst notification implementation using Dunst

So I added dunst to the script

image

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).

File not found error

@DragonGhost7 I just noticed that kunst is outputting an error:
Screenshot_19-06-02_at_09-11-11

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 :)

Kunst cannot find any album art online

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?

Kunst keeps running as zombie process when sxiv is closed

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).

Use kunst without display

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

Support `cover.{jpg,png}`

Many music organisers store their cover art along the album, instead of embedded inside the file. Typically, this file is called cover.jpg.

Mixed indentation styles in code

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.

Images are low res if zoomed with 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 !

Allow providing a fallback image

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.

Artless fallback broken

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.

Maybe remove tagging?

I am getting some strange errors
Screenshot_19-06-02_at_13-59-28
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

Support for mopidy

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.

Download album art if a file does not have it

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.

Does it work with flac files?

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

Missing Requirement

Needs mpd, which is not listed in the dependencies, at least under Mint 19.

Show in ncmpcpp

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
ncmpcpp

[ BUG ] cannot curl from deezer's API

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.

Hangs at: kunst: swapped album art to

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.