Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; XBMC Now Playing script v0.92 by hjbotha (http://forum.xbmc.org/showthread.php?t=101966)
- alias xbmc {
- ; put the host and port to your XBMC web interface here
- set %xbmc.host IP_HERE
- set %xbmc.port PORT_HERE
- ; go to the following website and generate your
- ; digest from the credentials you use to access
- ; the xbmc web interface
- ; http://www.motobit.com/util/base64-decoder-encoder.asp
- ; enter username:password
- ; hit Convert
- ; put the result here
- set %xbmc.digest DIGEST_HERE
- set %xbmc.comment $1-
- ; #### NO NEED TO EDIT BELOW THIS LINE ####
- sockopen xbmc.sock %xbmc.host %xbmc.port
- set %xbmc.window $active
- }
- on *:sockopen:xbmc.sock:{
- if ($sockerr) || (!$sock($sockname)) { echo %xbmc.window Failed to connect to XBMC server | return }
- sockwrite -n $sockname GET /xbmcCmds/xbmcHttp?command=getcurrentlyplaying HTTP/1.1
- sockwrite -n $sockname Authorization: Basic %xbmc.digest
- sockwrite -n $sockname $crlf
- }
- on *:sockread:xbmc.sock:{
- :nextread
- var %xbmc.read | sockread -f %xbmc.read
- var %xbmc.content %xbmc.content %xbmc.read
- if ($sockbr > 0) { goto nextread }
- while ($regsub(a, %xbmc.content, <[^>]+>,$chr(1),%xbmc.content) > 0) { noop }
- _xbmc.parse %xbmc.content
- }
- alias _xbmc.parse {
- var %i 1
- var %out $1-
- ;echo -s $1-
- ;echo -s $numtok(%out,1)
- while (%i < $numtok(%out,1)) {
- var %xbmc.tok $gettok(%out,%i,1)
- echo -s %i %xbmc.tok
- if (Type: isin %xbmc.tok) {
- ;echo -s type %xbmc.tok
- noop $regsub(, %xbmc.tok, ^Type:,, %xbmc.type)
- }
- if (Show Title: isin %xbmc.tok) {
- ;echo -s show title %xbmc.tok
- noop $regsub(, %xbmc.tok, ^Show Title:,, %xbmc.show)
- }
- if ($regex(,%xbmc.tok,^Title:)) {
- ;echo -s Eptitle - %xbmc.tok
- noop $regsub(, %xbmc.tok, ^Title:,, %xbmc.title)
- }
- if (Season: isin %xbmc.tok) {
- ;echo -s Season - %xbmc.tok
- noop $regsub(, %xbmc.tok, ^Season:,, %xbmc.season)
- }
- if (Episode: isin %xbmc.tok) {
- ;echo -s Episode - %xbmc.tok
- noop $regsub(, %xbmc.tok, ^Episode:,, %xbmc.episode)
- }
- if (Track: isin %xbmc.tok) {
- ;echo -s Title - %xbmc.tok
- noop $regsub(, %xbmc.tok, ^Track:,, %xbmc.track)
- }
- if (Artist: isin %xbmc.tok) {
- ;echo -s Artist - %xbmc.tok
- noop $regsub(, %xbmc.tok, ^Artist:,, %xbmc.artist)
- }
- if (Album: isin %xbmc.tok) {
- ;echo -s Album - %xbmc.tok
- noop $regsub(, %xbmc.tok, Album:,, %xbmc.album)
- }
- if (Year: isin %xbmc.tok) {
- ;echo -s Year - %xbmc.tok
- noop $regsub(, %xbmc.tok, ^Year:,, %xbmc.year)
- }
- if (First Aired: isin %xbmc.tok) {
- ;echo -s Year - %xbmc.tok
- noop $regsub(, %xbmc.tok, ^First Aired:,, %xbmc.firstaired)
- }
- %i = %i + 1
- }
- ;echo -s Type: %xbmc.type
- ;echo -s Show: %xbmc.show
- ;echo -s Title: %xbmc.title
- ;echo -s Season: %xbmc.season
- ;echo -s Episode: %xbmc.episode
- ;echo -s Year: %xbmc.year
- ;echo -s Artist: %xbmc.artist
- ;echo -s Album: %xbmc.album
- ;echo -s Track: %xbmc.track
- if (%xbmc.show != $null) {
- set %xbmc.result %xbmc.show - %xbmc.season $+ x $+ %xbmc.episode - %xbmc.title (Aired: %xbmc.firstaired $+ )
- }
- elseif (%xbmc.type == video) {
- set %xbmc.result %xbmc.title ( $+ %xbmc.year $+ )
- }
- elseif (%xbmc.type == audio) {
- set %xbmc.result %xbmc.artist - %xbmc.title $chr(91) $+ %xbmc.album $chr(40) $+ %xbmc.year $+ $chr(41) $+ $chr(93)
- }
- if (%xbmc.type) describe %xbmc.window np %xbmc.result %xbmc.comment
- elseif (Nothing Playing isin %xbmc.filename) echo %xbmc.window There is nothing playing in XBMC
- else echo %xbmc.window I was able to connect to XBMC but not to retrieve now playing data for some reason
- unset %xbmc.*
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement