# -*- coding: UTF-8 -*-
from __future__ import division
import sys,re,os
import six
from six.moves import urllib_parse
import json
import requests
from requests.compat import urlparse
import xbmcgui
import xbmcplugin
import xbmcaddon
import xbmc, xbmcvfs
from resources.lib.brotlipython import brotlidec
if six.PY3:
basestring = str
unicode = str
xrange = range
from resources.lib.cmf3 import parseDOM
else:
from resources.lib.cmf2 import parseDOM
import resolveurl
base_url = sys.argv[0]
addon_handle = int(sys.argv[1])
params = dict(urllib_parse.parse_qsl(sys.argv[2][1:]))
addon = xbmcaddon.Addon(id='plugin.video.wrestlingwatch')
PATH = addon.getAddonInfo('path')
if six.PY2:
DATAPATH = xbmc.translatePath(addon.getAddonInfo('profile')).decode('utf-8')
else:
DATAPATH = xbmcvfs.translatePath(addon.getAddonInfo('profile'))
RESOURCES = PATH+'/resources/'
FANART=RESOURCES+'../fanart.jpg'
ikona =RESOURCES+'../icon.png'
exlink = params.get('url', None)
nazwa= params.get('title', None)
rys = params.get('image', None)
page = params.get('page',[1])#[0]
UA= 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36'
TIMEOUT=15
headers = {'User-Agent': UA,}
sess = requests.Session()
def build_url(query):
return base_url + '?' + urllib_parse.urlencode(query)
def add_item(url, name, image, mode, itemcount=1, page=1,fanart=FANART, infoLabels=False,contextmenu=None,IsPlayable=False, folder=False):
list_item = xbmcgui.ListItem(label=name)
if IsPlayable:
list_item.setProperty("IsPlayable", 'True')
if not infoLabels:
infoLabels={'title': name}
list_item.setInfo(type="video", infoLabels=infoLabels)
list_item.setArt({'thumb': image, 'poster': image, 'banner': image, 'fanart': fanart})
if contextmenu:
out=contextmenu
list_item.addContextMenuItems(out, replaceItems=True)
else:
out = []
out.append(('Informacja', 'XBMC.Action(Info)'),)
list_item.addContextMenuItems(out, replaceItems=False)
xbmcplugin.addDirectoryItem(
handle=addon_handle,
url = build_url({'mode': mode, 'url' : url, 'page' : page, 'title':name,'image':image}),
listitem=list_item,
isFolder=folder)
xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE, label2Mask = "%R, %Y, %P")
def Clean_title(tit):
zmiany = (('full ',''),('watch ',''),('online ',''),(' free',''),(' show',''))
for z in zmiany:
tit = re.sub(z[0], z[1], tit, 0, re.IGNORECASE)
return tit
def ListLinks(url):
html=getUrlReqOk(url)
zz=''
try:
# videos = parseDOM(html,'div', attrs={'id':"content_section"})[0]
#videos = parseDOM(html,'div', attrs={'class':"entry-content rich-content"})[0]
videos = re.findall("jQuery\(\'body\'\)(.*?)jQuery",html,re.DOTALL)[0].replace("\'",'"')
except:
videos = parseDOM(html,'center')[0]
#
vidz = parseDOM(html,'div', attrs={'class':"episodeRepeater"})#[0]
for vid in vidz:
xcxcx=''
maintit = parseDOM(vid,'h1')
if maintit:
tm = '[COLOR yellowgreen]....----~~~~````-==' +maintit[0]+ '==````~~~~----....[/COLOR]'
add_item('xx', tm ,rys, ' ',fanart=FANART, folder=False, IsPlayable=False)
#href="https://geostudies.org/embed.php/?id=k7ae8sW2SeRMecyGfTJ&host=dm" rel="nofollow" target="_blank">Part 1([^<]+)<\/a",vid,re.DOTALL)
#typ = re.findall('>([^<]+)<\/span>',videos,re.DOTALL)
for x,nazw in xx:
href = x.replace('&','&')
try:
title = re.findall('campaign=(.+?)\&',href,re.DOTALL)[0]
except:
title = urlparse(href).netloc.strip()
if 'watch prev' in nazw.lower() or 'previous' in nazw.lower() :
break
tit = '[B][COLOR gold]'+nazwa + ' [/COLOR]'+'[COLOR khaki]'+nazw + '[/B][/COLOR][I] (' +title+')[/I]'
add_item(href, tit ,rys, 'playlink',fanart=FANART, folder=False, IsPlayable=True)
xbmcplugin.endOfDirectory(addon_handle)
def PlayLink(url):
ref=''
if '|' in url:
url,ref = url.split('|')
link=''
if 'premiumplug' in url or 'issuessolution' in url or 'gpllicense' in url or 'sports-update.com' in url or 'geostudies.org' in url:
html=getUrlReqOk(url,ref)
iframe = parseDOM(html,'iframe', ret="src")[0]
iframe = 'https:' + iframe if iframe.startswith('//') else iframe
else:
if '/t.co/' in url:
html=getUrlReqOk(url,ref)
url = re.findall('URL\s*=\s*(.*?)"',html,re.DOTALL)[0]
html=getUrlReqOk(url,ref)
iframe = parseDOM(html,'iframe', ret="src")[0]
iframe = 'https:' + iframe if iframe.startswith('//') else iframe
else:
iframe = url
try:
link = resolveurl.resolve(iframe)
except:
if 'dood' in iframe:
from resources.lib import dood
try:
link = dood.getLink(iframe)
except:
pass
if 'drop.down' in iframe and not link:
from resources.lib import dood
try:
link =dood.getDropDown(iframe)
except:
pass
elif 'm2list' in iframe and not link:
from resources.lib import dood
try:
link =dood.getm2list(iframe,url)
except:
pass
elif 'sawlive' in iframe and not link:
from resources.lib import dood
try:
link =dood.getsawlive(iframe,url)
except:
pass
if link:
play_item = xbmcgui.ListItem(path=link)
play_item.setInfo(type="Video", infoLabels={"title": nazwa,'plot':nazwa, 'thumb' :rys, 'icon': rys})
xbmcplugin.setResolvedUrl(addon_handle, True, listitem=play_item)
else:
xbmcgui.Dialog().notification('[COLOR orangered][B]Error[/B][/COLOR]', "[COLOR orangered][B]Video has been removed\n or can't resolve link[/B][/COLOR]", xbmcgui.NOTIFICATION_INFO, 5000,False)
sys.exit(1)
def ListPage(url, pg):
if '/page/' in url:
url = re.sub('/page/\\d+','/page/%d'%int(pg),url)
else:
url = url + '/page/%d' %int(pg)
html=getUrlReqOk(url)
nextpage=False
if html.find('rel="next"')>0:
nextpage = unicode(int(pg)+1)
# posty = parseDOM(html,'div', attrs={'id':"post\-.*?"})
posty = parseDOM(html,'div', attrs={'id':"\d+"})
for p in posty:
try:
dane = re.findall('(
',p,re.DOTALL)[0]
except:
dane = re.findall('(a.*?\s*alt\s*=\s*".*?)<\/a>',p,re.DOTALL)[0]
title = Clean_title(re.findall('title\s*=\s*"([^"]+)"',dane,re.DOTALL)[0])
href = re.findall('href\s*=\s*"([^"]+)"',dane,re.DOTALL)[0]
# img = re.findall('data\-lazy\-src\s*=\s*"([^"]+)"',dane,re.DOTALL)[0]
img = re.findall('img\s*src\s*=\s*"([^"]+)"',dane,re.DOTALL)[0]
#img src="
img = 'https:' + img if img.startswith('//') else img
add_item(href, PLchar(title) ,img, 'listlinks',fanart=FANART, folder=True)
if nextpage:
add_item(url, '>> next page >>' ,RESOURCES+'right.png', "listpage",fanart=FANART, page=nextpage, folder=True)
xbmcplugin.endOfDirectory(addon_handle)
def Menu2():
add_item('https://watchprowrestling.org/', 'Most recent shows' ,ikona, 'getRecent' ,fanart=FANART, folder=True)
try:
url = 'https://watchprowrestling.org/'
html=getUrlReqOk(url)
result = parseDOM(html,'ul', attrs={'id':"main-menu"})[0]
titlehref = re.findall('a title="([^"]+)"\s*href="([^"]+)"',result)
for title,href in titlehref:
if href == '#':
continue
add_item(href, title ,ikona, 'getRecent',fanart=FANART, folder=True)
except:
add_item('', '[COLOR pink][B]>=>=>=>=>=>=> error occured <=<=<=<=<=<=<[/B][/COLOR]', ikona, "err",fanart=FANART, folder=False, IsPlayable=False)
xbmcplugin.endOfDirectory(addon_handle)
def Menu():
try:
url = 'https://watchwrestling.ai/'
url = 'https://watchwrestling.ae'
html=getUrlReqOk(url)
# result = parseDOM(html,'div', attrs={'class':"menu-main-navigation-container"})[0]
result = parseDOM(html,'div', attrs={'id':"main-nav"})[0]
# (.*?)<\/ul',result,re.DOTALL)
#
# for sub in subm:
#
# sub1 = re.sub('
','',sub2)
# result = re.sub(sub,sub3,result)
menus = re.findall('