NAME

Music::Audioscrobbler::MPD - Module providing routines to submit songs to last.fm from MPD.

SYNOPSIS

use Music::Audioscrobbler::MPD
my $mpds = Music::Audioscrobbler::MPD->new(\%options); 
$mpds->monitor_mpd();

DESCRIPTION

Music::Audioscrobbler::MPD is a scrobbler for MPD. As of version .1, Music::Audioscrobbler::Submit is used to submit information to last.fm.

All internal code is subject to change. See musicmpdscrobble for usage info.

MORE HELP

Please see the documentation for musicmpdscrobble which is available from

musicmpdscrobble --longhelp

METHODS

new()
my $mpds = Music::Audioscrobbler::MPD->new($options);
monitor_mpd()

Starts the main loop.

options()

Get or set options via hash. Here is a list of available options:

optionfile

Perl file used to get options from

lastfm_username

lastfm username

lastfm_password

lastfm password. Not needed if lastfm_md5password is set.

lastfm_md5password

MD5 hash of lastfm password.

lastfm_client_id

Client ID provided by last.fm. Defaults to "tst", which is valid for testing only.

lastfm_client_version

Set to the version of your program when setting a valid client_id. Defaults to "1.0"

mpd_server

hostname of mpd_server

mpd_port

port for mpd_server

mpd_password

mpd password

verbose

Set verbosity level (1 through 4)

logfile

File to output loginfo to

scrobblequeue

Path to file to queue info to

music_directory

Root to MP3 files

get_mbid_from_mb

Use the Music::Tag::MusicBrainz plugin to get missing "mbid" value.

runonsubmit

Array of commands to run after submit

runonstart

Array of commands to run on start of play

monitor

True if monitor should be turned on

musictag

True if you want to use Music::Tag to get info from file

musictag_overwrite

True if you want to Music::Tag info to override file info

music_tag_opts

Options for Music::Tag

proxy_server

Specify a procy server in the form http://proxy.server.tld:8080. Please note that environment is checked for HTTP_PROXY, so you may not need this option.

allow_stream

If set to true, will scrobble HTTP streams.

INTERNAL METHODS (for reference)

mpdsock()

returns open socket to mpd program.

connect()

Connect to MPD if necessary

is_connected()

Return true if connected to mpd.

process_feedback

Process response from mpd.

send_command($command)

send a command to mpd.

send_password($command)

send password to mpd.

get_info($command)

Send mpd a command and parse the output if output is a column seperated list.

get_status($command)

get_status command. Returns hashref with:

*  volume: (0-100)
* repeat: (0 or 1)
* random: (0 or 1)
* playlist: (31-bit unsigned integer, the playlist version number)
* playlistlength: (integer, the length of the playlist)
* playlistqueue: (integer, the temporary fifo playlist version number)
* xfade: <int seconds> (crossfade in seconds)
* state: ("play", "stop", or "pause")
* song: (current song stopped on or playing, playlist song number)
* songid: (current song stopped on or playing, playlist songid)
* time: <int elapsed>:<time total> (of current playing/paused song)
* bitrate: <int bitrate> (instantaneous bitrate in kbps)
* audio: <int sampleRate>:<int bits>:<int channels>
* updating_db: <int job id>
* error: if there is an error, returns message here 
get_current_song_info($command)

get_status command. Returns hashref with:

file: albums/bob_marley/songs_of_freedom/disc_four/12.bob_marley_-_could_you_be_loved_(12"_mix).flac
Time: 327
Album: Songs Of Freedom - Disc Four
Artist: Bob Marley
Title: Could You Be Loved (12" Mix)
Track: 12
Pos: 11
Id: 6601
status($level, @message)

Print to log.

logfileout

returns filehandle to log.

mas()

Reference to underlying Music::Audioscrobbler::Submit object. If passed a Music::Audioscrobbler::Submit object, will use that one instead.

new_info($cinfo)

reset current song info.

song_change($cinfo)

Run on song change

update_info()

Run on poll

monitor()

print current status to STDERR

scrobble()

Scrobble current song

run_commands()

Fork and run list of commands.

SEE ALSO

musicmpdscrobble, Music::Audioscrobbler::Submit, Music::Tag

CHANGES

Release Name: 0.13
  • Added option allow_stream, which will allow scrobbling of http streams if set to true (default false). Feature untested.

  • Fixed bug in password submition (thanks joeblow1102)

  • Added support for password@host value in MPD_HOST

  • Searched, without success, for memory leak. If anyone wants to help, uncomment the Storable lines and start looking into it...

  • Added (documented) support for Proxy server

Release Name: 0.12
  • Fixed bug that sometimes prevented Music::Tag from working at all. Added some level 4 debug messages.

Release Name: 0.11
  • Added musictag_overwrite option. This is false by default. It is a workaround for problems with Music::Tag and unicode. Setting this to true allows Music::Tag info to overwrite info from MPD. Do not set this to true until Music::Tag returns proper unicode consistantly.

Release Name: 0.1
  • Split off all scrobbling code to Music::Audioscrobbler::Submit

  • Added an error message if file is not found.

  • Added use warnings for better debugging.

  • Started using Pod::Readme for README and CHANGES

AUTHOR

Edward Allen, ealleniii _at_ cpan _dot_ org

COPYRIGHT

Copyright (c) 2007 Edward J. Allen III

Some code and inspiration from Audio::MPD Copyright (c) 2005 Tue Abrahamsen, Copyright (c) 2006 Nicholas J. Humfrey, Copyright (c) 2007 Jerome Quelin

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either:

a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or

b) the "Artistic License" which comes with Perl.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the Artistic License for more details.

You should have received a copy of the Artistic License with this Kit, in the file named "Artistic". If not, I'll be glad to provide one.

You should also have received a copy of the GNU General Public License along with this program in the file named "Copying". If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA or visit their web page on the Internet at http://www.gnu.org/copyleft/gpl.html.