Advertisement
Guest User

Untitled

a guest
Jan 19th, 2012
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. ; XBMC Now Playing script v0.92 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. ;echo -s $1-
  45. ;echo -s $numtok(%out,1)
  46. while (%i < $numtok(%out,1)) {
  47. var %xbmc.tok $gettok(%out,%i,1)
  48. echo -s %i %xbmc.tok
  49.  
  50. if (Type: isin %xbmc.tok) {
  51. ;echo -s type %xbmc.tok
  52. noop $regsub(, %xbmc.tok, ^Type:,, %xbmc.type)
  53. }
  54.  
  55. if (Show Title: isin %xbmc.tok) {
  56. ;echo -s show title %xbmc.tok
  57. noop $regsub(, %xbmc.tok, ^Show Title:,, %xbmc.show)
  58. }
  59.  
  60. if ($regex(,%xbmc.tok,^Title:)) {
  61. ;echo -s Eptitle - %xbmc.tok
  62. noop $regsub(, %xbmc.tok, ^Title:,, %xbmc.title)
  63. }
  64.  
  65. if (Season: isin %xbmc.tok) {
  66. ;echo -s Season - %xbmc.tok
  67. noop $regsub(, %xbmc.tok, ^Season:,, %xbmc.season)
  68. }
  69.  
  70. if (Episode: isin %xbmc.tok) {
  71. ;echo -s Episode - %xbmc.tok
  72. noop $regsub(, %xbmc.tok, ^Episode:,, %xbmc.episode)
  73. }
  74.  
  75. if (Track: isin %xbmc.tok) {
  76. ;echo -s Title - %xbmc.tok
  77. noop $regsub(, %xbmc.tok, ^Track:,, %xbmc.track)
  78. }
  79.  
  80. if (Artist: isin %xbmc.tok) {
  81. ;echo -s Artist - %xbmc.tok
  82. noop $regsub(, %xbmc.tok, ^Artist:,, %xbmc.artist)
  83. }
  84.  
  85. if (Album: isin %xbmc.tok) {
  86. ;echo -s Album - %xbmc.tok
  87. noop $regsub(, %xbmc.tok, Album:,, %xbmc.album)
  88. }
  89.  
  90. if (Year: isin %xbmc.tok) {
  91. ;echo -s Year - %xbmc.tok
  92. noop $regsub(, %xbmc.tok, ^Year:,, %xbmc.year)
  93. }
  94. if (First Aired: isin %xbmc.tok) {
  95. ;echo -s Year - %xbmc.tok
  96. noop $regsub(, %xbmc.tok, ^First Aired:,, %xbmc.firstaired)
  97. }
  98.  
  99. %i = %i + 1
  100. }
  101.  
  102. ;echo -s Type: %xbmc.type
  103. ;echo -s Show: %xbmc.show
  104. ;echo -s Title: %xbmc.title
  105. ;echo -s Season: %xbmc.season
  106. ;echo -s Episode: %xbmc.episode
  107. ;echo -s Year: %xbmc.year
  108. ;echo -s Artist: %xbmc.artist
  109. ;echo -s Album: %xbmc.album
  110. ;echo -s Track: %xbmc.track
  111. if (%xbmc.show != $null) {
  112. set %xbmc.result %xbmc.show - %xbmc.season $+ x $+ %xbmc.episode - %xbmc.title (Aired: %xbmc.firstaired $+ )
  113. }
  114. elseif (%xbmc.type == video) {
  115. set %xbmc.result %xbmc.title ( $+ %xbmc.year $+ )
  116. }
  117. elseif (%xbmc.type == audio) {
  118. set %xbmc.result %xbmc.artist - %xbmc.title $chr(91) $+ %xbmc.album $chr(40) $+ %xbmc.year $+ $chr(41) $+ $chr(93)
  119. }
  120. if (%xbmc.type) describe %xbmc.window np %xbmc.result %xbmc.comment
  121. elseif (Nothing Playing isin %xbmc.filename) echo %xbmc.window There is nothing playing in XBMC
  122. else echo %xbmc.window I was able to connect to XBMC but not to retrieve now playing data for some reason
  123. unset %xbmc.*
  124. return
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement