([^<]+)', r2, re.DOTALL)
for item in result:
if "catalog" in item[0]: continue
title = item[1]
data2 = item[0]
img = self.img
desc = title
content.append((title,self.name+"::"+data2,img,desc))
return content
## Seriāls
elif clist=="play":
r = self.call(path)
r = r.decode("cp1251").encode("utf8")
title = title0 = util.unescape(re.search("titlePlayer = '([^']+)'", r, re.DOTALL).group(1))
m = re.search('', r, re.DOTALL)
duration = "(%s)"%m.group(1) if m else ""
m = re.search(']+>([^<]+)<', r, re.DOTALL)
desc = desc0 = util.unescape(m.group(1).strip()) if m else ""
vid = plist[-1]
js = self.get_movie_info(vid)
translations = js["message"]["translations"]["flash"]
for pl in translations:
if translations[pl].startswith("http"):
continue
pl_link = translations[pl]
lang = pl.encode("utf8")
break
else:
raise Exception("No episodes list found!")
#pl_link = js["message"]["translations"]["flash"].values()[0]
# TODO process several players, currently taking the first
if not pl_link.startswith("http"):
pl_link = self.decode_uppod_text(pl_link)
js = self._http_request(pl_link)
js = self.decode_uppod_text(js)
js = json.loads(js)
if "s" in qs:
s = int(qs["s"])
for i,ep in enumerate(js["playlist"][s-1]["playlist"]):
title = title0+" - "+js["playlist"][s-1]["playlist"][i]["comment"].encode("utf8")
serie = js["playlist"][s-1]["playlist"][i]["comment"].encode("utf8")
data2 = data+"&e=%s"%(i+1)
desc = serie +"\n"+desc0
content.append((title,self.name+"::"+data2,img,desc))
else:
for i,ep in enumerate(js["playlist"]):
title = title0 +" - "+js["playlist"][i]["comment"].encode("utf8")
serie = js["playlist"][i]["comment"].encode("utf8")
data2 = data+"?s=%s"%(i+1)
desc = serie +"\n"+desc0
content.append((title,self.name+"::"+data2,img,desc))
return content
#r = self._http_request(url)
### saraksts ###
else:
r = self.call(data)
r = r.decode("cp1251").encode("utf8")
for r2 in re.findall('', r, re.DOTALL):
m = re.search(r'', r2, re.DOTALL)
if not m: continue
vid = m.group(1)
data2 = "play/%s"%vid
#title = re.search('itemprop="name">([^<]+)', r2, re.DOTALL).group(1)
title = re.search('itemprop="name" content="([^"]+)"', r2, re.DOTALL).group(1)
m = re.search('itemprop="alternativeHeadline" content="([^"]+)"', r2, re.DOTALL)
if m:
title = title + "/"+m.group(1)
m = re.search('(\d+)<', r2, re.DOTALL)
if m:
year = m.group(1) if m else ""
title = "%s (%s)"%(title,year)
title = util.unescape(title)
genre = re.findall(']+?">([^<]+)', r2, re.DOTALL)
genre = ",".join(genre)
m = re.search('([^<]+)
', r2, re.DOTALL)
desc0 = util.unescape(m.group(1)) if m else ""
m = re.search('([^<]+)
', r2, re.DOTALL)
quality = m.group(1) if m else ""
actors = re.findall('itemprop="actor">([^<]+)<', r2, re.DOTALL)
actors = ",".join(actors)
desc="%s\n%s\n%s\n%s\n%s"%(title,genre,desc0,actors,quality)
content.append((title,self.name+"::"+data2,img,desc))
if '' in r:
m = re.search(r'href="https://filmix\.me/([^"]+)" class="next icon-arowRight btn-tooltip"', r, re.DOTALL)
if m:
data2 = m.group(1)
else:
m = re.search("/page/(\d)+",data)
if m:
page = int(m.group(1))+1
data2 = re.sub("/page/(\d)+", "/page/%s"%page, data)
else:
data2 = data + "/page/2"
content.append(("Next page",self.name+"::"+data2,self.img,"Next page"))
return content
def is_video(self,data):
source,data,path,plist,clist,params,qs = self.parse_data(data)
if clist == "play" and "s=" in data and "e=" in data:
return True
elif clist=="play" and not params:
r = self.call(path)
#r = r.decode("cp1251").encode("utf8")
m = re.search('itemprop="contentUrl" content="(.+?)"', r, re.IGNORECASE | re.DOTALL)
if not m:
raise Exception("Can not find video link")
#return False
video_link = m.group(1)
if video_link=='{video-link}':
return False
else:
return True
else:
return False
def get_streams(self, data):
print "[filmix] get_streams:", data
source,data,path,plist,clist,params,qs = self.parse_data(data)
r = self.call(path)
if not r:
return []
streams = []
r = r.decode("cp1251").encode("utf8")
title = title0 = util.unescape(re.search("titlePlayer = '([^']+)'", r, re.DOTALL).group(1))
m = re.search('
', r, re.DOTALL)
duration = "(%s)"%m.group(1) if m else ""
m = re.search('
]+>([^<]+)<', r, re.DOTALL)
desc = desc0 = util.unescape(m.group(1).strip()) if m else ""
m = re.search('itemprop="contentUrl" content="(.+?)"', r, re.IGNORECASE | re.DOTALL)
if not m:
raise Exception("Can not find video link")
#return []
video_link = m.group(1)
series = True if video_link == '{video-link}' else False
vid = plist[1]
js = self.get_movie_info(vid)
translations = js["message"]["translations"]["flash"]
for pl in translations:
if translations[pl].startswith("http"):
continue
pl_link = translations[pl]
lang = pl.encode("utf8")
break
else:
raise Exception("No episodes list found!")
if not pl_link.startswith("http"):
pl_link = self.decode_uppod_text(pl_link)
if not series : # Filma
url0 = pl_link
streams2 = self.get_streams2(url0)
for st in streams2:
stream = util.item()
stream["url"]=st[1]
stream["lang"]=lang
stream["quality"]=st[0]
stream["name"]= title
stream["desc"]=desc
streams.append(stream)
return streams
else: # Seriāls
#pl_link = video_link
js = self._http_request(pl_link)
js = self.decode_uppod_text(js)
js = json.loads(js)
if "s" in qs and "e" in qs:
s = int(qs["s"])
e = int(qs["e"])
serie = js["playlist"][s-1]["playlist"][e-1]["comment"].encode("utf8")
title = title0+" - "+ serie
url0 = js["playlist"][s-1]["playlist"][e-1]["file"].encode("utf8")
streams2 = self.get_streams2(url0)
for st in streams2:
stream = util.item()
stream["url"]=st[1]
stream["lang"]=lang
stream["quality"]=st[0]
stream["name"]= title
stream["desc"]=desc
streams.append(stream)
return streams
def call(self, data,params=None,headers=None,lang=""):
if not headers: headers = self.headers
url = self.url+data
result = self._http_request(url,params,headers=headers)
return result
def get_movie_info(self,vid):
headers = headers2dict("""
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: https://filmix.me/play/%s
"""%vid )
post_data = {"post_id":vid}
r = util.post("https://filmix.me/api/movies/player_data", data=post_data, headers = headers)
if not r:
raise Exception("Can not get movie info")
#return []
js = json.loads(r)
return js
def decode_uppod_text(self, text):
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", "="]
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"]
text = text.replace("\n", "").strip()
for i in range(len(Client_codec_a)):
char1 = Client_codec_b[i]
char2 = Client_codec_a[i]
text = text.replace(char1, "___")
text = text.replace(char2, char1)
text = text.replace("___", char2)
result = base64.b64decode(text)
print result
return result
def get_streams2(self,url0):
m = re.search("\[([\d\w,]+)\]",url0)
if not m:
return [("?",url0)]
res = m.group(1)
streams=[]
for res in res.split(","):
if not res: continue
if res in ["1080p"]: continue #TODO fullhd only in PRO+ version
url=re.sub("\[[\d\w,]+\]",res,url0)
streams.append((res,url))
return streams
if __name__ == "__main__":
c = Source()
#s = "ZnVuY3Rpb24gc2VuZE1lc3NhZ2U2MDc3ODkoZSl7dmFyIGg9bWdfd3M2MDc3ODkub25tZXNzYWdlOyBtZ193czYwNzc4OS5yZWFkeVN0YXRlPT1tZ193czYwNzc4OS5DTE9TRUQmJihtZ193czYwNzc4OT1uZXcgV2ViU29ja2V0KG1nX3dzNjA3Nzg5X2xvY2F0aW9uKSksbWdfd3M2MDc3ODkub25tZXNzYWdlPWgsd2FpdEZvclNvY2tldENvbm5lY3Rpb242MDc3ODkobWdfd3M2MDc3ODksZnVuY3Rpb24oKXttZ193czYwNzc4OS5zZW5kKGUpfSl9ZnVuY3Rpb24gd2FpdEZvclNvY2tldENvbm5lY3Rpb242MDc3ODkoZSx0KXtzZXRUaW1lb3V0KGZ1bmN0aW9uKCl7cmV0dXJuIDE9PT1lLnJlYWR5U3RhdGU/dm9pZChudWxsIT10JiZ0KCkpOnZvaWQgd2FpdEZvclNvY2tldENvbm5lY3Rpb242MDc3ODkoZSx0KX0sNSl9OyB2YXIgbWdfd3M2MDc3ODlfbG9jYXRpb24gPSAid3NzOi8vd3NwLm1hcmtldGdpZC5jb20vd3MiOyBtZ193czYwNzc4OSA9IG5ldyBXZWJTb2NrZXQobWdfd3M2MDc3ODlfbG9jYXRpb24pLCBtZ193czYwNzc4OS5vbm1lc3NhZ2UgPSBmdW5jdGlvbiAodCkge3Bvc3RNZXNzYWdlKHQuZGF0YSk7fSwgb25tZXNzYWdlID0gZnVuY3Rpb24oZSl7c2VuZE1lc3NhZ2U2MDc3ODkoZS5kYXRhKX0="
#txt = c.decode_uppod_text(s)
if len(sys.argv)>1:
data= sys.argv[1]
else:
data = "home"
content = c.get_content(data)
for item in content:
print item
#cat = api.get_categories(country)
#chan = api.get_channels("lv")
#prog = api.get_programs(channel=6400)
#prog = api.get_programs(category=55)
#seas = api.get_seasons(program=6453)
#str = api.get_streams(660243)
#res = api.get_videos(802)
#formats = api.getAllFormats()
#det = api.detailed("1516")
#vid = api.getVideos("13170")
pass