Browse Source

Merge branch 'master' of http://git.blue.lv/home/content

# Conflicts:
#	project.wpr
Ivars 6 years ago
parent
commit
9af6e1beb1
3 changed files with 190 additions and 22 deletions
  1. BIN
      picons/enigma2.png
  2. 167
    0
      sources/enigma2.py
  3. 23
    22
      sources/streams.cfg

BIN
picons/enigma2.png View File


+ 167
- 0
sources/enigma2.py View File

@@ -0,0 +1,167 @@
1
+#!/usr/bin/env python
2
+# coding=utf8
3
+#
4
+# This file is part of PlayStream - enigma2 plugin to play video streams from various sources
5
+# Copyright (c) 2016 ivars777 (ivars777@gmail.com)
6
+# Distributed under the GNU GPL v3. For full terms see http://www.gnu.org/licenses/gpl-3.0.en.html
7
+#
8
+try:
9
+    import json
10
+except:
11
+    import simplejson as json
12
+import requests
13
+import datetime, re, sys,os
14
+from collections import OrderedDict
15
+import ssl
16
+if "_create_unverified_context" in dir(ssl):
17
+    ssl._create_default_https_context = ssl._create_unverified_context
18
+
19
+from SourceBase import SourceBase
20
+
21
+import resolver
22
+try:
23
+    import util
24
+except:
25
+    sys.path.insert(0,'..')
26
+    import util
27
+
28
+headers2dict = lambda  h: dict([l.strip().split(": ") for l in h.strip().splitlines()])
29
+import HTMLParser
30
+h = HTMLParser.HTMLParser()
31
+
32
+class Source(SourceBase):
33
+
34
+    def __init__(self, country="lv",cfg_path=None):
35
+        self.name = "enigma2"
36
+        self.title = "Engima2"
37
+        self.img = "enigma2.png"
38
+        self.desc = "Get streams from engima2 sat receiver"
39
+        self.headers = headers2dict("""
40
+User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0
41
+Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
42
+Accept-Language: en-US,en;q=0.5
43
+""")
44
+        #self.url = "http://login.tvplayhome.lt:8081/sb/public/"
45
+        cur_directory = os.path.dirname(os.path.abspath(__file__))
46
+        if not cfg_path: cfg_path = cur_directory
47
+        self.config_file = os.path.join(cfg_path,self.name+".cfg")
48
+        self.options = OrderedDict([("host", "localhost"), ("user",""),("password","")])
49
+        self.options_read()
50
+
51
+        if self.options["user"]:
52
+            self.url = "http://%s:%s@%s/api/" % (self.options["user"], self.options["password"],self.options["host"])
53
+        else:
54
+            self.url = "http://%s/api/" % (self.options["host"])
55
+
56
+    ######### Entry point ########
57
+    def get_content(self, data):
58
+        print "[enigma2] get_content:", data
59
+        source, data, path, plist, clist, params, qs = self.parse_data(data)
60
+        content = []
61
+        content.append(("..return", "back","back.png","Return back"))
62
+
63
+        if clist=="home":
64
+            data3 = "getcurrent"
65
+            r2 = self.call(data3)
66
+            event = r2["now"]
67
+            title, img, desc = self.get_title_desc(event)
68
+            content.append(("Current stream: "+title, self.name+"::"+"streamcurrent", img, desc))
69
+            r = self.call("bouquets?stype=tv")
70
+            for item in r["bouquets"]:
71
+                title = item[1]
72
+                data2 = "getservices?sRef=%s" % item[0]
73
+                #data2 = "epgbouquet?bRef=%s" % item[1]
74
+                content.append((title, self.name+"::"+data2, self.img, title))
75
+            return content
76
+
77
+        elif clist == "getservices":
78
+            r = self.call(data)
79
+            data3 = data.replace("getservices?sRef", "epgbouquet?bRef")
80
+            r2 = self.call(data3)
81
+            for item in r["services"]:
82
+                title = item["servicename"]
83
+                data2 = "stream?ref=%s&name=%s" % (item["servicereference"], title)
84
+                img = self.img
85
+                desc = title
86
+                for item2 in r2["events"]:
87
+                    if item2["sref"] == item["servicereference"]:
88
+                        title, img, desc = self.get_title_desc(item2)
89
+                        break
90
+                content.append((title,self.name+"::"+data2, img,desc))
91
+            return content
92
+
93
+        ### kaut kas neparedzets ###
94
+        else:
95
+            return content
96
+
97
+    def get_title_desc(self, event):
98
+        t1 = event["begin_timestamp"]
99
+        t2 = event["begin_timestamp"] + event["duration_sec"]
100
+        t1 = datetime.datetime.fromtimestamp(t1).strftime("%H:%M")
101
+        t2 = datetime.datetime.fromtimestamp(t2).strftime("%H:%M")
102
+        title = "%s - %s [%s-%s]" % (event["sname"], event["title"], t1, t2)
103
+        desc = event["shortdesc"]
104
+        if event["longdesc"]:
105
+            desc += "\n" + event["longdesc"]
106
+        img = event["sref"][:-1].replace(":", "_") + ".png"
107
+        img = self.url.replace("/api/", "/picon/") + img
108
+        return title, img, desc
109
+
110
+
111
+    def is_video(self,data):
112
+        source,data,path,plist,clist,params,qs = self.parse_data(data)
113
+        if clist in ("stream", "streamcurrent"):
114
+            return True
115
+        else:
116
+            return False
117
+
118
+    def call(self, data,params=None,headers=None,lang=""):
119
+        if not headers: headers = self.headers
120
+        url = self.url+data
121
+        r = requests.get(url,headers = headers)
122
+        result = json.loads(r.content)
123
+        #result = self._http_request(url,params,headers=headers)
124
+        return result
125
+
126
+    def get_streams(self,data):
127
+        print "[enigma2] get_streams:", data
128
+        if not self.is_video(data):
129
+            return []
130
+        source,data,path,plist,clist,params,qs = self.parse_data(data)
131
+        if "streamcurrent" in data:
132
+            data3 = "getcurrent"
133
+            r2 = self.call(data3)
134
+            event = r2["now"]
135
+            data = data.replace("streamcurrent", "streamcurrent.m3u")
136
+        else:
137
+            data3 = data.replace("stream?ref=","epgservicenow?sRef=")
138
+            r2 = self.call(data3)
139
+            event = r2["events"][0]
140
+            data = data.replace("stream", "stream.m3u")
141
+        title, img, desc = self.get_title_desc(event)
142
+
143
+        r = self._http_request(self.url+data)
144
+        m =  re.search("(http(s)*:.+)", r)
145
+        if not m:
146
+            raise Exception("No streams found!")
147
+        data2 = m.group(1)
148
+        #data2 = "http://videolink"
149
+        stream = util.item()
150
+        stream["name"] = title
151
+        stream["url"] = data2
152
+        stream["img"] = img
153
+        stream["desc"] = desc
154
+        stream["resolver"] = "enigma2"
155
+        return [stream]
156
+
157
+
158
+if __name__ == "__main__":
159
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
160
+    import run
161
+    source = Source()
162
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
163
+    if len(sys.argv) > 2:
164
+        run.run_cli(source, data)
165
+    else:
166
+        run.run(source, data)
167
+    sys.exit()

+ 23
- 22
sources/streams.cfg View File

@@ -14,13 +14,14 @@ viaplay.lv|viaplay::home|viaplay.png|Viaplay.lv - filmas latviešu, krievu u.c.
14 14
 TVDom.tv|tvdom::home|tvdom.png|PBK tiešraides un arhīvs
15 15
 BBC iPlayer|iplayer::home|iplayer.png|BBC live streams and arhive
16 16
 Euronews|euronews::home|euronews.png|Euronews live streams and archive
17
-cinemalive.tv|cinemalive::home|cinemalive.png|cinemalive.tv - flmas  latviešu valodā
18
-MoviePlace.lv|movieplace::home|movieplace.png|Movieplace.lv - filmas latviesu valodā
19 17
 Filmix.net|filmix::home|filmix.png|Filmix.net - filmas krievu valodā
20
-SerialGURU.ru|serialguru::home||Serialguru.ru - filmas krievu valodā
21 18
 USTVNow|ustvnow::home|ustvnow.png|USTVNow kanālu tiešraide
22 19
 FilmOn|filmon::home|filmon.png|FilmOn - tiešraides un video (dažādās valodās)
23 20
 MTG|config::mtg|mtg.png|Other countries MTG media portals content
21
+cinemalive.tv|cinemalive::home|cinemalive.png|Filmas latviski
22
+SerialGURU.ru|serialguru::home|http://serialguru.ru/images/xlogo_new.png.pagespeed.ic.0sre2_2OJN.png|Serialguru.ru portāla satura skatīšanās
23
+MoviePlace.lv|movieplace::home|movieplace.png|Movieplace.lv - filmas latviesu valodā
24
+Engima2|enigma2::home|enigma2.png|Get streams from engima2 sat receiver
24 25
 
25 26
 [my_tv]
26 27
 My Tv
@@ -28,19 +29,20 @@ My Tv
28 29
 LTV1|replay::tiesraide/ltv1/|http://replay.lsm.lv/resources/logo/large_ltv1.png|LTV1 tiesraide (video )
29 30
 LTV7|replay::tiesraide/ltv7/|http://replay.lsm.lv/resources/logo/large_ltv7.png|LTV7 tiesraide (video )
30 31
 TVRiga24|play24::tiesraide|riga24.png|TV live streams
31
-Re:TV|ltc::content/live-streams/924?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/RE_TV.png|Re:TV
32
-Skaties.lv Live|mtgplay::videos?country=lv&order=title&type=live|skaties.png|TV live streams(not always available)
33
-LNT|ltc::content/live-streams/104?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/LNT_logo.png|LNT (ltc)
34
-TV3|ltc::content/live-streams/103?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/TV3_logo.png|TV3 (ltc)
35
-Kanāls 2|ltc::content/live-streams/608?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/Kanals2_logo.png|Kanāls 2 (ltc)
36
-3+|ltc::content/live-streams/107?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/3_logo.png|3+ (ltc)
37
-360TV|ltc::content/live-streams/1051?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/360TV_new.png|360TV (ltc)
38
-STV Pirmā!|ltc::content/live-streams/1069?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/STV.png|STV Pirmā! (ltc)
39
-RU live|tvdom::tiesraides|tvdom.png|RU live streams from TVDom
32
+TVPlay Live|tvplay::tiesraides|tvplay.png|TVPlay live streams(not always available)
33
+Shortcut TV|ltc::tiesraide|shortcut.png|Shortcut.lv live streams
34
+LNT (ltc)|ltc::content/live-streams/104?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/LNT_logo.png|LNT (ltc)
35
+TV3 (ltc)|ltc::content/live-streams/103?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/TV3_logo.png|TV3 (ltc)
36
+Kanāls 2 (ltc)|ltc::content/live-streams/608?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/Kanals2_logo.png|Kanāls 2 (ltc)
37
+3+ (ltc)|ltc::content/live-streams/107?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/3_logo.png|3+ (ltc)
38
+Re:TV (ltc)|ltc::content/live-streams/924?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/RE_TV.png|Re:TV
39
+360TV (ltc)|ltc::content/live-streams/1051?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/360TV_new.png|360TV (ltc)
40
+STV Pirmā! (ltc) |ltc::content/live-streams/1069?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/STV.png|STV Pirmā! (ltc)
41
+TVDom Live|tvdom::tiesraides|tvdom.png|RU live streams from TVDom
40 42
 Euronews live|euronews::live?lang=en|euronews.png|Euronews live stream
41
-BBC live (iPlayer)|iplayer::live|iplayer.png|BBC live streams from iPlayer
42
-UK live (FilmOn) TV|filmon::group?id=5|https://static.filmon.com/assets/groups/5/big_logo.png|UK live streams from FilmOn
43
-US live (USTVNow|ustvnow::tvlive|ustvnow.png|US live streams from FilmOn
43
+BBC Live (iPlayer)|iplayer::live|iplayer.png|BBC live streams from iPlayer
44
+UK Live (FilmOn) TV|filmon::group?id=5|https://static.filmon.com/assets/groups/5/big_logo.png|UK live streams from FilmOn
45
+US Live (USTVNow|ustvnow::tvlive|ustvnow.png|US live streams from FilmOn
44 46
 Canadian live (FilmOn)|filmon::group?id=44|https://static.filmon.com/assets/groups/44/big_logo.png|Canada live streams from FilmOn
45 47
 Sport stream|rtmp://184.172.124.216/live/test111||
46 48
 
@@ -49,7 +51,7 @@ My Archive
49 51
 ..return|back|back.png|Atgriezties atpakaļ
50 52
 LTV arhīvs LV|replay::visi/jaunakie/?source=ltv&lang=lv|replay.png|LTV1, LTV2 pārraižu arhīvs LV
51 53
 LTV arhīvs RU|replay::vse/novie/?source=ltv&lang=ru|replay.png|LTV1, LTV2 pārraižu arhīvs RU
52
-skaties.lv arhīvs|mtgplay::videos?country=lv&order=-airdate|skaties.png|MTG (LNT, TV3, TV6 u.c.) pārraižu arhīvs
54
+TVPlay jaunākais|tvplay::jaunakais/epizodes|tvplay.png|TVPlay pārraižu arhīvs
53 55
 Lattelecom.tv arhīvs - categories|ltc::archive/categories|shortcut.png|Lattelecom.tv pārraižu arhīvs
54 56
 TVRiga24 arhīvs|play24::kategorija/raidijumi|riga24.png|TVRiga24.tv pārraižu arhīvs
55 57
 TVDom arhīvs - categories|tvdom::arhivs|tvdom.png|TVDom(PBK, NTV, REN u.c.) pārraižu arhīvs RU
@@ -68,12 +70,13 @@ My Kids
68 70
 ..return|back|back.png|Atgriezties atpakaļ
69 71
 Bērnu TV|config::my_kids_tv|my_tv.png|Bērnu TV kanāli
70 72
 Bērnu video|config::my_kids_video|my_video.png|Saglabātie bērnu video
71
-LTV bērnu TV arhīvs|replay::raidijumi/?lang=lv&type=video&theme=5|my_archive.png|LTV bērnu TV arhīvs
72
-Skaties.lv bērnu TV arhīvs|mtgplay::formats?category=51&country=lv&order=title|http://mtgonline.lv/tv3play/categories/berni-new.jpg|Skaties.lv bērnu TV arhīvs
73
-Shortcut.lv video bērniem - latviski|ltc::videonoma?page=0&genre=3&sorts=title&cnt=40&clear=true&filter={"valoda":["lv"]}|https://www.lattelecom.tv/images/redesign/videonoma_dropdown_berniem.png|Shortuc.lv (Lattelecom) bērnu video latviski
73
+LTV bērnu TV arhīvs|replay::kategorija/berniem?lang=lv|my_archive.png|LTV bērnu TV arhīvs
74
+TVPlay bērnu TV arhīvs|tvplay::jaunakais/berniem|tvplay.png|Skaties.lv bērnu TV arhīvs
75
+Shortcut.lv video bērniem|ltc::viss/actual_kid|shortcut.png|Shortuc.lv (Lattelecom) bērnu video latviski
76
+Shortcut.lv Premiere video bērniem|ltc::viss/kids_premiere|shortcut.png|Shortuc.lv (Lattelecom) bērnu Premium video latviski
74 77
 CBeebies video|iplayer::categories/cbeebies|iplayer.png|CBeebies videos from iPlayer
75 78
 CBBC video|iplayer::categories/cbbc|iplayer.png|CBBC videos from iPlayer
76
-TVDom bērnu video|tvdom::arhivs/bernu|tvdom.png|TVDom bērnu video RU
79
+TVDom bērnu video|tvdom::arhivs?genre1=49&filter=new&region=lv&lang=lv&page=0&limit=30|tvdom.png|TVDom bērnu video RU
77 80
 Filmix bērnu filmas|filmix::detskij|filmix.png|Filmix bērnu filmas
78 81
 Filmix bērnu seriāli|filmix::detskij/s7|filmix.png|Filmix bērnu seriāli
79 82
 
@@ -107,8 +110,6 @@ LR6|replay::tiesraide/lr6/|http://replay.lsm.lv/resources/logo/lr6_logo.png|LR6
107 110
 [mtg]
108 111
 MTG
109 112
 ..return|back|back.png|Atgriezties atpakaļ
110
-Estonia (tv3play.ee)|mtgplay::home?country=ee||MTG Estonia media portal content
111
-Lithuania (play.tv3.lt/)|mtgplay::home?country=lt||MTG Lithuania media portal content
112 113
 Sweden (tvXplay.se)|mtgplay::home?country=se||MTG Sweden media portal content
113 114
 Denmark (tv3play.dk)|mtgplay::home?country=dk||MTG Denmark media portal content
114 115
 Norway (tv3play.no)|mtgplay::home?country=no||MTG Norway media portal content