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.parseChannels(r.read())
  43.  
  44. def parseChannels(self, xmlfile):
  45. """Fai il parse dei canali scaricati dalla rai"""
  46.  
  47. dom = parseString(xmlfile)
  48. channels = dom.getElementsByTagName("set")
  49. for c in channels:
  50. ## Recupero il nome del canale
  51. name = c.getElementsByTagName("item")[0].getAttribute("name")
  52. ## Recupero l'url
  53. videounit = c.getElementsByTagName("videoUnit")
  54. url_array = []
  55. for vu in videounit:
  56. url = vu.getElementsByTagName("url")[0]
  57. if url.childNodes is not []:
  58. url_array.append(url.childNodes[0].data)
  59.  
  60. if url_array is not []:
  61. self.channels.append((name, url_array[0]))
  62.  
  63.  
  64. def getChannel(self, channel):
  65. """Ottiene il vero canale da cui guardare.. :)"""
  66.  
  67. ## Scorriamo la lista per trovare il canale desiderato
  68. # it = self.channels.get_iter_first()
  69.  
  70. if it is None:
  71. return None ## Qui c'è poco da fare, la lista è vuota
  72.  
  73. ## Devo trovare l'URL associato a channel
  74. while it is not None:
  75. chan, url = self.channels.get(it, 0)
  76. if chan is channel:
  77. break
  78. else:
  79. ## Incremento
  80. it = self.channels.iter_next(it)
  81.  
  82. return self.urlToMms(url)
  83.  
  84.  
  85. def getChannelFromPath(self, path):
  86. """Ottiene l'URL dello streaming puntato da path
  87. nella liststore"""
  88.  
  89.  
  90. ## Ottengo l'URL
  91. it = self.channels.get_iter(path)
  92. url = self.channels.get_value(it, 1)
  93.  
  94. return self.urlToMms(url)
  95.  
  96. def getChannelFromIter(self, it):
  97.  
  98. url = self.channels.get_value(it, 1)
  99. return self.urlToMms(url)
  100.  
  101.  
  102. def urlToMms(self, url):
  103. """Converte un URL nello streaming MMS"""
  104. req = urllib2.Request(url,
  105. None,
  106. {'User-Agent': self.UA})
  107.  
  108. r = urllib2.urlopen(req)
  109. mms = r.read()
  110. mms = re.search(r"HREF=\"(\S*)\"", mms).group(1)
  111.  
  112. ## Provo a vedere se riesco ad ottenere l'URL vero. Mando
  113. ## anche lo User agent fra gli header, fingendomi al solito
  114. ## firefox. Questo PER ORA NON SERVE, ma meglio prevenire
  115. ## che curare.
  116. u = re.sub(r"mms://", "http://", mms)
  117. req = urllib2.Request(u, None, {'User-Agent': self.UA})
  118.  
  119. r = urllib2.urlopen(req)
  120. reference = re.findall(r"http://(\S*)", r.read(1024))
  121. if reference is not []:
  122. ## Se è così ci serve mms over http, o almeno penso che questo
  123. ## intenda. Sembra che per altro ogni link funzioni così. Meglio! :)
  124. mms = "mmsh://" + reference[0]
  125.  
  126. return mms
  127.  
  128.  
  129. def getChannelList(self):
  130. return self.channels
  131.  
  132.  
  133.  
  134.