document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import com.google.jplurk.*
  2. import org.cyberneko.html.parsers.*
  3.  
  4. words = [\'channel\', \'頻道\']
  5.  
  6. words.each {
  7.     word ->
  8.    
  9.     if (plurk.content.toLowerCase().endsWith(word)) {
  10.         println "match ${word}"
  11.        
  12.         ch_name = plurk.content.substring(0, plurk.content.length()-word.length()).trim()
  13.         println "查詢 ${ch_name}"
  14.        
  15.         def parser = new SAXParser()
  16.         parser.setFeature(\'http://xml.org/sax/features/namespaces\', false)
  17.         page = new XmlParser(parser).parse(\'http://www.niotv.com/i_index.php?cont=now\')
  18.        
  19.         ch_id = 0
  20.         data = page.depthFirst().A.grep {
  21.             it.value() &&
  22.             it.value().text() &&
  23.             it.value().text().toLowerCase().contains(ch_name.toLowerCase()) &&
  24.             it.\'@href\'.startsWith(\'i_index\')
  25.         }
  26.         println data
  27.         data.each {
  28.             def m = (it.\'@href\' =~ "sch_id=([0-9]+)")
  29.             ch_id = m[0][1]
  30.         }
  31.         println "發現頻道編號 ${ch_id}"
  32.        
  33.         result = []
  34.         data = page.depthFirst().A.grep { it.\'@href\' != null && it.\'@href\'.endsWith("ch_id=${ch_id}") }
  35.         data.each { result << it.value().text() }
  36.        
  37.         matched++
  38.         ship.response plurk.plurk_id, "${ch_name}正在播${result[0]},接下來播${result[1]}", Qualifier.SAYS
  39.     }
  40. }
');