Firmware: A-410 [01 Apr. 2014] | A-400 [12 Mar. 2014] | C-300 [13 Feb. 2014] | A-300 [24 Feb. 2014] | C-200 [11 July 2013] | A-200/A-210 [11 July 2013] | Popbox V8 [3 Dec 2013]

Just got your NMT | WIKI has the answers | Search the forum | Forum Rules/Policy | Firmware & Official NMT News | Popcornhour manuals



User(s) browsing this thread: 1 Guest(s)
Thread Closed 
[AUDIO] lastfm script (bookmarks, auto-login, etc.)
01-16-2009, 10:16 PM (This post was last modified: 03-01-2009 08:47 PM by mk11.)
Post: #1
[AUDIO] lastfm script (bookmarks, auto-login, etc.)
EDIT: Version 0.2.1 is now available. It has some bug fixes and some new (small) features. Download it from here: http://www.mediafire.com/?k41egfgg10d and follow the instructions for version 0.2 (below).

EDIT: Here comes a new version that works now, and also has some more features. It's still not completely finished, but it's already in a usable state (see below for limitations). The instructions are slightly different now -- I leave the original post just for reference.

New instructions:

1. Download the .zip archive from http://www.mediafire.com/?nrnnuenexyy and unpack it to your NMT hard drive (e.g., the top directory).

2. Make files lastfm-cli.cgi and lastfm-downloader.sh executable (see in this thread for instructions on how to do it).

3. Edit the configuration file lastfm-cli-config.txt: you must enter there your last.fm user name and an MD5 hash of your password (use, e.g., http://www.fileformat.info/tool/hash.htm to compute the MD5 hash). You should also put there your last.fm bookmarks (3 of them are already there, but they are just an example). If you know CSS, you can also change the look of the pages generated by the script (I'm looking forward to some nice themes on this thread).

4. If you installed the files in the top directory of your NMT hard drive, skip to step 5. Otherwise, you have to edit file lastfm-bookmarks.html and put the correct path there.

5. The first time you select file lastfm-bookmarks.html nothing will show up until you press "stop" on your remote (but wait a few seconds before doing so -- the script must start some background services).

Quick manual: select a bookmark and then either choose one song to play (rather impractical -- see the limitations) or select "Play station". "Next" gets a new playlist.

Note: the script stores a lot of data in the folder set in the configuration file (Music/lastfm-cli-cache by default). Click on "Clear cache" to delete all the files from this directory (you should probably do it once in a while).

Current limitations:

1. It takes a long time before playback starts.
2. If you stop playback in the middle of a song, it might be impossible to play anything else for some time.
3. The installation procedure is long -- an installer would be nice.
4. The script downloads the songs to the cache directory, so there might be some legal issues in some countries. (I take no responsibility for any problems you might encounter.)

Old contents of this post follows.
---------------------------------------------

Here is a script that I wrote and find more convenient to use for listening to last.fm than the MSP portal. I'd say it's not exactly for total beginners, but if you know how to use FTP and write simple web pages, you should be fine using it. Standard disclaimer applies: the code is public domain but I take no responsibility if it doesn't work or breaks something in your system.

Here are the instructions:

1. Create a file "lastfm-cli.cgi" and copy the following code into it:

Code:
#!/bin/sh

USER="lastfm-username"
PASSWD="md5sum-of-lastfm-password"

if [ -z "$QUERY_STRING" ] ; then
        LASTFM_URL=$1
        CGI="false"
else
        LASTFM_URL="lastfm://$QUERY_STRING"
        CGI="true"
fi

if [ -z "$LASTFM_URL" ] ; then
        echo "syntax: lastfm-cli.cgi lastfm-url"
        echo "(if not run via CGI)"
        exit 1
fi

SESSION_FILE="/tmp/lastfm-cli-session"
VER="1.3.1.1"
LANG="en"
PLAYER="custom"

print_headers() {
        if [ $CGI == "true" ] ; then
                echo "Content-type: text/html"
                echo
                echo "<html><body><h2>Playing: ${LASTFM_URL}</h2>"
        fi
}

print_closing_tags() {
        if [ $CGI == "true" ] ; then
                echo "</body></html>"
        fi
}

init_session() {
        INIT_URL="http://ws.audioscrobbler.com/radio/handshake.php?version=${VER}&platform=linux&username=${USER}&passwordmd5=${PASSWD}&language=${LANG}&player=${PLAYER}"
        wget -q -O $SESSION_FILE "$INIT_URL"
        if grep 'session=FAILED' $SESSION_FILE > /dev/null 2>&1 ; then
                echo "Handshake error:"
                echo $(cat $SESSION_FILE | grep 'msg' | cut -d '=' -f 2-)
                rm $SESSION_FILE
                print_closing_tags
                exit 1
        fi
}

print_headers

if [ ! -e $SESSION_FILE ] ; then
        init_session
fi

STREAM_URL=$(cat $SESSION_FILE | grep 'stream_url' | cut -d '=' -f 2-)
SESSION=$(cat $SESSION_FILE | grep 'session')

SET_STATION_URL="http://ws.audioscrobbler.com/radio/adjust.php?${SESSION}&url=${LASTFM_URL}&debug=0"
wget -q -O - "$SET_STATION_URL" > /dev/null

if [ $CGI == "true" ] ; then
        echo "<a href=\"$STREAM_URL\" aod>PLAY</a>"
else
        echo "$STREAM_URL"
fi

print_closing_tags

2. Change in this file "lastfm-username" to your lastfm username, and "md5sum-of-lastfm-password" to the md5 hash of your lastfm password (you can use, e.g., http://www.fileformat.info/tool/hash.htm to compute the md5 hash).

3. Copy the file "lastfm-cli.cgi" to your Popcorn Hour: either to the hard drive (e.g., via FTP) or to a USB pendrive. Make sure the file is executable, e.g., using FTP:

Code:
site chmod 755 lastfm-cli.cgi

4. Create a HTML file with your lastfm bookmarks. Here is an example (this assumes you put "lastfm-cli.cgi" in the root directory of the hard drive):

Code:
<html><body><h1>Last.fm bookmarks:</h1>
<a href="http://localhost.drives:8883/HARD_DISK/lastfm-cli.cgi?artist/Air">artist/Air</a><br>
<a href="http://localhost.drives:8883/HARD_DISK/lastfm-cli.cgi?artist/Delerium">artist/Delerium</a><br>
<a href="http://localhost.drives:8883/HARD_DISK/lastfm-cli.cgi?artist/Gerardo+Nunez">artist/Gerardo+Nunez</a><br>
</body></html>

You get the point. For USB pendrive you have to replace "HARD_DISK" with "USB_DRIVE_A" or "USB_DRIVE_B".

5. Open the HTML file (as a playlist) on your Popcorn, choose the bookmark, select PLAY, and enjoy!

A note for advanced users: the script also works directly in the command-line. It then outputs an URL that you can pass directly to mono for playback.
Find all posts by this user
[+] 1 user says Thank You to mk11 for this post
01-17-2009, 12:13 AM (This post was last modified: 01-17-2009 12:16 AM by empatico.)
Post: #2
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
I will try because i need an user-friendly way to listen lastfm for my parents. Could you provide some URLs for playing genres, tags or users radios?
Find all posts by this user
01-17-2009, 08:52 PM
Post: #3
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
(01-17-2009 12:13 AM)empatico Wrote:  I will try because i need an user-friendly way to listen lastfm for my parents. Could you provide some URLs for playing genres, tags or users radios?

Global tags: globaltags/jazz
Library: user/user-name/personal
Loved: user/user-name/loved
Neighbours: user/user-name/neighbours
Recommendations: user/user-name/recommended

In general: if you set in your lastfm profile settings "use external player" (or something like that), then the links to radio stations become in the form of "lastfm://some/station" -- then you use "some/station" in the script.
Find all posts by this user
01-18-2009, 01:57 PM
Post: #4
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
Thank you for your great job. It works perfectly and easy for my parents.
Find all posts by this user
01-18-2009, 09:38 PM
Post: #5
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
(01-18-2009 01:57 PM)empatico Wrote:  Thank you for your great job. It works perfectly and easy for my parents.

when I do the site chmod 755 lastfm-cli.cgi with telnet, I get a "/bin/sh:site:not found" error
Find all posts by this user
01-18-2009, 09:42 PM
Post: #6
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
(01-18-2009 09:38 PM)ricocarlos Wrote:  when I do the site chmod 755 lastfm-cli.cgi with telnet, I get a "/bin/sh:site:not found" error

Via telnet use:

Quote:chmod 755 lastfm-cli.cgi

(without "site")
Find all posts by this user
01-19-2009, 05:04 AM
Post: #7
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
Thank you, that worked. What do you put in the html file to make it play your radio station?
Find all posts by this user
01-19-2009, 01:14 PM (This post was last modified: 01-19-2009 01:20 PM by empatico.)
Post: #8
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
My own lastfm.htm file:

http://www.uar.jazztel.es/Documentos/lastfm.htm

Edit it with your own users, genres and artists. Also edit the path to your own file lastfm-cli.cgi
Find all posts by this user
01-19-2009, 03:22 PM
Post: #9
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
Excellent. I put mine on a share and named it index.htm, so that when I click on the share it launches. I will be copying your file. Thank you very much.
Find all posts by this user
01-19-2009, 04:30 PM (This post was last modified: 01-19-2009 04:31 PM by ricocarlos.)
Post: #10
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
Now you guys need to get a cgi for Pandora...do that and you shall rule the world.
Find all posts by this user
01-20-2009, 04:59 AM
Post: #11
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
thanks again, empatico, I modified your file added a kickin background to it, and it is so freakin sweet. Now, is there a way to get it to play once you select an option, rather than selecting it and then having to tell it to play?
And is there any way possible to get album art to display??
I actually feel guilty asking for more from this near perfect app. This totally makes the PCH such a more powerful device.
Find all posts by this user
01-20-2009, 02:41 PM (This post was last modified: 01-20-2009 02:43 PM by empatico.)
Post: #12
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
(01-20-2009 04:59 AM)ricocarlos Wrote:  Now, is there a way to get it to play once you select an option, rather than selecting it and then having to tell it to play?

The only way to do that it's editing the lastfm-cli.cgi script. I have no cgi skills, maybe mk11 can help you with that.

(01-20-2009 04:59 AM)ricocarlos Wrote:  And is there any way possible to get album art to display??

Same here, it need lastfm-cli.cgi script changes. Also i prefer shutdown my television and listen the music with my hifi because having a fixed image during long time could hang the television.

(01-20-2009 04:59 AM)ricocarlos Wrote:  I actually feel guilty asking for more from this near perfect app. This totally makes the PCH such a more powerful device.

You can try the http://nmt.kowalczuk.eu/last.fm/ msp plug in. It is more powerful than lastfm-cli.cgi script. I prefer lastfm-cli.cgi script because it's just what my parents and i need. keep it simple! Big Grin

mk11 really did a good job and he deserves our thanks.
Find all posts by this user
01-20-2009, 03:09 PM
Post: #13
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
Rock on, mk11, you did a yeoman's job here.
Find all posts by this user
01-22-2009, 02:26 AM (This post was last modified: 01-22-2009 02:26 AM by meowmoo.)
Post: #14
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
I cant get it to work :/

i copy the lastfm-cli.cgi and the lastfm.htm via samba to the popcorn

and when i start an bookmark from the htm the error screen come Sad

lastfm-cli.cgi is in the ROOT and the htm looks like this

Code:
http://localhost.drives:8883/HARD_DISK/lastfm-cli.cgi?user/emtee_elp/personal

do i miss something?
Find all posts by this user
01-22-2009, 04:18 PM
Post: #15
RE: [AUDIO] lastfm script (bookmarks, auto-login, etc.)
I am giving upSad

It wont start the .cgi no matter where it is usb/root/newfolder in root....
Find all posts by this user
Thread Closed 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Bierdopje auto-sub for A-110 BeeVee 19 5,628 12-27-2013 09:12 AM
Last Post: Djiest
  Pure Web Remote Control or Listening Audio with switched off TV pompon 170 86,235 10-08-2013 03:24 PM
Last Post: alkr
Star [Apps] Bierdopje 4 NMT PHP script SilverViper 4 2,447 11-26-2012 04:57 PM
Last Post: Djiest
  Audio App to play lists or whole directories? danielfm 1 1,312 01-24-2012 12:55 AM
Last Post: geerten
  PCH Audio playlist format? Nono 4 2,378 10-05-2011 10:10 PM
Last Post: Nono
  Need help debugging a simple script to enable NTFS write on HDD user33 10 4,416 04-05-2011 06:05 PM
Last Post: nuke12
  Help with Server Timeout Error running a script hindibuff 0 2,164 03-29-2011 06:21 AM
Last Post: hindibuff
Bug Executing a script on the server from the NMT? johnk 6 4,152 02-21-2011 10:59 PM
Last Post: johnk
  Stream movie audio over network Irri 0 1,749 11-06-2010 11:52 AM
Last Post: Irri
  help with auto unrar script. kiranos 0 2,092 05-15-2010 10:24 AM
Last Post: kiranos

Forum Jump: