Ivars 7 jaren geleden
bovenliggende
commit
ffa5260ff6

+ 13
- 1
ContentSources.py Bestand weergeven

@@ -7,6 +7,7 @@
7 7
 #
8 8
 
9 9
 import sys,os,re
10
+import glob
10 11
 sys.path.insert(0,os.path.dirname(os.path.abspath(__file__)))
11 12
 from  sources.SourceBase import stream_type
12 13
 import util
@@ -20,15 +21,26 @@ class ContentSources(object):
20 21
         self.plugins = {}
21 22
         self.error_content = [("..atpakaļ", "back", None, "Kļūda, atgriezties atpakaļ")]
22 23
         sys.path.insert(0, plugin_path)
23
-        for f in os.listdir(plugin_path):
24
+        #for f in os.listdir(plugin_path):
25
+        #for f in next(os.walk(plugin_path))[2]:
26
+        print "ContentSources: Importing sources from "+plugin_path
27
+        files = glob.glob(os.path.join(plugin_path,"*.py"))
28
+        for f in files:
24 29
             fname, ext = os.path.splitext(f)
30
+            fname = os.path.split(fname)[1]
25 31
             if fname == "__init__": continue
26 32
             if ext == '.py':
27 33
                 mod = __import__(fname)
28 34
                 reload(mod)
29 35
                 if "Source" in dir(mod):
30 36
                     self.plugins[fname] = mod.Source()
37
+                    print fname+ " imported"
38
+                else:
39
+                    pass
40
+                    #print fname+ "skipped"
31 41
         sys.path.pop(0)
42
+        if not "config" in self.plugins:
43
+            raise Exception("Problem importing content sources")
32 44
         cfg = self.plugins["config"]
33 45
         for pl in self.plugins.keys():
34 46
             found = False

+ 1
- 1
PlayStream.py Bestand weergeven

@@ -13,7 +13,7 @@ import datetime,re
13 13
 import urllib2
14 14
 
15 15
 from enigma import ePicLoad, eServiceReference, eTimer, getDesktop
16
-from Components.ActionMap import ActionMap,HelpableActionMap
16
+from Components.ActionMap import ActionMap, HelpableActionMap
17 17
 from Screens.InfoBarGenerics import InfoBarShowHide
18 18
 from Components.AVSwitch import AVSwitch
19 19
 from Components.Label import Label

+ 329
- 1252
PlayStream.wpr
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 5
- 0
changelog.md Bestand weergeven

@@ -1,3 +1,8 @@
1
+**0.6a** (12.02.2016):
2
+- kombinētā versija ar Kodi, salabots, lai iet kopā (funkcionali nekas jauns)
3
+
4
+**0.5y** (11.02.2016):
5
+- salabots filmix.me
1 6
 
2 7
 **0.5u** (19.01.2016):
3 8
 - kļūdas labojums atverot hqq u.c. strīmus

+ 1
- 1
imake.bat Bestand weergeven

@@ -2,7 +2,7 @@
2 2
 :=== Parameters ===
3 3
 
4 4
 if ()==(%1%) (
5
-    set ver=0.5x
5
+    set ver=0.6a
6 6
 	rem echo Please provide version
7 7
 	rem pause
8 8
 	rem GOTO:EOF

BIN
release/enigma2-plugin-extensions-playstream_0.5y.ipk Bestand weergeven


BIN
release/enigma2-plugin-extensions-playstream_0.6a.ipk Bestand weergeven


+ 7
- 1
sources/SourceBase.py Bestand weergeven

@@ -11,7 +11,13 @@ import datetime, re, sys,os
11 11
 import requests
12 12
 from collections import OrderedDict
13 13
 import ConfigParser
14
-import util
14
+try:
15
+    import util
16
+except:
17
+    parent = os.path.dirname(os.path.abspath(__file__))
18
+    parent = os.sep.join(parent.split(os.sep)[:-1])
19
+    sys.path.insert(0,parent)
20
+    import util
15 21
 
16 22
 headers2dict = lambda  h: dict([l.strip().split(": ") for l in h.strip().splitlines()])
17 23
 

BIN
sources/SourceBase.pyc Bestand weergeven


+ 35
- 61
sources/filmix.py Bestand weergeven

@@ -17,10 +17,13 @@ from SourceBase import SourceBase
17 17
 import base64
18 18
 from collections import OrderedDict
19 19
 import sys
20
-
20
+try:
21
+    import util
22
+except:
23
+    sys.path.insert(0,'..')
24
+    import util
21 25
 
22 26
 headers2dict = lambda  h: dict([l.strip().split(": ") for l in h.strip().splitlines()])
23
-import util
24 27
 
25 28
 class Source(SourceBase):
26 29
 
@@ -49,14 +52,7 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
49 52
 
50 53
     def get_content(self, data):
51 54
         print "[filmix] get_content:", data
52
-        if "::" in data:
53
-            data = data.split("::")[1]
54
-        path = data.split("?")[0]
55
-        clist = path.split("/")[0]
56
-        params = data[data.find("?"):] if "?" in data else ""
57
-        qs = dict(map(lambda x:x.split("="),re.findall("[%\w]+=\w+",params)))
58
-        lang = qs["lang"] if "lang" in qs else self.country
59
-
55
+        source, data, path, plist, clist, params, qs = self.parse_data(data)
60 56
         content=[]
61 57
         content.append(("..return", "back","","Return back"))
62 58
 
@@ -107,29 +103,9 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
107 103
             duration = "(%s)"%m.group(1) if m else ""
108 104
             m = re.search('<p itemprop="description"[^>]+>([^<]+)<', r, re.DOTALL)
109 105
             desc = desc0 =  util.unescape(m.group(1).strip()) if m else ""
110
-
111
-            m = re.search('itemprop="contentUrl" content="(.+?)"', r, re.IGNORECASE | re.DOTALL)
112
-            if not m:
113
-            #    #raise Exception("Can not find video link")
114
-                return []
115
-            video_link = m.group(1)
116
-
117
-            if video_link<>'{video-link}': # TODO nevar būt!
118
-                video_link = self.decode_uppod_text(video_link)
119
-                streams = self.get_streams2(video_link)
120
-                data2 = streams[0][1]
121
-                content = (title,data2,img,desc)
122
-                return content
123
-
124
-            r = util.request("https://m.filmix.me/"+data)
125
-            i = r.find("var flashvars")
126
-            if i == -1:
127
-                raise Exception("Can not find series list")
128
-            m = re.search('pl:"([^"]+)"', r[i:], re.DOTALL)
129
-            if not m:
130
-                #return []
131
-                raise Exception("Can not find series list")
132
-            pl_link = m.group(1)
106
+            vid = plist[-1]
107
+            js = self.get_movie_info(vid)
108
+            pl_link = js["message"]["translations"]["flash"].values()[0] # TODO process several players
133 109
             pl_link = self.decode_uppod_text(pl_link)
134 110
             js = self._http_request(pl_link)
135 111
             js = self.decode_uppod_text(js)
@@ -241,28 +217,16 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
241 217
         video_link = m.group(1)
242 218
         series = True if video_link == '{video-link}' else False
243 219
         vid = plist[1]
244
-        headers = headers2dict("""
245
-    User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
246
-    Accept: application/json, text/javascript, */*; q=0.01
247
-    Accept-Language: en-US,en;q=0.5
248
-    Content-Type: application/x-www-form-urlencoded; charset=UTF-8
249
-    X-Requested-With: XMLHttpRequest
250
-    Referer: https://filmix.me/play/%s
251
-    """%vid )
252
-        post_data = {"post_id":vid}
253
-        r = util.post("https://filmix.me/api/movies/player_data", data=post_data, headers = headers)
254
-        if not r:
255
-            #raise Exception("Can not find video link")
256
-            return []
257
-        js = json.loads(r)
220
+        js = self.get_movie_info(vid)
258 221
         if js["message"]["translations"]["flash"]:
259 222
             video_link = js["message"]["translations"]["flash"].values()[0].encode("utf8")
260
-            lang = js["message"]["translations"]["flash"].keys()[0].encode("utf8")
223
+            video_link = self.decode_uppod_text(video_link)
224
+            lang = js["message"]["translations"]["flash"].keys()[0].encode("utf8") # TODO process several players/streams
261 225
         else:
262 226
             return []
263 227
 
264 228
         if not series : # Filma
265
-            url0 = self.decode_uppod_text(video_link)
229
+            url0 = video_link
266 230
             streams2 = self.get_streams2(url0)
267 231
             for st in streams2:
268 232
                 stream = util.item()
@@ -275,16 +239,7 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
275 239
             return streams
276 240
 
277 241
         else: # Seriāls
278
-            r = util.request("https://m.filmix.me/"+path)
279
-            i = r.find("var flashvars")
280
-            if i == -1:
281
-                raise Exception("Can not find series list")
282
-            m = re.search('pl:"([^"]+)"', r[i:], re.DOTALL)
283
-            if not m:
284
-                #return []
285
-                raise Exception("Can not find series list")
286
-            pl_link = m.group(1)
287
-            pl_link = self.decode_uppod_text(pl_link)
242
+            pl_link = video_link
288 243
             js = self._http_request(pl_link)
289 244
             js = self.decode_uppod_text(js)
290 245
             js = json.loads(js)
@@ -311,6 +266,22 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
311 266
         result = self._http_request(url,params,headers=headers)
312 267
         return result
313 268
 
269
+    def get_movie_info(self,vid):
270
+        headers = headers2dict("""
271
+    User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
272
+    Accept: application/json, text/javascript, */*; q=0.01
273
+    Accept-Language: en-US,en;q=0.5
274
+    Content-Type: application/x-www-form-urlencoded; charset=UTF-8
275
+    X-Requested-With: XMLHttpRequest
276
+    Referer: https://filmix.me/play/%s
277
+    """%vid )
278
+        post_data = {"post_id":vid}
279
+        r = util.post("https://filmix.me/api/movies/player_data", data=post_data, headers = headers)
280
+        if not r:
281
+            raise Exception("Can not get movie info")
282
+            #return []
283
+        js = json.loads(r)
284
+        return js
314 285
 
315 286
     def decode_uppod_text(self, text):
316 287
         Client_codec_a = ["l", "u", "T", "D", "Q", "H", "0", "3", "G", "1", "f", "M", "p", "U", "a", "I", "6", "k", "d", "s", "b", "W", "5", "e", "y", "="]
@@ -340,8 +311,11 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
340 311
 
341 312
 
342 313
 if __name__ == "__main__":
343
-    country= "lv"
344
-    c = Source(country)
314
+
315
+    c = Source()
316
+    #s = "ZnVuY3Rpb24gc2VuZE1lc3NhZ2U2MDc3ODkoZSl7dmFyIGg9bWdfd3M2MDc3ODkub25tZXNzYWdlOyBtZ193czYwNzc4OS5yZWFkeVN0YXRlPT1tZ193czYwNzc4OS5DTE9TRUQmJihtZ193czYwNzc4OT1uZXcgV2ViU29ja2V0KG1nX3dzNjA3Nzg5X2xvY2F0aW9uKSksbWdfd3M2MDc3ODkub25tZXNzYWdlPWgsd2FpdEZvclNvY2tldENvbm5lY3Rpb242MDc3ODkobWdfd3M2MDc3ODksZnVuY3Rpb24oKXttZ193czYwNzc4OS5zZW5kKGUpfSl9ZnVuY3Rpb24gd2FpdEZvclNvY2tldENvbm5lY3Rpb242MDc3ODkoZSx0KXtzZXRUaW1lb3V0KGZ1bmN0aW9uKCl7cmV0dXJuIDE9PT1lLnJlYWR5U3RhdGU/dm9pZChudWxsIT10JiZ0KCkpOnZvaWQgd2FpdEZvclNvY2tldENvbm5lY3Rpb242MDc3ODkoZSx0KX0sNSl9OyB2YXIgbWdfd3M2MDc3ODlfbG9jYXRpb24gPSAid3NzOi8vd3NwLm1hcmtldGdpZC5jb20vd3MiOyBtZ193czYwNzc4OSA9IG5ldyBXZWJTb2NrZXQobWdfd3M2MDc3ODlfbG9jYXRpb24pLCBtZ193czYwNzc4OS5vbm1lc3NhZ2UgPSBmdW5jdGlvbiAodCkge3Bvc3RNZXNzYWdlKHQuZGF0YSk7fSwgb25tZXNzYWdlID0gZnVuY3Rpb24oZSl7c2VuZE1lc3NhZ2U2MDc3ODkoZS5kYXRhKX0="
317
+
318
+    #txt = c.decode_uppod_text(s)
345 319
     if len(sys.argv)>1:
346 320
         data= sys.argv[1]
347 321
     else:

BIN
sources/filmix.pyc Bestand weergeven


+ 6
- 1
sources/movieplace.py Bestand weergeven

@@ -15,7 +15,12 @@ import ConfigParser
15 15
 from collections import OrderedDict
16 16
 from SourceBase import SourceBase
17 17
 import resolver
18
-import util
18
+try:
19
+    import util
20
+except:
21
+    sys.path.insert(0,'..')
22
+    import util
23
+
19 24
 
20 25
 headers2dict = lambda  h: dict([l.strip().split(": ") for l in h.strip().splitlines()])
21 26
 import HTMLParser

BIN
sources/movieplace.pyc Bestand weergeven


+ 30
- 6
util.py Bestand weergeven

@@ -19,11 +19,9 @@
19 19
 # *  http://www.gnu.org/copyleft/gpl.html
20 20
 # *
21 21
 # */
22
-import os
23
-import re
24
-import sys
25
-import urllib
26
-import urllib2
22
+import os, sys, re
23
+import urllib, urllib2
24
+import datetime
27 25
 import traceback
28 26
 import cookielib
29 27
 import requests
@@ -47,6 +45,16 @@ LOG = 2
47 45
 _cookie_jar = None
48 46
 CACHE_COOKIES = 'cookies'
49 47
 
48
+def system():
49
+    if "kodi" in sys.executable.lower():
50
+        return "kodi"
51
+    elif sys.platform == "win32":
52
+        return "windows"
53
+    elif sys.platform == "linux2":
54
+        return "enigma2"
55
+    else:
56
+        return "unknown"
57
+
50 58
 def play_video(streams):
51 59
     if len(streams)>1:
52 60
         for i,s in enumerate(streams):
@@ -153,6 +161,7 @@ def streamproxy_decode(urlp):
153 161
 
154 162
 class Captions(object):
155 163
     def __init__(self,uri):
164
+        self.uri = uri
156 165
         self.subs = []
157 166
         self.styles = {}
158 167
         if uri.startswith("http"):
@@ -214,6 +223,19 @@ class Captions(object):
214 223
                 continue
215 224
         pass
216 225
 
226
+    def get_srt(self):
227
+        out = ""
228
+        i = 0
229
+        for sub in self.subs:
230
+            i +=1
231
+            begin = sub["begin"]
232
+            begin = "%s,%03i"%(str(datetime.timedelta(seconds=begin/1000)),begin%1000)
233
+            end = sub["end"]
234
+            end = "%s,%03i"%(str(datetime.timedelta(seconds=end/1000)),end%1000)
235
+            txt2 = sub["text"]
236
+            out += "%s\n%s --> %s\n%s\n\n\n"%(i,begin,end,txt2)
237
+        return out
238
+
217 239
 def str2sec(r):
218 240
     # Convert str time to miliseconds
219 241
     r= r.replace(",",".")
@@ -225,6 +247,7 @@ def str2sec(r):
225 247
     else:
226 248
         return -1
227 249
 
250
+
228 251
 #c = Captions("http://195.13.216.2/mobile-vod/mp4:lb_barbecue_fr_lq.mp4/lb_barbecue_lv.vtt")
229 252
 #c = Captions("http://www.bbc.co.uk/iplayer/subtitles/ng/modav/bUnknown-0edd6227-0f38-411c-8d46-fa033c4c61c1_b05ql1s3_1479853893356.xml")
230 253
 #url = "http://195.13.216.2/mobile-vod/mp4:ac_now_you_see_me_2_en_lq.mp4/ac_now_you_see_me_2_lv.vtt"
@@ -255,7 +278,8 @@ def item():
255 278
         'surl': '',
256 279
         'subs': [],
257 280
         'headers': {},
258
-        "desc":"","img":"",
281
+        "desc":"",
282
+        "img":"",
259 283
         "lang":"",
260 284
         "type":"",
261 285
         "resolver":"",