Giter VIP home page Giter VIP logo

alfred-mpd's Introduction

alfred-mpd

alfred-mpd is an Alfred workflow designed to make playing music using mpd extremely quick and convenient.

Current functionality is designed around the way I myself play music, which is to say, a whole album at a time. In the future I may be willing to implement other use cases if people ask, but I get the impression that use of mpd on a Mac is at best an extremely niche proposition. The following instructions assume you have it installed and configured.

Usage

Trigger this workflow using the mpdalbum keyword (or assign it a hotkey). Alfred will scan your mpd database, and you can use Alfred's fuzzy matching to search for an album. When you select the album, if mpd is already playing, the selected album will be queued at the end of the playlist. Otherwise it will start playing immediately.

The workflow also includes the following features for music playback, which you should assign hotkeys to if you want to use them:

  • Toggle Play
  • Volume Up/Down (in increments of 10 within mpd's range from 0 to 100)
  • Show Current Song/Artist/Album/Time
  • Next/Previous Song
  • NEW in version 2.1: Find / Show Lyrics (see below)

Modifier Keys for Playing / Queueing Albums

You can modify the behavior of the workflow when you select an album using mpdalbum.

Shift will cause the album to be queued instead of played, regardless of whether mpd is currently playing.

Option will shuffle the playlist after adding the album. Note that this means that if you want to queue several albums with shuffle on, each additional album will re-shuffle the playlist.

Control will show the album's tracks in Alfred instead of playing the album. Selecting a track will behave as the Play/Queue hotkey above, but for the track. Control-selecting the track will play or queue the whole album. This lets you preview the tracks on an album before deciding to play it. Shift or Option-selecting a single track works as for albums, above.

Lyrics

The new command mpdlyrics will attempt to show the currently playing song's lyrics in large text. If the song has no lyrics attached to the file, it will attempt to search Genius.com for lyrics, add them to the file, and display them. In order to do this, you must do the following:

  • Set the GENIUS_ACCESS_TOKEN variable in the "Workflow Variables" section of this workflow (the [x]) icon in the upper right of the workflow editor. To get a token, sign up an API client with Genius.com here: [https://genius.com/api-clients]
  • Set up mpd to use a Unix socket for connections. You can do this by putting the line bind_to_address "~/.mpd/mpd.socket" in your mpd.conf (adjust this as necessary for where you put the rest of your mpd storage) and setting the workflow environment variable MPD_HOST to ~/.mpd/mpd.socket.

What's With The Large Text

Aside from playing or queueing an album or song, most actions will show large text. The problem with large text is that it's always as large as possible, which is sometimes very large indeed. In particular, the play/pause/stop emoji shown when you toggle play are colossal if shown alone and typically extremely pixelated. I padded them out to force them smaller; it's not a great solution but it's the best I could come up with.

If You Don't Have mpd Installed Already

You should be aware that using mpd instead of the Music app (née iTunes) to play music means circumventing the "(usually) just works" nature of Apple's default music player in the interest of maybe saving some memory and using some software that is in principle more narrowly focused on a single purpose. As a result, you'll probably be setting yourself up for a certain amount of frustration as you're forced to tinker with your non-standard setup. This route is not for everyone! On the other hand, this setup certainly allows for more tinkering than iTunes.

Here's a nice blog post that explains why you might be interested in going this route, with instructions for setting things up: http://ssrubin.com/posts/music-library-with-mpd-ncmpcpp-beets.html

Personally, I don't use beets or ncmpcpp, which is why I wrote my own Alfred workflow rather than using the one linked in that post. I let Apple's Music app manage my music because trying to cut it out of my life entirely is too much for me (in particular I'm not interested in coming up with an alternative for syncing to a mobile device). But you can certainly just use the setup in that post if you prefer!

If you use Apple Lossless files, you might need to follow these instructions when you install mpd to make sure it works with them: http://onethingwell.org/post/16355956926/mpd-apple-lossless-os-x

Libraries Used

This workflow uses the following Python libraries for its functionality. They're all included and don't need to be installed; this is just to give credit.

Copyright 2016 Ian McCowan

alfred-mpd's People

Contributors

valrus avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

alfred-mpd's Issues

Adding an album only adds the tracks that match the album's main artist

Firstly, alfred-mpd is really really really awesome and I'm so glad it exists! Now for it's first bug report 😄


I have an album who's artist is "Mr. Oizo" but some of the tracks in the album have an artist field like "Mr. Oizo feat. Somebody". If I add the album from Alfred only the songs matching the album artist are added.

image

Actual

image

Expected

image

Lyrics fail on m4a files

Suspect this is due to the album name being mangled into "DAMN_" by the MacOS filesystem. The traceback:

[14:35:08.231] ERROR: Play with mpd[Run Script] Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/ianmccowan/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.E9AAC0A8-7F64-4A19-920C-0E071F0C8807/actions/lyrics.py", line 51, in <module>
    main()
  File "/Users/ianmccowan/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.E9AAC0A8-7F64-4A19-920C-0E071F0C8807/actions/lyrics.py", line 16, in main
    tag_lyrics = audiofile.tag.lyrics
AttributeError: 'NoneType' object has no attribute 'tag'

Add album search by duration

I hate pausing an album in the middle and often find myself with some specific amount of time before a meeting or something during which I want to listen to some music. It'd be nice to be able to search albums by their length.

Match smart quotes

beets likes to replace plain quotes with smart ones when tagging, which makes them hard to search with alfred-mpd. Flatten smart quotes when constructing the searchable list to fix this.

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.