Browse Source

ltc epg info

Ivars 6 years ago
parent
commit
0ad850217a
1 changed files with 23 additions and 13 deletions
  1. 23
    13
      sources/ltc.py

+ 23
- 13
sources/ltc.py View File

@@ -12,7 +12,6 @@ from urllib import quote, unquote
12 12
 import datetime
13 13
 import HTMLParser
14 14
 import json
15
-import datetime
16 15
 from SourceBase import SourceBase, stream_type
17 16
 import util
18 17
 from util import unescape
@@ -187,12 +186,12 @@ Accept-Language: en-US,en;q=0.8
187 186
                 item = self.get_epg_id(item["id"])
188 187
                 ch = self.get_channel_by_id2(item["channel_id"])
189 188
                 ch_name = ch["name"] if ch else item["channel_id"]
190
-                title = u"[%s %s-%s] %s - %s"%(item["date"],item["time_start2"].strftime("%H:%M"),item["time_stop2"].strftime("%H:%M"),ch_name,item["title"])
189
+                title = u"%s (%s-%s)"%(item["title"], item["time_start2"].strftime("%H:%M"),item["time_stop2"].strftime("%H:%M"))
191 190
                 #data2 = "archive/get-stream/%s?channelid=%s"%(item["id"],ch["id"])
192 191
                 data2 = "content/record-streams/%s?include=quality"%item["id"]
193 192
                 img = "https://manstv.lattelecom.tv/"+ item["url"]
194
-                desc = u"%s - %s\n%s - %s\n%s\n%s"%(ch_name,item["title"],item["time_start"],item["time_stop"],
195
-                                                          item["category1"],item["description"])
193
+                desc = u"%s - %s\n%s %s-%s\n%s\n%s"%(ch_name,item["title"], item["date"], item["time_start2"].strftime("%H:%M"),item["time_stop2"].strftime("%H:%M"),
194
+                                                                 item["category1"],item["description"])
196 195
                 content.append((title,self.name+"::"+data2,img,desc))
197 196
             if "until_id" in data:
198 197
                 data2 = re.sub("until_id=\d+","until_id="+item["id"],data)
@@ -216,17 +215,20 @@ Accept-Language: en-US,en;q=0.8
216 215
         elif "archive/channel/" in data:
217 216
             chid = path.split("/")[2]
218 217
             for item in self.get_epg_date(qs["date"],chid):
219
-                #if item["is_archive"]=='0':continue
218
+                if item["is_archive"]=='0':continue
219
+                if item["time_stop2"] > datetime.datetime.now(): continue
220 220
                 ch = self.get_channel_by_id2(item["channel_id"])
221 221
                 ch_name = ch["name"] if ch else item["channel_id"]
222
-                title = u"[%s %s-%s] %s - %s"%(item["date"],item["time_start2"].strftime("%H:%M"),item["time_stop2"].strftime("%H:%M"),ch_name,item["title"])
222
+                #title = u"[%s %s-%s] %s - %s"%(item["date"],item["time_start2"].strftime("%H:%M"),item["time_stop2"].strftime("%H:%M"),ch_name,item["title"])
223
+                title = u"%s (%s-%s)"%(item["title"], item["time_start2"].strftime("%H:%M"),item["time_stop2"].strftime("%H:%M"))
223 224
                 #data2 = "archive/get-stream/%s?channelid=%s"%(item["id"],ch["id"])
224 225
                 data2 = "content/record-streams/%s?include=quality"%item["id"]
225 226
                 img = "https://manstv.lattelecom.tv/"+ item["url"]
226
-                desc = u"%s - %s\n%s - %s\n%s\n%s"%(ch_name,item["title"],item["time_start"],item["time_stop"],
227
+                desc = u"%s - %s\n%s %s-%s\n%s\n%s"%(ch_name,item["title"], item["date"], item["time_start2"].strftime("%H:%M"),item["time_stop2"].strftime("%H:%M"),
227 228
                                                           item["category1"],item["description"])
228 229
                 content.append((title,self.name+"::"+data2,img,desc))
229
-            date2=datetime.datetime.strptime(qs["date"], '%Y-%m-%d').date()-datetime.timedelta(days=1)
230
+            #date2=datetime.datetime.strptime(qs["date"], '%Y-%m-%d').date()-datetime.timedelta(days=1)
231
+            date2 = datetime.date(*tuple(map(int, qs["date"].split("-")))) - datetime.timedelta(days=1)
230 232
             date2 = date2.strftime("%Y-%m-%d")
231 233
             if "date=" in data:
232 234
                 data2 = re.sub("date=[\d-]+","date="+date2,data)
@@ -592,12 +594,20 @@ Accept-Language: en-US,en;q=0.8
592 594
 
593 595
 
594 596
     def get_epg_id(self,epgid):
595
-        if not self.epg:
596
-            return None
597
-            #self.get_epg()
598
-        if epgid in self.epg_id:
597
+
598
+        if self.epg and epgid in self.epg_id:
599 599
             return self.epg[self.epg_id[epgid]]
600
-        return None
600
+        else:
601
+            r=self.call("content/epgs/%s" % epgid)
602
+            if not r:
603
+                return None
604
+            item =  r["data"][0]["attributes"]
605
+            item["unix_start"] = item["unix-start"]
606
+            item["unix_stop"] = item["unix-stop"]
607
+            item["time_start2"] = datetime.datetime.fromtimestamp(int(item["unix_start"]))
608
+            item["time_stop2"] = datetime.datetime.fromtimestamp(int(item["unix_stop"]))
609
+            item["date"]=item["time_start2"].strftime("%Y-%m-%d")
610
+            return item
601 611
 
602 612
     def get_epg_date(self,date,chid):
603 613
         if not date in self.epgdates: