Exemple #1
0
 def getDayEpg(self, id, date=None):
     if not date:
         date = syncTime()
     print date
     params = {
         "cid":
         id,
         "from_uts":
         datetime.datetime(date.year, date.month, date.day).strftime('%s'),
         "hours":
         24
     }
     root = self.getData(self.site + "/get_epg?" + urllib.urlencode(params),
                         "EPG for channel %s" % id)
     epglist = []
     self.channels[id].lepg[date.strftime("%y%m%d")] = []
     for prog in root.find('channels').find('item').find('epg'):
         title = prog.findtext('title').encode('utf-8') + '\n'
         title += prog.findtext('info').encode('utf-8')
         t_start = datetime.datetime.fromtimestamp(
             int(prog.findtext('begin').encode('utf-8')))
         t_end = datetime.datetime.fromtimestamp(
             int(prog.findtext('end').encode('utf-8')))
         self.channels[id].lepg[date.strftime("%y%m%d")] += [
             EpgEntry(title, t_start, t_end)
         ]
         epglist += [(t_start, title.split('\n')[0], title.split('\n')[1])]
     return epglist
Exemple #2
0
 def getStreamUrl(self, id, pin):
     params = {"cid": id}
     if self.channels[id].is_protected:
         params["protect_code"] = self.protect_code
     if self.aTime:
         params["uts"] = (syncTime() + secTd(self.aTime)).strftime("%s")
     root = self.getData(self.site + "/get_url_tv?" + urllib.urlencode(params), "stream url")
     return root.findtext("url").encode("utf-8")
Exemple #3
0
 def getStreamUrl(self, id, pin):
     params = {"cid": id}
     if self.channels[id].is_protected:
         params["protect_code"] = self.protect_code
     if self.aTime:
         params["uts"] = (syncTime() + secTd(self.aTime)).strftime("%s")
     root = self.getData(
         self.site + "/get_url_tv?" + urllib.urlencode(params),
         "stream url")
     return root.findtext("url").encode("utf-8")
Exemple #4
0
 def getGmtEpg(self, cid):
     t = syncTime() + secTd(self.aTime)
     print self.channels[cid].lepg.has_key(t.strftime("%y%m%d"))
     lepg = self.channels[cid].lepg[t.strftime("%y%m%d")]
     self.trace("get gmt epg")
     print t
     for x in lepg:
         print x.tend
         if x.tend > t:
             self.channels[cid].aepg = x
             return
Exemple #5
0
 def getGmtEpg(self, cid):
     t = syncTime() + secTd(self.aTime)
     print self.channels[cid].lepg.has_key(t.strftime("%y%m%d"))
     lepg = self.channels[cid].lepg[t.strftime("%y%m%d")]
     self.trace("get gmt epg")
     print t
     for x in lepg:
         print x.tend
         if x.tend > t:
             self.channels[cid].aepg = x
             return
Exemple #6
0
	def getGmtEpg(self, id):
		params = {"m" : "channels",
				  "act" : "get_stream_url",
				  "cid" : id,
				  "gmt": (syncTime() + secTd(self.aTime)).strftime("%s"),
				  "just_info" : 1 }
		root = self.getData("/?"+urllib.urlencode(params), "get GmtEpg of stream %s" % id)
		prog = unescapeEntities(root.attrib.get("programm")).encode("utf-8")
		tstart = datetime.datetime.fromtimestamp( int(root.attrib.get("start").encode("utf-8")) ) #unix
		tend = datetime.datetime.fromtimestamp( int(root.attrib.get("next").encode("utf-8")) )
		self.channels[id].aepg = EpgEntry(prog, tstart,  tend)
Exemple #7
0
 def getDayEpg(self, id, date=None):
     if not date:
         date = syncTime()
     print date
     params = {"cid": id, "from_uts": datetime.datetime(date.year, date.month, date.day).strftime("%s"), "hours": 24}
     root = self.getData(self.site + "/get_epg?" + urllib.urlencode(params), "EPG for channel %s" % id)
     epglist = []
     self.channels[id].lepg[date.strftime("%y%m%d")] = []
     for prog in root.find("channels").find("item").find("epg"):
         title = prog.findtext("title").encode("utf-8") + "\n"
         title += prog.findtext("info").encode("utf-8")
         t_start = datetime.datetime.fromtimestamp(int(prog.findtext("begin").encode("utf-8")))
         t_end = datetime.datetime.fromtimestamp(int(prog.findtext("end").encode("utf-8")))
         self.channels[id].lepg[date.strftime("%y%m%d")] += [EpgEntry(title, t_start, t_end)]
         epglist += [(t_start, title.split("\n")[0], title.split("\n")[1])]
     return epglist
Exemple #8
0
 def getGmtEpg(self, id):
     params = {
         "m": "channels",
         "act": "get_stream_url",
         "cid": id,
         "gmt": (syncTime() + secTd(self.aTime)).strftime("%s"),
         "just_info": 1
     }
     root = self.getData("/?" + urllib.urlencode(params),
                         "get GmtEpg of stream %s" % id)
     prog = unescapeEntities(root.attrib.get("programm")).encode("utf-8")
     tstart = datetime.datetime.fromtimestamp(
         int(root.attrib.get("start").encode("utf-8")))  #unix
     tend = datetime.datetime.fromtimestamp(
         int(root.attrib.get("next").encode("utf-8")))
     self.channels[id].aepg = EpgEntry(prog, tstart, tend)
Exemple #9
0
	def getDayEpg(self, cid, date = None):
		if not date:
			date = syncTime()
		params = {"m" : "epg",
				  "act" : "show_day_xml",
				  "day" : date.strftime("%d%m%y"),
				  "cid" : cid}
		root = self.getData("/?"+urllib.urlencode(params), "EPG for channel %s" % cid)
		epglist = []
		archive = int(root.attrib.get("have_archive").encode("utf-8"))
		self.channels[cid].archive = archive
		for program in root:
			t = int(program.attrib.get("t_start").encode("utf-8"))
			time = datetime.datetime.fromtimestamp(t)
			progname = unescapeEntities(program.attrib.get("progname")).encode("utf-8")
			pdescr =  unescapeEntities(program.attrib.get("pdescr")).encode("utf-8")
			epglist += [(time, progname, pdescr)]
		return epglist
Exemple #10
0
	def getStreamUrl(self, cid, pin):
		params = {"m" : "channels",
				  "act" : "get_stream_url",
				  "cid" : cid}
		if self.aTime:
			params["gmt"] = (syncTime() + secTd(self.aTime)).strftime("%s")
		params["protect_code"] = pin
		root = self.getData("/?"+urllib.urlencode(params), "URL of stream %s" % cid)
		if self.aTime:
			prog = unescapeEntities(root.attrib.get("programm"))
			if prog:
				prog = prog.encode("utf-8")
				tstart = datetime.datetime.fromtimestamp( int(root.attrib.get("start").encode("utf-8")) ) #unix
				tend = datetime.datetime.fromtimestamp( int(root.attrib.get("next").encode("utf-8")) )
				self.channels[cid].aepg = EpgEntry(prog, tstart, tend)
		url = root.attrib.get("url").encode("utf-8").split(' ')[0].replace('http/ts://', 'http://')
		if url == "protected": return 0
		return url
Exemple #11
0
 def getStreamUrl(self, cid, pin):
     params = {"m": "channels", "act": "get_stream_url", "cid": cid}
     if self.aTime:
         params["gmt"] = (syncTime() + secTd(self.aTime)).strftime("%s")
     params["protect_code"] = pin
     root = self.getData("/?" + urllib.urlencode(params),
                         "URL of stream %s" % cid)
     if self.aTime:
         prog = unescapeEntities(root.attrib.get("programm"))
         if prog:
             prog = prog.encode("utf-8")
             tstart = datetime.datetime.fromtimestamp(
                 int(root.attrib.get("start").encode("utf-8")))  #unix
             tend = datetime.datetime.fromtimestamp(
                 int(root.attrib.get("next").encode("utf-8")))
             self.channels[cid].aepg = EpgEntry(prog, tstart, tend)
     url = root.attrib.get("url").encode("utf-8").split(' ')[0].replace(
         'http/ts://', 'http://')
     if url == "protected": return 0
     return url
Exemple #12
0
 def getDayEpg(self, cid, date=None):
     if not date:
         date = syncTime()
     params = {
         "m": "epg",
         "act": "show_day_xml",
         "day": date.strftime("%d%m%y"),
         "cid": cid
     }
     root = self.getData("/?" + urllib.urlencode(params),
                         "EPG for channel %s" % cid)
     epglist = []
     archive = int(root.attrib.get("have_archive").encode("utf-8"))
     self.channels[cid].archive = archive
     for program in root:
         t = int(program.attrib.get("t_start").encode("utf-8"))
         time = datetime.datetime.fromtimestamp(t)
         progname = unescapeEntities(
             program.attrib.get("progname")).encode("utf-8")
         pdescr = unescapeEntities(
             program.attrib.get("pdescr")).encode("utf-8")
         epglist += [(time, progname, pdescr)]
     return epglist