Showing posts with label MPD. Show all posts
Showing posts with label MPD. Show all posts

New scripts for publishing MPD current song with using Psi+

old implementation

This python script gets information about current song in Title/Artist/Album format. You can save it to ~/.scripts/mpdnow.py
This script connects to the server directly, and displays information about the song only if it is playing.
# -*- coding: utf-8 -*-
import mpd

try:
    client = mpd.MPDClient()
    client.connect("localhost", 6600)
    if (client.status()['state']) == 'play':
            print(client.currentsong()['title']+'\n'+client.currentsong()['artist']+'\n'+client.currentsong()['album'])
except:
    2+2

Check the address and port of your MPD server.

Second script was written on UNIX Shell:
 #!/bin/sh
while true
rm ~/.psi/tune
touch /tmp/tune
ln -s /tmp/tune ~/.psi/tune
do
    python ~/.scripts/mpdnow.py > ~/.psi/tune
    sleep 1
done;
In this simple code you must check the address of first script.
After theese steps, you may add second script to autostart.
Share/Save/Bookmark

Sending current MPD song to Psi

If you use ncmpcpp (GIT version) you can publish tune after adding one line to your ~/.ncmpcpp/config
execute_on_song_change = "ncmpcpp --now-playing > ~/.psi/tune"
This line executes ncmpcpp (recursion!) when song changed.
This way have a issue: ncmpcpp --now-playing not give newline. It not show a user tune according XEP-0118.

 If you want to match the standard, you should to install MPC and you fix the line:
execute_on_song_change = "mpc --format '%title%\n%artist%\n%album%\n%track%\n%time%' | head -n -2 > ~/.psi/tune"


 If the instructions do not help, you may check:

  • Psi version
  • ncmcpp version
  • Support this feature on your jabber server.
*It works only if ncmpcpp run.
*ncmpcpp not have hook for pause or stop. 

Share/Save/Bookmark