Browse Source

salabots filmix

Ivars 8 years ago
parent
commit
2d76ccdf6a
6 changed files with 1439 additions and 365 deletions
  1. 1286
    287
      PlayStream.wpr
  2. 1
    1
      imake.bat
  3. BIN
      release/enigma2-plugin-extensions-playstream_0.5x.ipk
  4. 151
    76
      sources/filmix.py
  5. BIN
      sources/filmix.pyc
  6. 1
    1
      util.py

+ 1286
- 287
PlayStream.wpr
File diff suppressed because it is too large
View File


+ 1
- 1
imake.bat View File

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

BIN
release/enigma2-plugin-extensions-playstream_0.5x.ipk View File


+ 151
- 76
sources/filmix.py View File

21
 
21
 
22
 headers2dict = lambda  h: dict([l.strip().split(": ") for l in h.strip().splitlines()])
22
 headers2dict = lambda  h: dict([l.strip().split(": ") for l in h.strip().splitlines()])
23
 import util
23
 import util
24
-    
24
+
25
 class Source(SourceBase):
25
 class Source(SourceBase):
26
-    
26
+
27
     def __init__(self,country=""):
27
     def __init__(self,country=""):
28
         self.name = "filmix"
28
         self.name = "filmix"
29
         self.title = "filmix.me"
29
         self.title = "filmix.me"
43
 """)
43
 """)
44
         self.url = "https://filmix.me/"
44
         self.url = "https://filmix.me/"
45
         #self.login()
45
         #self.login()
46
-        
46
+
47
     def login(self,user="",password=""):
47
     def login(self,user="",password=""):
48
         return True
48
         return True
49
-            
49
+
50
     def get_content(self, data):
50
     def get_content(self, data):
51
         print "[filmix] get_content:", data
51
         print "[filmix] get_content:", data
52
         if "::" in data:
52
         if "::" in data:
53
-            data = data.split("::")[1] 
53
+            data = data.split("::")[1]
54
         path = data.split("?")[0]
54
         path = data.split("?")[0]
55
         clist = path.split("/")[0]
55
         clist = path.split("/")[0]
56
         params = data[data.find("?"):] if "?" in data else ""
56
         params = data[data.find("?"):] if "?" in data else ""
57
         qs = dict(map(lambda x:x.split("="),re.findall("[%\w]+=\w+",params)))
57
         qs = dict(map(lambda x:x.split("="),re.findall("[%\w]+=\w+",params)))
58
         lang = qs["lang"] if "lang" in qs else self.country
58
         lang = qs["lang"] if "lang" in qs else self.country
59
-    
59
+
60
         content=[]
60
         content=[]
61
         content.append(("..return", "back","","Return back"))
61
         content.append(("..return", "back","","Return back"))
62
-        
62
+
63
         if clist=="home":
63
         if clist=="home":
64
             content.extend([
64
             content.extend([
65
-                ("Search", "filmix::search/{0}","","Search"),                
65
+                ("Search", "filmix::search/{0}","","Search"),
66
                 ("Movies", "filmix::movies","","Movies"),
66
                 ("Movies", "filmix::movies","","Movies"),
67
                 ("Series", "filmix::series","","TV Series"),
67
                 ("Series", "filmix::series","","TV Series"),
68
                 ("Cartoons", "filmix::cartoons","","Cartoons"),
68
                 ("Cartoons", "filmix::cartoons","","Cartoons"),
69
             ])
69
             ])
70
             return content
70
             return content
71
-    
71
+
72
         #elif clist=="search":
72
         #elif clist=="search":
73
             # TODO
73
             # TODO
74
             #return content
74
             #return content
93
                 data2 = item[0]
93
                 data2 = item[0]
94
                 img = self.img
94
                 img = self.img
95
                 desc = title
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
         elif clist=="play":
100
         elif clist=="play":
101
             r = self.call(path)
101
             r = self.call(path)
102
             r = r.decode("cp1251").encode("utf8")
102
             r = r.decode("cp1251").encode("utf8")
107
             duration = "(%s)"%m.group(1) if m else ""
107
             duration = "(%s)"%m.group(1) if m else ""
108
             m = re.search('<p itemprop="description"[^>]+>([^<]+)<', r, re.DOTALL)
108
             m = re.search('<p itemprop="description"[^>]+>([^<]+)<', r, re.DOTALL)
109
             desc = desc0 =  util.unescape(m.group(1).strip()) if m else ""
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
             if not m:
112
             if not m:
116
-                raise Exception("Can not find video link")
113
+            #    #raise Exception("Can not find video link")
114
+                return []
117
             video_link = m.group(1)
115
             video_link = m.group(1)
118
-            if video_link<>'{video-link}':
116
+
117
+            if video_link<>'{video-link}': # TODO nevar būt!
119
                 video_link = self.decode_uppod_text(video_link)
118
                 video_link = self.decode_uppod_text(video_link)
120
                 streams = self.get_streams2(video_link)
119
                 streams = self.get_streams2(video_link)
121
                 data2 = streams[0][1]
120
                 data2 = streams[0][1]
122
                 content = (title,data2,img,desc)
121
                 content = (title,data2,img,desc)
123
                 return content
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
             else:
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
                     desc = serie +"\n"+desc0
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
         else:
157
         else:
166
             r = self.call(data)
158
             r = self.call(data)
167
             r = r.decode("cp1251").encode("utf8")
159
             r = r.decode("cp1251").encode("utf8")
204
                     else:
196
                     else:
205
                         data2 = data + "/page/2"
197
                         data2 = data + "/page/2"
206
                 content.append(("Next page",self.name+"::"+data2,self.img,"Next page"))
198
                 content.append(("Next page",self.name+"::"+data2,self.img,"Next page"))
207
-                        
208
-            return content                            
209
-              
199
+
200
+            return content
201
+
210
     def is_video(self,data):
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
         if clist == "play" and "s=" in data and "e=" in data:
204
         if clist == "play" and "s=" in data and "e=" in data:
218
             return True
205
             return True
219
         elif clist=="play" and not params:
206
         elif clist=="play" and not params:
220
             r = self.call(path)
207
             r = self.call(path)
221
             #r = r.decode("cp1251").encode("utf8")
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
             if not m:
210
             if not m:
225
                 raise Exception("Can not find video link")
211
                 raise Exception("Can not find video link")
212
+                #return False
226
             video_link = m.group(1)
213
             video_link = m.group(1)
227
             if video_link=='{video-link}':
214
             if video_link=='{video-link}':
228
                 return False
215
                 return False
230
                 return True
217
                 return True
231
         else:
218
         else:
232
             return False
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
     def call(self, data,params=None,headers=None,lang=""):
308
     def call(self, data,params=None,headers=None,lang=""):
235
         if not headers: headers = self.headers
309
         if not headers: headers = self.headers
236
         url = self.url+data
310
         url = self.url+data
237
         result = self._http_request(url,params,headers=headers)
311
         result = self._http_request(url,params,headers=headers)
238
         return result
312
         return result
239
 
313
 
240
-    
241
-    def decode_uppod_text(self, text): 
314
+
315
+    def decode_uppod_text(self, text):
242
         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", "="]
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
         text = text.replace("\n", "").strip()
318
         text = text.replace("\n", "").strip()
245
         for i in range(len(Client_codec_a)):
319
         for i in range(len(Client_codec_a)):
246
             char1 = Client_codec_b[i]
320
             char1 = Client_codec_b[i]
251
         result = base64.b64decode(text)
325
         result = base64.b64decode(text)
252
         print result
326
         print result
253
         return result
327
         return result
254
-    
328
+
255
     def get_streams2(self,url0):
329
     def get_streams2(self,url0):
256
         m = re.search("\[([\d,]+)]",url0)
330
         m = re.search("\[([\d,]+)]",url0)
257
         if not m:
331
         if not m:
263
             url=re.sub("\[[\d,]+]",res,url0)
337
             url=re.sub("\[[\d,]+]",res,url0)
264
             streams.append((res,url))
338
             streams.append((res,url))
265
         return streams
339
         return streams
266
-        
340
+
341
+
267
 if __name__ == "__main__":
342
 if __name__ == "__main__":
268
     country= "lv"
343
     country= "lv"
269
     c = Source(country)
344
     c = Source(country)

BIN
sources/filmix.pyc View File


+ 1
- 1
util.py View File

51
     if len(streams)>1:
51
     if len(streams)>1:
52
         for i,s in enumerate(streams):
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
         a = raw_input("Select stram to play: ")
55
         a = raw_input("Select stram to play: ")
56
         try:
56
         try:
57
             n = int(a)
57
             n = int(a)