Skip to content

Instantly share code, notes, and snippets.

@tupton
Created January 16, 2011 21:33

Revisions

  1. tupton revised this gist Jan 19, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion eventcmd
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ while read L; do
    done < <(grep -e '^\(title\|artist\|album\|stationName\|pRet\|pRetStr\|wRet\|wRetStr\|songDuration\|songPlayed\|rating\)=' /dev/stdin) # don't overwrite $1...

    username='<YOUR GOOGLE USERNAME>';
    secret='<YOUR SCROBBULAR SECRET>'
    secret='<YOUR SCROBBULAR SECRET>';

    case "$1" in
    songfinish)
  2. tupton revised this gist Jan 19, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions eventcmd
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,8 @@ while read L; do
    export "$k=$v"
    done < <(grep -e '^\(title\|artist\|album\|stationName\|pRet\|pRetStr\|wRet\|wRetStr\|songDuration\|songPlayed\|rating\)=' /dev/stdin) # don't overwrite $1...

    username='username';
    secret='secret'
    username='<YOUR GOOGLE USERNAME>';
    secret='<YOUR SCROBBULAR SECRET>'

    case "$1" in
    songfinish)
  3. tupton revised this gist Jan 16, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion eventcmd
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ case "$1" in
    if [ -n "$songDuration" ] &&
    [ $(echo "scale=4; ($songPlayed/$songDuration*100)>50" | bc) -eq 1 ] &&
    [ "$rating" -ne 2 ]; then
    curl -X POST --data-urlencode "username=$username"\
    curl -X POST --data-urlencode "username=$username" \
    --data-urlencode "s=$secret" \
    --data-urlencode "track=$title" \
    --data-urlencode "artist=$artist" \
  4. tupton revised this gist Jan 16, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion eventcmd
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #!/bin/bash
    #!/bin/bash

    # create variables
    while read L; do
  5. tupton created this gist Jan 16, 2011.
    37 changes: 37 additions & 0 deletions eventcmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    #!/bin/bash

    # create variables
    while read L; do
    k="`echo "$L" | cut -d '=' -f 1`"
    v="`echo "$L" | cut -d '=' -f 2`"
    export "$k=$v"
    done < <(grep -e '^\(title\|artist\|album\|stationName\|pRet\|pRetStr\|wRet\|wRetStr\|songDuration\|songPlayed\|rating\)=' /dev/stdin) # don't overwrite $1...

    username='username';
    secret='secret'

    case "$1" in
    songfinish)
    # scrobble if 75% of the song has been played but only if the song hasn't been banned
    if [ -n "$songDuration" ] &&
    [ $(echo "scale=4; ($songPlayed/$songDuration*100)>50" | bc) -eq 1 ] &&
    [ "$rating" -ne 2 ]; then
    curl -X POST --data-urlencode "username=$username"\
    --data-urlencode "s=$secret" \
    --data-urlencode "track=$title" \
    --data-urlencode "artist=$artist" \
    --data-urlencode "duration=$((songDuration/1000))" \
    --data-urlencode "album=$album" \
    http://scrobbular.appspot.com/scrobble
    fi;
    ;;

    songstart)
    curl -X POST --data-urlencode "username=$username" \
    --data-urlencode "s=$secret" \
    --data-urlencode "track=$title" \
    --data-urlencode "artist=$artist" \
    --data-urlencode "album=$album" \
    http://scrobbular.appspot.com/now_playing
    ;;
    esac