Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; XBMC Now Playing script v0.91 by hjbotha (http://forum.xbmc.org/showthread.php?t=101966)
- ; Modifications by MrPink
- ; MrPink's Changelog
- ; Removed %xbmc.window, replaced with $active
- ; Removed error line "I was able to connect to XBMC but not to retrieve now playing data for some reason" since it would show even when outputting correctly
- ; Added filename functionality
- alias xbmc {
- ; put the host and port to your XBMC web interface here
- set %xbmc.host 127.0.0.1
- set %xbmc.port 8080
- ; 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
- }
- 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-
- while (%i < $numtok(%out,1)) {
- var %xbmc.tok $gettok(%out,%i,1)
- ;echo -s %i %xbmc.tok
- if (Type: isin %xbmc.tok) {
- noop $regsub(, %xbmc.tok, ^Type:,, %xbmc.type)
- }
- if (Show Title: isin %xbmc.tok) {
- noop $regsub(, %xbmc.tok, ^Show Title:,, %xbmc.show)
- }
- if ($regex(,%xbmc.tok,^Title:)) {
- noop $regsub(, %xbmc.tok, ^Title:,, %xbmc.title)
- }
- if (Season: isin %xbmc.tok) {
- noop $regsub(, %xbmc.tok, ^Season:,, %xbmc.season)
- }
- if (Episode: isin %xbmc.tok) {
- noop $regsub(, %xbmc.tok, ^Episode:,, %xbmc.episode)
- }
- if (Track: isin %xbmc.tok) {
- noop $regsub(, %xbmc.tok, ^Track:,, %xbmc.track)
- }
- if (Artist: isin %xbmc.tok) {
- noop $regsub(, %xbmc.tok, ^Artist:,, %xbmc.artist)
- }
- if (Album: isin %xbmc.tok) {
- noop $regsub(, %xbmc.tok, ^\<li\>Album:,, %xbmc.album)
- }
- if (Year: isin %xbmc.tok) {
- noop $regsub(, %xbmc.tok, ^Year:,, %xbmc.year)
- }
- if (Filename: isin %xbmc.tok) {
- noop $regsub(, %xbmc.tok, ^Filename:,, %xbmc.chang)
- set %xbmc.fncnt $count(%xbmc.chang,$chr(92))
- set %xbmc.fnnum $pos(%xbmc.chang,$chr(92),%xbmc.fncnt)
- set %xbmc.fnln $len(%xbmc.chang)
- set %xbmc.fnlfnum $calc(%xbmc.fnln - %xbmc.fnnum)
- set %xbmc.fn $right(%xbmc.chang,%xbmc.fnlfnum)
- }
- %i = %i + 1
- }
- if (%xbmc.show != $null) {
- set %xbmc.result Series: %xbmc.show - %xbmc.season $+ x $+ %xbmc.episode - %xbmc.title
- }
- elseif (%xbmc.type == video) {
- set %xbmc.result Movie: %xbmc.title ( $+ %xbmc.year $+ )
- }
- elseif (%xbmc.type == audio) {
- set %xbmc.result Music: %xbmc.artist - %xbmc.title $chr(91) $+ %xbmc.album $chr(40) $+ %xbmc.year $+ $chr(41) $+ $chr(93)
- }
- if ((%xbmc.title == $null) && (%xbmc.fn != $null)) {
- set %xbmc.result File: %xbmc.fn
- }
- if (%xbmc.type) describe $active np %xbmc.result %xbmc.comment
- unset %xbmc.*
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement