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]
# # -*- coding: utf-8 -*- # # Scarica la lista di URI per vedere i canali rai # # This file is part of RaiTV # # RaiTV is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # RaiTV is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with RaiTV; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import urllib2, re, httplib from xml.dom.minidom import parseString class ChannelList(): def __init__(self, liststore): ## Inizializzo un dizionario di canali self.channels = liststore self.UA = 'Mozilla/5.0 (X11; U; Linux i686; it; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.11' def updateChannels(self): ## Qui dobbiamo un pochino imbrogliare..ehm ehm req = urllib2.Request("http://www.rai.tv/dl/RaiTV/videoWall/PublishingBlock-5566288c-3d21-48dc-b3e2-af7fbe3b2af8.xml", None, { 'User-Agent': self.UA }) r = urllib2.urlopen(req) self.channels.clear() self.parseChannels(r.read()) def parseChannels(self, xmlfile): """Fai il parse dei canali scaricati dalla rai""" dom = parseString(xmlfile) channels = dom.getElementsByTagName("set") for c in channels: ## Recupero il nome del canale name = c.getElementsByTagName("item")[0].getAttribute("name") ## Recupero l'url videounit = c.getElementsByTagName("videoUnit") url_array = [] for vu in videounit: url = vu.getElementsByTagName("url")[0] if len(url.childNodes) is not 0: url_array.append(url.childNodes[0].data) if len(url_array) is not 0: self.channels.append((name, url_array[0])) def getChannel(self, channel): """Ottiene il vero canale da cui guardare.. :)""" ## Scorriamo la lista per trovare il canale desiderato # it = self.channels.get_iter_first() if it is None: return None ## Qui c'è poco da fare, la lista è vuota ## Devo trovare l'URL associato a channel while it is not None: chan, url = self.channels.get(it, 0) if chan is channel: break else: ## Incremento it = self.channels.iter_next(it) return self.urlToMms(url) def getChannelFromPath(self, path): """Ottiene l'URL dello streaming puntato da path nella liststore""" ## Ottengo l'URL it = self.channels.get_iter(path) url = self.channels.get_value(it, 1) return self.urlToMms(url) def getChannelFromIter(self, it): url = self.channels.get_value(it, 1) return self.urlToMms(url) def urlToMms(self, url): """Converte un URL nello streaming MMS""" req = urllib2.Request(url, None, {'User-Agent': self.UA}) r = urllib2.urlopen(req) mms = r.read() mms = re.search(r"HREF=\"(\S*)\"", mms).group(1) ## Provo a vedere se riesco ad ottenere l'URL vero. Mando ## anche lo User agent fra gli header, fingendomi al solito ## firefox. Questo PER ORA NON SERVE, ma meglio prevenire ## che curare. u = re.sub(r"mms://", "http://", mms) req = urllib2.Request(u, None, {'User-Agent': self.UA}) r = urllib2.urlopen(req) reference = re.findall(r"http://(\S*)", r.read(1024)) if len(reference) is not 0: ## Se è così ci serve mms over http, o almeno penso che questo ## intenda. Sembra che per altro ogni link funzioni così. Meglio! :) mms = "mmsh://" + reference[0] return mms def getChannelList(self): return self.channels