Ivars před 7 roky
rodič
revize
2d76ccdf6a
6 změnil soubory, kde provedl 1439 přidání a 365 odebrání
  1. 1286
    287
      PlayStream.wpr
  2. 1
    1
      imake.bat
  3. binární
      release/enigma2-plugin-extensions-playstream_0.5x.ipk
  4. 151
    76
      sources/filmix.py
  5. binární
      sources/filmix.pyc
  6. 1
    1
      util.py

+ 1286
- 287
PlayStream.wpr
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 1
- 1
imake.bat Zobrazit soubor

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

binární
release/enigma2-plugin-extensions-playstream_0.5x.ipk Zobrazit soubor


+ 151
- 76
sources/filmix.py Zobrazit soubor

@@ -21,9 +21,9 @@ import sys
21 21
 
22 22
 headers2dict = lambda  h: dict([l.strip().split(": ") for l in h.strip().splitlines()])
23 23
 import util
24
-    
24
+
25 25
 class Source(SourceBase):
26
-    
26
+
27 27
     def __init__(self,country=""):
28 28
         self.name = "filmix"
29 29
         self.title = "filmix.me"
@@ -43,32 +43,32 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
43 43
 """)
44 44
         self.url = "https://filmix.me/"
45 45
         #self.login()
46
-        
46
+
47 47
     def login(self,user="",password=""):
48 48
         return True
49
-            
49
+
50 50
     def get_content(self, data):
51 51
         print "[filmix] get_content:", data
52 52
         if "::" in data:
53
-            data = data.split("::")[1] 
53
+            data = data.split("::")[1]
54 54
         path = data.split("?")[0]
55 55
         clist = path.split("/")[0]
56 56
         params = data[data.find("?"):] if "?" in data else ""
57 57
         qs = dict(map(lambda x:x.split("="),re.findall("[%\w]+=\w+",params)))
58 58
         lang = qs["lang"] if "lang" in qs else self.country
59
-    
59
+
60 60
         content=[]
61 61
         content.append(("..return", "back","","Return back"))
62
-        
62
+
63 63
         if clist=="home":
64 64
             content.extend([
65
-                ("Search", "filmix::search/{0}","","Search"),                
65
+                ("Search", "filmix::search/{0}","","Search"),
66 66
                 ("Movies", "filmix::movies","","Movies"),
67 67
                 ("Series", "filmix::series","","TV Series"),
68 68
                 ("Cartoons", "filmix::cartoons","","Cartoons"),
69 69
             ])
70 70
             return content
71
-    
71
+
72 72
         #elif clist=="search":
73 73
             # TODO
74 74
             #return content
@@ -93,10 +93,10 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
93 93
                 data2 = item[0]
94 94
                 img = self.img
95 95
                 desc = title
96
-                content.append((title,self.name+"::"+data2,img,desc))      
97
-            return content      
98
-         
99
-        ## Video/seriāla spēlēšana
96
+                content.append((title,self.name+"::"+data2,img,desc))
97
+            return content
98
+
99
+        ## Seriāls
100 100
         elif clist=="play":
101 101
             r = self.call(path)
102 102
             r = r.decode("cp1251").encode("utf8")
@@ -107,61 +107,53 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
107 107
             duration = "(%s)"%m.group(1) if m else ""
108 108
             m = re.search('<p itemprop="description"[^>]+>([^<]+)<', r, re.DOTALL)
109 109
             desc = desc0 =  util.unescape(m.group(1).strip()) if m else ""
110
-            
111
-            #url2 = re.search('<div id="play-descr" class="title-page">.+?<a href="([^"]+)"', r, re.DOTALL).group(1)
112
-            #r2 = self._http_request(url2)
113
-             
114
-            m = re.search("videoLink = '([^']+)'", r, re.DOTALL)
110
+
111
+            m = re.search('itemprop="contentUrl" content="(.+?)"', r, re.IGNORECASE | re.DOTALL)
115 112
             if not m:
116
-                raise Exception("Can not find video link")
113
+            #    #raise Exception("Can not find video link")
114
+                return []
117 115
             video_link = m.group(1)
118
-            if video_link<>'{video-link}':
116
+
117
+            if video_link<>'{video-link}': # TODO nevar būt!
119 118
                 video_link = self.decode_uppod_text(video_link)
120 119
                 streams = self.get_streams2(video_link)
121 120
                 data2 = streams[0][1]
122 121
                 content = (title,data2,img,desc)
123 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)
133
+            pl_link = self.decode_uppod_text(pl_link)
134
+            js = self._http_request(pl_link)
135
+            js = self.decode_uppod_text(js)
136
+            js = json.loads(js)
137
+            if "s" in qs:
138
+                s = int(qs["s"])
139
+                for i,ep in enumerate(js["playlist"][s-1]["playlist"]):
140
+                    title = title0+" - "+js["playlist"][s-1]["playlist"][i]["comment"].encode("utf8")
141
+                    serie = js["playlist"][s-1]["playlist"][i]["comment"].encode("utf8")
142
+                    data2 = data+"&e=%s"%(i+1)
143
+                    desc = serie +"\n"+desc0
144
+                    content.append((title,self.name+"::"+data2,img,desc))
124 145
             else:
125
-                m = re.search("plLink = '([^']+)'", r, re.DOTALL)
126
-                if not m:
127
-                    raise Exception("Can not find video link")
128
-                pl_link = m.group(1)
129
-                pl_link = self.decode_uppod_text(pl_link)
130
-                js = self._http_request(pl_link)
131
-                js = self.decode_uppod_text(js)
132
-                js = json.loads(js)
133
-                if "s" in qs and "e" in qs:
134
-                    s = int(qs["s"])
135
-                    e = int(qs["e"])
136
-                    serie = js["playlist"][s-1]["playlist"][e-1]["comment"].encode("utf8")
137
-                    title = title0+" - "+ serie
138
-                    data2 = js["playlist"][s-1]["playlist"][e-1]["file"].encode("utf8")
139
-                    streams = self.get_streams2(data2)
140
-                    data2=streams[0][1]
146
+                for i,ep in enumerate(js["playlist"]):
147
+                    title = title0 +" - "+js["playlist"][i]["comment"].encode("utf8")
148
+                    serie = js["playlist"][i]["comment"].encode("utf8")
149
+                    data2 = data+"?s=%s"%(i+1)
141 150
                     desc = serie +"\n"+desc0
142
-                    content = (title,data2,img,desc)
143
-                    return content
144
-                
145
-                elif "s" in qs:
146
-                    s = int(qs["s"])
147
-                    for i,ep in enumerate(js["playlist"][s-1]["playlist"]):
148
-                        title = title0+" - "+js["playlist"][s-1]["playlist"][i]["comment"].encode("utf8")
149
-                        serie = js["playlist"][s-1]["playlist"][i]["comment"].encode("utf8")
150
-                        data2 = data+"&e=%s"%(i+1)
151
-                        desc = serie +"\n"+desc0
152
-                        content.append((title,self.name+"::"+data2,img,desc)) 
153
-                else:
154
-                    for i,ep in enumerate(js["playlist"]):
155
-                        title = title0 +" - "+js["playlist"][i]["comment"].encode("utf8")
156
-                        serie = js["playlist"][i]["comment"].encode("utf8")
157
-                        data2 = data+"?s=%s"%(i+1)
158
-                        desc = serie +"\n"+desc0
159
-                        content.append((title,self.name+"::"+data2,img,desc)) 
160
-                return content                    
161
-                #r = self._http_request(url)
162
-            
163
-        
164
-        ### saraksts ### 
151
+                    content.append((title,self.name+"::"+data2,img,desc))
152
+            return content
153
+            #r = self._http_request(url)
154
+
155
+
156
+        ### saraksts ###
165 157
         else:
166 158
             r = self.call(data)
167 159
             r = r.decode("cp1251").encode("utf8")
@@ -204,25 +196,20 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
204 196
                     else:
205 197
                         data2 = data + "/page/2"
206 198
                 content.append(("Next page",self.name+"::"+data2,self.img,"Next page"))
207
-                        
208
-            return content                            
209
-              
199
+
200
+            return content
201
+
210 202
     def is_video(self,data):
211
-        if "::" in data:
212
-            data = data.split("::")[1] 
213
-        path = data.split("?")[0]
214
-        clist = path.split("/")[0]
215
-        params = data[data.find("?"):] if "?" in data else ""
216
-        
203
+        source,data,path,plist,clist,params,qs = self.parse_data(data)
217 204
         if clist == "play" and "s=" in data and "e=" in data:
218 205
             return True
219 206
         elif clist=="play" and not params:
220 207
             r = self.call(path)
221 208
             #r = r.decode("cp1251").encode("utf8")
222
-            title = title0 = util.unescape(re.search("titlePlayer = '([^']+)'", r, re.DOTALL).group(1))
223
-            m = re.search("videoLink = '([^']+)'", r, re.DOTALL)
209
+            m = re.search('itemprop="contentUrl" content="(.+?)"', r, re.IGNORECASE | re.DOTALL)
224 210
             if not m:
225 211
                 raise Exception("Can not find video link")
212
+                #return False
226 213
             video_link = m.group(1)
227 214
             if video_link=='{video-link}':
228 215
                 return False
@@ -230,17 +217,104 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
230 217
                 return True
231 218
         else:
232 219
             return False
233
-        
220
+
221
+    def get_streams(self, data):
222
+        print "[filmix] get_streams:", data
223
+        source,data,path,plist,clist,params,qs = self.parse_data(data)
224
+
225
+        r = self.call(path)
226
+        if not r:
227
+            return []
228
+        streams = []
229
+        r = r.decode("cp1251").encode("utf8")
230
+        title = title0 = util.unescape(re.search("titlePlayer = '([^']+)'", r, re.DOTALL).group(1))
231
+        m = re.search('<meta itemprop="thumbnailUrl" content="([^"]+)',r,re.DOTALL)
232
+        img = m.group(1) if m else self.img
233
+        m = re.search('<meta itemprop="duration" content="([^"]+)" />', r, re.DOTALL)
234
+        duration = "(%s)"%m.group(1) if m else ""
235
+        m = re.search('<p itemprop="description"[^>]+>([^<]+)<', r, re.DOTALL)
236
+        desc = desc0 =  util.unescape(m.group(1).strip()) if m else ""
237
+        m = re.search('itemprop="contentUrl" content="(.+?)"', r, re.IGNORECASE | re.DOTALL)
238
+        if not m:
239
+        #    #raise Exception("Can not find video link")
240
+            return []
241
+        video_link = m.group(1)
242
+        series = True if video_link == '{video-link}' else False
243
+        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)
258
+        if js["message"]["translations"]["flash"]:
259
+            video_link = js["message"]["translations"]["flash"].values()[0].encode("utf8")
260
+            lang = js["message"]["translations"]["flash"].keys()[0].encode("utf8")
261
+        else:
262
+            return []
263
+
264
+        if not series : # Filma
265
+            url0 = self.decode_uppod_text(video_link)
266
+            streams2 = self.get_streams2(url0)
267
+            for st in streams2:
268
+                stream = util.item()
269
+                stream["url"]=st[1]
270
+                stream["lang"]=lang
271
+                stream["quality"]=st[0]
272
+                stream["name"]= title
273
+                stream["desc"]=desc
274
+                streams.append(stream)
275
+            return streams
276
+
277
+        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)
288
+            js = self._http_request(pl_link)
289
+            js = self.decode_uppod_text(js)
290
+            js = json.loads(js)
291
+            if "s" in qs and "e" in qs:
292
+                s = int(qs["s"])
293
+                e = int(qs["e"])
294
+                serie = js["playlist"][s-1]["playlist"][e-1]["comment"].encode("utf8")
295
+                title = title0+" - "+ serie
296
+                url0 = js["playlist"][s-1]["playlist"][e-1]["file"].encode("utf8")
297
+                streams2 = self.get_streams2(url0)
298
+                for st in streams2:
299
+                    stream = util.item()
300
+                    stream["url"]=st[1]
301
+                    stream["lang"]=lang
302
+                    stream["quality"]=st[0]
303
+                    stream["name"]= title
304
+                    stream["desc"]=desc
305
+                    streams.append(stream)
306
+                return streams
307
+
234 308
     def call(self, data,params=None,headers=None,lang=""):
235 309
         if not headers: headers = self.headers
236 310
         url = self.url+data
237 311
         result = self._http_request(url,params,headers=headers)
238 312
         return result
239 313
 
240
-    
241
-    def decode_uppod_text(self, text): 
314
+
315
+    def decode_uppod_text(self, text):
242 316
         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", "="]
243
-        Client_codec_b = ["w", "g", "i", "Z", "c", "R", "z", "v", "x", "n", "N", "2", "8", "J", "X", "t", "9", "V", "7", "4", "B", "m", "Y", "o", "L", "h"]    
317
+        Client_codec_b = ["w", "g", "i", "Z", "c", "R", "z", "v", "x", "n", "N", "2", "8", "J", "X", "t", "9", "V", "7", "4", "B", "m", "Y", "o", "L", "h"]
244 318
         text = text.replace("\n", "").strip()
245 319
         for i in range(len(Client_codec_a)):
246 320
             char1 = Client_codec_b[i]
@@ -251,7 +325,7 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
251 325
         result = base64.b64decode(text)
252 326
         print result
253 327
         return result
254
-    
328
+
255 329
     def get_streams2(self,url0):
256 330
         m = re.search("\[([\d,]+)]",url0)
257 331
         if not m:
@@ -263,7 +337,8 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
263 337
             url=re.sub("\[[\d,]+]",res,url0)
264 338
             streams.append((res,url))
265 339
         return streams
266
-        
340
+
341
+
267 342
 if __name__ == "__main__":
268 343
     country= "lv"
269 344
     c = Source(country)

binární
sources/filmix.pyc Zobrazit soubor


+ 1
- 1
util.py Zobrazit soubor

@@ -51,7 +51,7 @@ def play_video(streams):
51 51
     if len(streams)>1:
52 52
         for i,s in enumerate(streams):
53 53
 
54
-            print "%s: [%s,%s,%s] %s"%(i,s["quality"],s["lang"].encode("utf8"),s["type"],s["name"])
54
+            print "%s: [%s,%s,%s] %s"%(i,s["quality"],s["lang"],s["type"],s["name"])
55 55
         a = raw_input("Select stram to play: ")
56 56
         try:
57 57
             n = int(a)