#!/usr/bin/env python # coding=utf8 # # This file is part of PlayStream - enigma2 plugin to play video streams from various sources # Copyright (c) 2016 ivars777 (ivars777@gmail.com) # Distributed under the GNU GPL v3. For full terms see http://www.gnu.org/licenses/gpl-3.0.en.html # try: import json except: import simplejson as json import urllib2, urllib import datetime, re, sys,os import ConfigParser from SourceBase import SourceBase import base64 from collections import OrderedDict import sys try: import util except: sys.path.insert(0,'..') import util headers2dict = lambda h: dict([l.strip().split(": ") for l in h.strip().splitlines()]) class Source(SourceBase): def __init__(self,country=""): self.name = "filmix" self.title = "filmix.me" self.img = "http://cs5324.vk.me/g33668783/a_903fcc63.jpg" self.desc = "filmix.me satura skatīšanās" self.country=country self.headers = headers2dict(""" Host: filmix.me User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 """) self.headers2 = headers2dict(""" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0 X-Requested-With: XMLHttpRequest Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 """) self.url = "https://filmix.me/" #self.login() def login(self,user="",password=""): return True def get_content(self, data): print "[filmix] get_content:", data source, data, path, plist, clist, params, qs = self.parse_data(data) content=[] content.append(("..return", "back","","Return back")) if clist=="home": content.extend([ ("Search", "filmix::search/{0}","","Search"), ("Movies", "filmix::movies","","Movies"), ("Series", "filmix::series","","TV Series"), ("Cartoons", "filmix::cartoons","","Cartoons"), ]) return content #elif clist=="search": # TODO #return content elif data in ("movies","series","cartoons"): r = self.call("") r = r.decode("cp1251").encode("utf8") if data == "movies": sname = "Фильмы" elif data=="series": sname = "Сериалы" else: sname = "Мультфильмы" # Фильмы m = re.search('%s(.+?)
  • \s+?([^<]+)', 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) pl_link = js["message"]["translations"]["flash"].values()[0] # TODO process several players 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 '