Advertisement
Guest User

Untitled

a guest
Nov 24th, 2011
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. ; XBMC Now Playing script v0.91 by hjbotha (http://forum.xbmc.org/showthread.php?t=101966)
  2. ; Modifications by MrPink
  3. ; MrPink's Changelog
  4. ; Removed %xbmc.window, replaced with $active
  5. ; 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
  6. ; Added filename functionality
  7. alias xbmc {
  8. ; put the host and port to your XBMC web interface here
  9. set %xbmc.host 127.0.0.1
  10. set %xbmc.port 8080
  11.  
  12. ; go to the following website and generate your
  13. ; digest from the credentials you use to access
  14. ; the xbmc web interface
  15. ; http://www.motobit.com/util/base64-decoder-encoder.asp
  16. ; enter username:password
  17. ; hit Convert
  18. ; put the result here
  19. set %xbmc.digest DIGEST_HERE
  20. set %xbmc.comment $1-
  21.  
  22. ; #### NO NEED TO EDIT BELOW THIS LINE ####
  23.  
  24. sockopen xbmc.sock %xbmc.host %xbmc.port
  25. }
  26.  
  27. on *:sockopen:xbmc.sock:{
  28. if ($sockerr) || (!$sock($sockname)) { echo %xbmc.window Failed to connect to XBMC server | return }
  29. sockwrite -n $sockname GET /xbmcCmds/xbmcHttp?command=getcurrentlyplaying HTTP/1.1
  30. sockwrite -n $sockname Authorization: Basic %xbmc.digest
  31. sockwrite -n $sockname $crlf
  32. }
  33.  
  34. on *:sockread:xbmc.sock:{
  35. :nextread
  36. var %xbmc.read | sockread -f %xbmc.read
  37. var %xbmc.content %xbmc.content %xbmc.read
  38. if ($sockbr > 0) { goto nextread }
  39. while ($regsub(a, %xbmc.content, <[^>]+>,$chr(1),%xbmc.content) > 0) { noop }
  40. _xbmc.parse %xbmc.content
  41. }
  42.  
  43. alias _xbmc.parse {
  44. var %i 1
  45. var %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. noop $regsub(, %xbmc.tok, ^Type:,, %xbmc.type)
  52. }
  53.  
  54. if (Show Title: isin %xbmc.tok) {
  55. noop $regsub(, %xbmc.tok, ^Show Title:,, %xbmc.show)
  56. }
  57.  
  58. if ($regex(,%xbmc.tok,^Title:)) {
  59. noop $regsub(, %xbmc.tok, ^Title:,, %xbmc.title)
  60. }
  61.  
  62. if (Season: isin %xbmc.tok) {
  63. noop $regsub(, %xbmc.tok, ^Season:,, %xbmc.season)
  64. }
  65.  
  66. if (Episode: isin %xbmc.tok) {
  67. noop $regsub(, %xbmc.tok, ^Episode:,, %xbmc.episode)
  68. }
  69.  
  70. if (Track: isin %xbmc.tok) {
  71. noop $regsub(, %xbmc.tok, ^Track:,, %xbmc.track)
  72. }
  73.  
  74. if (Artist: isin %xbmc.tok) {
  75. noop $regsub(, %xbmc.tok, ^Artist:,, %xbmc.artist)
  76. }
  77.  
  78. if (Album: isin %xbmc.tok) {
  79. noop $regsub(, %xbmc.tok, ^\<li\>Album:,, %xbmc.album)
  80. }
  81.  
  82. if (Year: isin %xbmc.tok) {
  83. noop $regsub(, %xbmc.tok, ^Year:,, %xbmc.year)
  84. }
  85. if (Filename: isin %xbmc.tok) {
  86. noop $regsub(, %xbmc.tok, ^Filename:,, %xbmc.chang)
  87. set %xbmc.fncnt $count(%xbmc.chang,$chr(92))
  88. set %xbmc.fnnum $pos(%xbmc.chang,$chr(92),%xbmc.fncnt)
  89. set %xbmc.fnln $len(%xbmc.chang)
  90. set %xbmc.fnlfnum $calc(%xbmc.fnln - %xbmc.fnnum)
  91. set %xbmc.fn $right(%xbmc.chang,%xbmc.fnlfnum)
  92. }
  93. %i = %i + 1
  94. }
  95.  
  96. if (%xbmc.show != $null) {
  97. set %xbmc.result Series: %xbmc.show - %xbmc.season $+ x $+ %xbmc.episode - %xbmc.title
  98. }
  99. elseif (%xbmc.type == video) {
  100. set %xbmc.result Movie: %xbmc.title ( $+ %xbmc.year $+ )
  101. }
  102. elseif (%xbmc.type == audio) {
  103. set %xbmc.result Music: %xbmc.artist - %xbmc.title $chr(91) $+ %xbmc.album $chr(40) $+ %xbmc.year $+ $chr(41) $+ $chr(93)
  104. }
  105. if ((%xbmc.title == $null) && (%xbmc.fn != $null)) {
  106. set %xbmc.result File: %xbmc.fn
  107. }
  108. if (%xbmc.type) describe $active np %xbmc.result %xbmc.comment
  109. unset %xbmc.*
  110. return
  111. }
  112.  
  113.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement