#!/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 binascii import datetime, re, sys,os, time import ConfigParser from collections import OrderedDict from SourceBase import SourceBase import requests import ssl if "_create_unverified_context" in dir(ssl): ssl._create_default_https_context = ssl._create_unverified_context try: from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) except: pass #import resolver 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="",cfg_path=None): self.hidden = False # nerāda menu nestrādājošos avotus self.name = "filmas" self.title = "Filmas.lv" self.img = "filmas.png" self.desc = "Filmas.lv - Latvijas filmas" self.headers = headers2dict(""" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate, br """) 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://www.filmas.lv/" ######### Entry point ######## def get_content(self, data): print "[filmas] get_content:", data source, data, path, plist, clist, params, qs = self.parse_data(data) content = [] content.append(("..return", "back","back.png","Return back")) if clist=="home": content.extend([ ("Meklēt", "filmas::lmdb/api/search/?term={0}","","Meklēt"), ("Visas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-all&watch=latvia&pg=1","","Latvijā skatamās visas filmas"), ("Spēlfilmas", "filmu-katalogs/?tab=movies&sub_tab=movies-all&mp20=112&watch=latvia&pg=1","","Latvijā skatamās spēlfilmas"), ("Dokumentalās filmas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-hronika&pg=1","","Latvijā skatamās kinohronikas") , ("Animācijas filmas", "filmu-katalogs/?tab=movies&sub_tab=movies-all&mp20=113&watch=latvia&pg=1","","Latvijā skatamās animācijas filmas"), ("Kinohronikas", "filmas::filmu-katalogs/filmu-katalogs/?tab=movies&sub_tab=movies-hronika","","Latvijā skatamās kinohronikas") , ("Pēc alfabēta", "filmas::filmu-katalogs/?ml=A&tab=movies&sub_tab=movies-abc&pg=1","","Latvija skatamās filmas pēc alfabēta") , ]) return content elif "api/search" in data: r = self.call(data) js = json.loads(r) for it in js: if "type" in it and it["type"] == "movie": title = it["label"] + "(%s)" % it["year"] if "year" in it else "" img = ("https://www.filmas.lv/images/movies/" + it["photo"]) if "photo" in it and it["photo"] else "" desc = title data2 = "movie/%s" % it["value"] content.append((title,self.name+"::"+data2,img,desc)) return content elif clist=="filmu-katalogs": r=self.call(data) result = re.findall(r'.+?src="([^"]+)".+?"movie-catalog-title">([^<]+)<.+?"movie-catalog-year">([^<]+)<', r, re.DOTALL) for item in result: title = item[2]+' (%s)'%item[3] data2 = item[0] img = item[1] desc = title content.append((title,self.name+"::"+data2,img,desc)) m = re.search("