The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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();

AUTHOR

Edward Allen, ealleniii _at_ cpan _dot_ org

DESCRIPTION

Music::Audioscrobbler::MPD is a scrobbler for MPD. It may one day be distributed in a package called Music::Audioscrobbler, but is independent at the momment.

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

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 throuch 4)

logfile

File to output loginfo to

scrobblequue

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

musicdb

True to use MusicDB plugin for Music::Tag

music_tag_opts

Options for Music::Tag

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

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.

ua()

returns or optionally sets LWP UA.

info_to_hash

Converts a Music::Tag object, a hash, or a filename to a simple hash for processing.

music_tag_opts()

Get or set music_tag_opts

get_info_from_file()

use Music::Tag to get info from a file.

scrobble_queue()

Reference to queue of files to scrobble.

handshake()

Perform handshake with Last.FM

now_playing

Takes filename / Music::Tag object / Generic Hash as value and submits to last.fm

get_mbid()

Use Music::Brainz to get mbid for a Music::Tag object. Requires Music::Tag::MusicBrainz;

submit

Takes filename / Music::Tag object / Generic Hash as value and submits to last.fm

process_scrobble_queue

Process up to 50 files from scrobble_queue. Recursivly calls itself if necessary / possible to empty scrobble_queue

SEE ALSO

musicmpdscrobble, Music::Tag

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

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.