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. # This file is part of RaiTV
  7. #
  8. # RaiTV is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # RaiTV is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with RaiTV; if not, write to the Free Software
  20. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21.  
  22.  
  23. import urllib2, re, httplib
  24. from xml.dom.minidom import parseString
  25.  
  26. class ChannelList():
  27.  
  28. def __init__(self, liststore):
  29.  
  30. ## Inizializzo un dizionario di canali
  31. self.channels = liststore
  32.  
  33. self.UA = 'Mozilla/5.0 (X11; U; Linux i686; it; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.11'
  34.  
  35. def updateChannels(self):
  36.  
  37. ## Qui dobbiamo un pochino imbrogliare..ehm ehm
  38. req = urllib2.Request("http://www.rai.tv/dl/RaiTV/videoWall/PublishingBlock-5566288c-3d21-48dc-b3e2-af7fbe3b2af8.xml",
  39. None,
  40. { 'User-Agent': self.UA })
  41. r = urllib2.urlopen(req)
  42. self.channels.clear()
  43. self.parseChannels(r.read())
  44.  
  45. def parseChannels(self, xmlfile):
  46. """Fai il parse dei canali scaricati dalla rai"""
  47.  
  48. dom = parseString(xmlfile)
  49. channels = dom.getElementsByTagName("set")
  50. for c in channels:
  51. ## Recupero il nome del canale
  52. name = c.getElementsByTagName("item")[0].getAttribute("name")
  53. ## Recupero l'url
  54. videounit = c.getElementsByTagName("videoUnit")
  55. url_array = []
  56. for vu in videounit:
  57. url = vu.getElementsByTagName("url")[0]
  58. if len(url.childNodes) is not 0:
  59. url_array.append(url.childNodes[0].data)
  60.  
  61. if len(url_array) is not 0:
  62. self.channels.append((name, url_array[0]))
  63.  
  64.  
  65. def getChannel(self, channel):
  66. """Ottiene il vero canale da cui guardare.. :)"""
  67.  
  68. ## Scorriamo la lista per trovare il canale desiderato
  69. # it = self.channels.get_iter_first()
  70.  
  71. if it is None:
  72. return None ## Qui c'è poco da fare, la lista è vuota
  73.  
  74. ## Devo trovare l'URL associato a channel
  75. while it is not None:
  76. chan, url = self.channels.get(it, 0)
  77. if chan is channel:
  78. break
  79. else:
  80. ## Incremento
  81. it = self.channels.iter_next(it)
  82.  
  83. return self.urlToMms(url)
  84.  
  85.  
  86. def getChannelFromPath(self, path):
  87. """Ottiene l'URL dello streaming puntato da path
  88. nella liststore"""
  89.  
  90.  
  91. ## Ottengo l'URL
  92. it = self.channels.get_iter(path)
  93. url = self.channels.get_value(it, 1)
  94.  
  95. return self.urlToMms(url)
  96.  
  97. def getChannelFromIter(self, it):
  98.  
  99. url = self.channels.get_value(it, 1)
  100. return self.urlToMms(url)
  101.  
  102.  
  103. def urlToMms(self, url):
  104. """Converte un URL nello streaming MMS"""
  105. req = urllib2.Request(url,
  106. None,
  107. {'User-Agent': self.UA})
  108.  
  109. r = urllib2.urlopen(req)
  110. mms = r.read()
  111. mms = re.search(r"HREF=\"(\S*)\"", mms).group(1)
  112.  
  113. ## Provo a vedere se riesco ad ottenere l'URL vero. Mando
  114. ## anche lo User agent fra gli header, fingendomi al solito
  115. ## firefox. Questo PER ORA NON SERVE, ma meglio prevenire
  116. ## che curare.
  117. u = re.sub(r"mms://", "http://", mms)
  118. req = urllib2.Request(u, None, {'User-Agent': self.UA})
  119.  
  120. r = urllib2.urlopen(req)
  121. reference = re.findall(r"http://(\S*)", r.read(1024))
  122. if len(reference) is not 0:
  123. ## Se è così ci serve mms over http, o almeno penso che questo
  124. ## intenda. Sembra che per altro ogni link funzioni così. Meglio! :)
  125. mms = "mmsh://" + reference[0]
  126.  
  127. return mms
  128.  
  129.  
  130. def getChannelList(self):
  131. return self.channels
  132.  
  133.  
  134.  
  135.