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):
  12.  
  13. ## Inizializzo un dizionario di canali
  14. self.channels = {}
  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[channel] = url
  33.  
  34.  
  35. def getChannel(self, key):
  36. """Ottiene il vero canale da cui guardare.. :)"""
  37.  
  38. if not self.channels.has_key(key):
  39. return None
  40.  
  41. host = re.search(r"^.*//([^/]*)/", self.channels[key]).group(1)
  42. # print " => host = %s" % host
  43. path = re.search(r"%s/(.*)$" % host, self.channels[key]).group(1)
  44. # print " => path = %s" % path
  45.  
  46. req = urllib2.Request(self.channels[key],
  47. None,
  48. {'User-Agent': self.UA})
  49.  
  50. r = urllib2.urlopen(req)
  51. mms = r.read()
  52. mms = re.search(r"HREF=\"(\S*)\"", mms).group(1)
  53. return mms
  54.  
  55.  
  56.  
  57.