[vlc-devel] [PATCH] Make VLC scrobble through the Official client if possible.

Peter Grundström pete at openfestis.org
Tue Jul 1 18:59:53 CEST 2008


Hi vlc-devel,

my name is Peter Grundström and I work on the Last.fm Client Team. VLC
already have support for scrobbling (The act of reporting to Last.fm what
you just listen to) but this is by using our webservices directly. This
patch also adds support for scrobbling via the official client, if
available. This have some advantages like having more information about the
track in the Last.fm client and also have access the socialnetwork aspects.

I was a bit uncertain if to make this a whole new module but I chose to
integrate it in the existing. Please tell me if you would like it the other
way around.

When this patch is applied the audioscrobbler module will try to scrobble
through the client if possible. This works by opening a socket to the
Last.fm client and the sending commands over it. If it fails it will revert
to use the webservices directly. The only time you will lose scrobbles is if
you start playing a track while the Last.fm client is running and the close
it before the you reach the scrobblepoint ( 4 min or middle of the track ).
This is as far as I can see impossible to fix since we cant know when the
Last.fm client closes and if we scrobble the same track twice we will
trigger spam protection.

Here are some comments on the changes I made:

> -        a = encode_URI_component( psz_meta ); \
> +        a = strdup( psz_meta ); \

The audioscrobbler module earlier stored the metadata of the track in
percent encoding. This is the right format when sending it to the
webservice, but wont work when sending it through the socket to the client.
I changed it to store the metadata unencoded and then encode it before it
sends it to the webservice or through the socket.

> input_item_GetURL( p_item );

One of the problems I had was not being able to get a hold of the path of
the current file. Is the above function the one I'm supposed to use.

Another one was that when the VLC is closed I need to send the stop command
to Last.fm. I tried sending the command in several places Close, Unload and
Run (audioscrobbler is dying part...). But every time the thread gets killed
before the Last.fm client has time to read from the other end of the socket.
Please advise.

> +static int TransmitStart    ( intf_thread_t *p_this );
> +static int TransmitStop     ( intf_thread_t *p_this );
> +static int TransmitResume   ( intf_thread_t *p_this );
> +static int TransmitPause    ( intf_thread_t *p_this );
> +static int Transmit         ( intf_thread_t *p_this, const char* message
);

This is the functions where the magic happens. Transmit opens a socket to
the Last.fm client and sends a message. The Transmit* functions creates the
appropriate messages for that action and calls Transmit.

While doing this I also found a bug in the old code (still present). If you
enable scrobbling and then dont enter a username and password, the client
will crash when trying to scrobble via the webservice.

j-b: The thing we talked about regarding the Pvlc flag in the call to the
webservice. I talked to max about it and it's not necessary but if you do we
can give you statistics over how many scrobbles made from VLC.

Attached is a git diff over my changes.

--
Regards
Peter Grundtröm
Last.fm Client Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20080701/3b3a0203/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: audioscrobbler_client_scrobble.diff
Type: text/x-diff
Size: 12304 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20080701/3b3a0203/attachment.diff>


More information about the vlc-devel mailing list