viewgit/index.php:465 Only variables should be passed by reference [2048]

viewgit/index.php:466 Non-static method GeSHi::get_language_name_from_extension() should not be called statically [2048]

  1. #
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Scarica la lista di URI per vedere i canali rai
  5. #
  6.  
  7. import urllib2, re, httplib
  8. from xml.dom.minidom import parseString
  9.  
  10. class ChannelList():
  11.  
  12. def __init__(self, liststore):
  13.  
  14. ## Inizializzo un dizionario di canali
  15. self.channels = liststore
  16.  
  17. self.UA = 'Mozilla/5.0 (X11; U; Linux i686; it; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.11'
  18.  
  19. def updateChannels(self):
  20.  
  21. ## Qui dobbiamo un pochino imbrogliare..ehm ehm
  22. req = urllib2.Request("http://www.rai.tv/dl/RaiTV/videoWall/PublishingBlock-5566288c-3d21-48dc-b3e2-af7fbe3b2af8.xml",
  23. None,
  24. { 'User-Agent': self.UA })
  25. r = urllib2.urlopen(req)
  26. self.parseChannels(r.read())
  27.  
  28. def parseChannels(self, xmlfile):
  29. """Fai il parse dei canali scaricati dalla rai"""
  30.  
  31. dom = parseString(xmlfile)
  32. channels = dom.getElementsByTagName("set")
  33. for c in channels:
  34. ## Recupero il nome del canale
  35. name = c.getElementsByTagName("item")[0].getAttribute("name")
  36. ## Recupero l'url
  37. videounit = c.getElementsByTagName("videoUnit")
  38. url_array = []
  39. for vu in videounit:
  40. url = vu.getElementsByTagName("url")[0]
  41. if url.childNodes is not []:
  42. url_array.append(url.childNodes[0].data)
  43.  
  44. if url_array is not []:
  45. self.channels.append((name, url_array[0]))
  46.  
  47.  
  48. def getChannel(self, channel):
  49. """Ottiene il vero canale da cui guardare.. :)"""
  50.  
  51. ## Scorriamo la lista per trovare il canale desiderato
  52. # it = self.channels.get_iter_first()
  53.  
  54. if it is None:
  55. return None ## Qui c'è poco da fare, la lista è vuota
  56.  
  57. ## Devo trovare l'URL associato a channel
  58. while it is not None:
  59. chan, url = self.channels.get(it, 0)
  60. if chan is channel:
  61. break
  62. else:
  63. ## Incremento
  64. it = self.channels.iter_next(it)
  65.  
  66. return self.urlToMms(url)
  67.  
  68.  
  69. def getChannelFromPath(self, path):
  70. """Ottiene l'URL dello streaming puntato da path
  71. nella liststore"""
  72.  
  73.  
  74. ## Ottengo l'URL
  75. it = self.channels.get_iter(path)
  76. url = self.channels.get_value(it, 1)
  77.  
  78. return self.urlToMms(url)
  79.  
  80. def getChannelFromIter(self, it):
  81.  
  82. url = self.channels.get_value(it, 1)
  83. return self.urlToMms(url)
  84.  
  85.  
  86. def urlToMms(self, url):
  87. """Converte un URL nello streaming MMS"""
  88. req = urllib2.Request(url,
  89. None,
  90. {'User-Agent': self.UA})
  91.  
  92. r = urllib2.urlopen(req)
  93. mms = r.read()
  94. mms = re.search(r"HREF=\"(\S*)\"", mms).group(1)
  95. print "mms url // " + mms
  96. return mms
  97.  
  98.  
  99. def getChannelList(self):
  100. return self.channels
  101.  
  102.  
  103.  
  104.