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.  
  9. class ChannelList():
  10.  
  11. def __init__(self, liststore):
  12.  
  13. ## Inizializzo un dizionario di canali
  14. self.channels = liststore
  15.  
  16. self.UA = 'Mozilla/5.0 (X11; U; Linux i686; it; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.11'
  17.  
  18. def updateChannels(self):
  19.  
  20. ## Qui dobbiamo un pochino imbrogliare..ehm ehm
  21. req = urllib2.Request("http://www.rai.tv/dl/RaiTV/videoWall/PublishingBlock-5566288c-3d21-48dc-b3e2-af7fbe3b2af8.xml",
  22. None,
  23. { 'User-Agent': self.UA })
  24. r = urllib2.urlopen(req)
  25. self.parseChannels(r.read())
  26.  
  27. def parseChannels(self, xmlfile):
  28. """Fai il parse dei canali scaricati dalla rai"""
  29.  
  30. for channel, url in re.findall("<videoUnit name=\"([^\"]*)\".*>.*\\n.*<url>(\S*)</url>", xmlfile):
  31. url = re.sub(r"&amp;", "&", url)
  32. self.channels.append( (channel,url) )
  33.  
  34.  
  35. def getChannel(self, channel):
  36. """Ottiene il vero canale da cui guardare.. :)"""
  37.  
  38. ## Scorriamo la lista per trovare il canale desiderato
  39. # it = self.channels.get_iter_first()
  40.  
  41.  
  42.  
  43. if it is None:
  44. return None ## Qui c'è poco da fare, la lista è vuota
  45.  
  46. ## Devo trovare l'URL associato a channel
  47. while it is not None:
  48. chan, url = self.channels.get(it, 0)
  49. if chan is channel:
  50. break
  51. else:
  52. ## Incremento
  53. it = self.channels.iter_next(it)
  54.  
  55. return self.urlToMms(url)
  56.  
  57.  
  58. def getChannelFromPath(self, path):
  59. """Ottiene l'URL dello streaming puntato da path
  60. nella liststore"""
  61.  
  62. ## Ottengo l'URL
  63. it = self.channels.get_iter(path)
  64. url = self.channels.get_value(it, 1)
  65.  
  66. return self.urlToMms(url)
  67.  
  68. def urlToMms(self, url):
  69. """Converte un URL nello streaming MMS"""
  70. req = urllib2.Request(url,
  71. None,
  72. {'User-Agent': self.UA})
  73.  
  74. r = urllib2.urlopen(req)
  75. mms = r.read()
  76. mms = re.search(r"HREF=\"(\S*)\"", mms).group(1)
  77. return mms
  78.  
  79.  
  80. def getChannelList(self):
  81. return self.channels
  82.  
  83.  
  84.  
  85.