Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2011
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. ; XBMC Now Playing script v0.91 by hjbotha (http://forum.xbmc.org/showthread.php?t=101966)
  2.  
  3. alias xbmc {
  4. ; put the host and port to your XBMC web interface here
  5. set %xbmc.host IP_HERE
  6. set %xbmc.port PORT_HERE
  7.  
  8. ; go to the following website and generate your
  9. ; digest from the credentials you use to access
  10. ; the xbmc web interface
  11. ; http://www.motobit.com/util/base64-decoder-encoder.asp
  12. ; enter username:password
  13. ; hit Convert
  14. ; put the result here
  15. set %xbmc.digest DIGEST_HERE
  16. set %xbmc.comment $1-
  17.  
  18. ; #### NO NEED TO EDIT BELOW THIS LINE ####
  19.  
  20. sockopen xbmc.sock %xbmc.host %xbmc.port
  21. set %xbmc.window $active
  22. }
  23.  
  24. on *:sockopen:xbmc.sock:{
  25. if ($sockerr) || (!$sock($sockname)) { echo %xbmc.window Failed to connect to XBMC server | return }
  26. sockwrite -n $sockname GET /xbmcCmds/xbmcHttp?command=getcurrentlyplaying HTTP/1.1
  27. sockwrite -n $sockname Authorization: Basic %xbmc.digest
  28. sockwrite -n $sockname $crlf
  29. }
  30.  
  31. on *:sockread:xbmc.sock:{
  32. :nextread
  33. var %xbmc.read | sockread -f %xbmc.read
  34. var %xbmc.content %xbmc.content %xbmc.read
  35. if ($sockbr > 0) { goto nextread }
  36. while ($regsub(a, %xbmc.content, <[^>]+>,$chr(1),%xbmc.content) > 0) { noop }
  37. _xbmc.parse %xbmc.content
  38.  
  39. }
  40.  
  41. alias _xbmc.parse {
  42. var %i 1
  43. var %out $1-
  44. while (%i < $numtok(%out,1)) {
  45. var %xbmc.tok $gettok(%out,%i,1)
  46. echo -s %i %xbmc.tok
  47.  
  48. if (Type: isin %xbmc.tok) {
  49. noop $regsub(, %xbmc.tok, ^Type:,, %xbmc.type)
  50. }
  51.  
  52. if (Show Title: isin %xbmc.tok) {
  53. noop $regsub(, %xbmc.tok, ^Show Title:,, %xbmc.show)
  54. }
  55.  
  56. if ($regex(,%xbmc.tok,^Title:)) {
  57. noop $regsub(, %xbmc.tok, ^Title:,, %xbmc.title)
  58. }
  59.  
  60. if (Season: isin %xbmc.tok) {
  61. noop $regsub(, %xbmc.tok, ^Season:,, %xbmc.season)
  62. }
  63.  
  64. if (Episode: isin %xbmc.tok) {
  65. noop $regsub(, %xbmc.tok, ^Episode:,, %xbmc.episode)
  66. }
  67.  
  68. if (Track: isin %xbmc.tok) {
  69. noop $regsub(, %xbmc.tok, ^Track:,, %xbmc.track)
  70. }
  71.  
  72. if (Artist: isin %xbmc.tok) {
  73. noop $regsub(, %xbmc.tok, ^Artist:,, %xbmc.artist)
  74. }
  75.  
  76. if (Album: isin %xbmc.tok) {
  77. noop $regsub(, %xbmc.tok, ^\<li\>Album:,, %xbmc.album)
  78. }
  79.  
  80. if (Year: isin %xbmc.tok) {
  81. noop $regsub(, %xbmc.tok, ^Year:,, %xbmc.year)
  82. }
  83. %i = %i + 1
  84. }
  85.  
  86. if (%xbmc.show != $null) {
  87. set %xbmc.result Series: %xbmc.show - %xbmc.season $+ x $+ %xbmc.episode - %xbmc.title
  88. }
  89. elseif (%xbmc.type == video) {
  90. set %xbmc.result Movie: %xbmc.title ( $+ %xbmc.year $+ )
  91. }
  92. elseif (%xbmc.type == audio) {
  93. set %xbmc.result Music: %xbmc.artist - %xbmc.title $chr(91) $+ %xbmc.album $chr(40) $+ %xbmc.year $+ $chr(41) $+ $chr(93)
  94. }
  95. if (%xbmc.type) describe %xbmc.window np %xbmc.result %xbmc.comment
  96. elseif (Nothing Playing isin %xbmc.filename) echo %xbmc.window There is nothing playing in XBMC
  97. else echo %xbmc.window I was able to connect to XBMC but not to retrieve now playing data for some reason
  98. unset %xbmc.*
  99. return
  100. }
  101.  
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement