Browse Source

pielabots ltc, config

Ivars 6 years ago
parent
commit
03824bf162
4 changed files with 24 additions and 10 deletions
  1. 1
    1
      ContentSources.py
  2. 3
    0
      changelog.md
  3. 12
    7
      sources/config.py
  4. 8
    2
      sources/ltc.py

+ 1
- 1
ContentSources.py View File

18
     """Wrapper for content sources plugin"""
18
     """Wrapper for content sources plugin"""
19
 
19
 
20
     #----------------------------------------------------------------------
20
     #----------------------------------------------------------------------
21
-    def __init__(self, plugin_path, cfg_file="streams.cfg"):
21
+    def __init__(self, plugin_path, cfg_file="streams.cfg", cfg_file2=None):
22
         self.plugins = {}
22
         self.plugins = {}
23
         self.error_content = [("..atpakaļ", "back", "back.png", "Kļūda, atgriezties atpakaļ")]
23
         self.error_content = [("..atpakaļ", "back", "back.png", "Kļūda, atgriezties atpakaļ")]
24
         sys.path.insert(0, plugin_path)
24
         sys.path.insert(0, plugin_path)

+ 3
- 0
changelog.md View File

1
+**05.12.2018**
2
+- pielabots ltc (arhīvu bildes, kārtība u.c.)
3
+
1
 **29.09.2018**
4
 **29.09.2018**
2
 - salabots TVPlay (raidījumi pa ketogorijām)
5
 - salabots TVPlay (raidījumi pa ketogorijām)
3
 
6
 

+ 12
- 7
sources/config.py View File

12
 os.path.dirname(os.path.abspath(__file__))
12
 os.path.dirname(os.path.abspath(__file__))
13
 class Source(SourceBase):
13
 class Source(SourceBase):
14
 
14
 
15
-    def __init__(self,country="lv",cfg_path=None, cfg_file=""):
15
+    def __init__(self, cfg_file="streams.cfg", cfg_file2=None):
16
         self.name = "config"
16
         self.name = "config"
17
-        self.country=country
18
         self.lists = collections.OrderedDict()
17
         self.lists = collections.OrderedDict()
19
         self.titles = {}
18
         self.titles = {}
20
-        if not cfg_file: cfg_file = "streams.cfg"
21
-        cur_directory = os.path.dirname(os.path.abspath(__file__))
22
-        if not cfg_path: cfg_path = cur_directory
23
-        self.cfg_path = cfg_path
19
+        cur_directory = os.path.dirname(__file__)
20
+        self.cfg_path = cur_directory
24
         self.set_streams_file(cfg_file)
21
         self.set_streams_file(cfg_file)
25
         print "streams_file=", self.streams_file
22
         print "streams_file=", self.streams_file
26
-        self.read_streams()
23
+        try:
24
+            self.read_streams()
25
+        except Exception as e:
26
+            if cfg_file2:
27
+                # Try fallback
28
+                self.set_streams_file(cfg_file2)
29
+                self.read_streams()
30
+            else:
31
+                raise Exception(e.message)
27
 
32
 
28
     def set_streams_file(self, cfg_file):
33
     def set_streams_file(self, cfg_file):
29
         if not ("/" in cfg_file or "\\" in cfg_file):  # ja tikai faila nosaukums, tad meklē to source folderi
34
         if not ("/" in cfg_file or "\\" in cfg_file):  # ja tikai faila nosaukums, tad meklē to source folderi

+ 8
- 2
sources/ltc.py View File

608
                 else:
608
                 else:
609
                     title = ch["name"]
609
                     title = ch["name"]
610
                     desc = title
610
                     desc = title
611
+                    img = ""
611
             elif vtype == "record-streams":
612
             elif vtype == "record-streams":
612
                 epg = self.get_epg_id(vid)
613
                 epg = self.get_epg_id(vid)
613
                 if epg:
614
                 if epg:
615
                     t1 = datetime.datetime.fromtimestamp(int(epg["unix_start"])).strftime('%H:%M')
616
                     t1 = datetime.datetime.fromtimestamp(int(epg["unix_start"])).strftime('%H:%M')
616
                     t2 = datetime.datetime.fromtimestamp(int(epg["unix_stop"])).strftime('%H:%M')
617
                     t2 = datetime.datetime.fromtimestamp(int(epg["unix_stop"])).strftime('%H:%M')
617
                     date = epg["date"]
618
                     date = epg["date"]
618
-                    title = "%s (%s %s-%s)"%(title,date,t1,t2)
619
-                    desc = epg["description"]
619
+                    #title = "%s [%s %s-%s]"%(title,date,t1,t2)
620
+                    desc = title + "\n" + epg["description"].encode("utf8")
621
+                    img = epg["img"].encode("utf8") if "img" in epg else ""
620
                 else:
622
                 else:
621
                     title = desc = data
623
                     title = desc = data
624
+                    img = ""
622
 
625
 
623
             streams = []
626
             streams = []
624
             for s in r["data"]:
627
             for s in r["data"]:
626
                 stream["url"]=(s["attributes"]["stream-url"]+token.encode("utf8")).encode("utf8")
629
                 stream["url"]=(s["attributes"]["stream-url"]+token.encode("utf8")).encode("utf8")
627
                 stream["name"]=title
630
                 stream["name"]=title
628
                 stream["desc"]=desc
631
                 stream["desc"]=desc
632
+                stream["img"] = img
629
                 stream["type"]="hls"
633
                 stream["type"]="hls"
630
                 m=re.search(".+_(\w\w)_(\w\w)\.\w+",s["id"])
634
                 m=re.search(".+_(\w\w)_(\w\w)\.\w+",s["id"])
631
                 if m:
635
                 if m:
763
             item["time_start2"] = datetime.datetime.fromtimestamp(int(item["unix_start"]))
767
             item["time_start2"] = datetime.datetime.fromtimestamp(int(item["unix_start"]))
764
             item["time_stop2"] = datetime.datetime.fromtimestamp(int(item["unix_stop"]))
768
             item["time_stop2"] = datetime.datetime.fromtimestamp(int(item["unix_stop"]))
765
             item["date"]=item["time_start2"].strftime("%Y-%m-%d")
769
             item["date"]=item["time_start2"].strftime("%Y-%m-%d")
770
+            item["img"] = "https://manstv.lattelecom.tv/" + item["url"]
766
             return item
771
             return item
767
 
772
 
768
     def get_epg_date(self,date,chid):
773
     def get_epg_date(self,date,chid):
774
             item = self.epg[it]
779
             item = self.epg[it]
775
             if item["channel_id"]==ch["xprs_id"]:
780
             if item["channel_id"]==ch["xprs_id"]:
776
                 items.append(item)
781
                 items.append(item)
782
+        items.reverse()
777
         return items
783
         return items
778
 
784
 
779
 
785