# -*- coding: utf8 -*-
import urllib,urllib2,re,sys,os
from iTools import CBaseAddonClass,printD,printE
##########################################
class myaddon(CBaseAddonClass):
def __init__(self):
CBaseAddonClass.__init__(self,{'cookie':'myaddon.cookie'})
self.USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0'
self.MAIN_URL ="http://myaddon.com"
self.HEADER = {'User-Agent': self.USER_AGENT, 'DNT':'1', 'Accept': 'text/html', 'Accept-Encoding':'gzip, deflate', 'Referer':self.getMainUrl(), 'Origin':self.getMainUrl()}
self.AJAX_HEADER = dict(self.HEADER)
self.AJAX_HEADER.update( {'X-Requested-With': 'XMLHttpRequest', 'Accept-Encoding':'gzip, deflate', 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8', 'Accept':'application/json, text/javascript, */*; q=0.01'} )
self.cacheLinks = {}
self.defaultParams = {'header':self.HEADER, 'raw_post_data':True, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIE_FILE}
def showmenu(self):
self.addDir('search','https://yts.lt/api/v2/list_movies.json?limit=50&sort_by=date_added&quality=all&genre=all',103,'img/search.png','',1,searchall=True)
self.addDir('Most Downloads','https://yts.lt/api/v2/list_movies.json?limit=50&sort_by=date_added&quality=all&genre=all',100,'img/1.png','',1)
self.addDir('Recent','https://yts.lt/api/v2/list_movies.json?limit=50&sort_by=download_count&quality=all&genre=all',100,'img/2.png','',1)
self.addDir('Top rated','https://yts.lt/api/v2/list_movies.json?limit=50&sort_by=rating&quality=all&genre=all',100,'img/3.png','',1)
self.addDir('Most liked','https://yts.lt/api/v2/list_movies.json?limit=50&sort_by=like_count&quality=all&genre=all',100,'img/4.png','',1)
def search_103(self,name,sterm,page):
surl='https://m2.arabseed.net/?s='
if page>1:
url_page='https://m2.arabseed.net/page/%s/?s=%s'%(str(page),sterm)
else:
url_page=surl+sterm
##################################################################
data=self.getcfPage(url_page)
if data is None:
return
print "data",data
#data=self.getDM(data,'ti-video-library','class="pagination"',False)
blocks=data.split('class="BlockItem ISMovie"')
i=0
print "blocks",len(blocks)
blocks.pop(0)
print "block",blocks[0]
for block in blocks:
regx='''href="(.*?)"'''
href=self.getSM(block,regx)
regx='''data-src="(.*?)"'''
image=self.getSM(block,regx)
regx='''title="(.*?)"'''
title=self.getSM(block,regx)
regx='''<div class="Rate">imdb <em>(.*?)</em></div>'''
rating=self.getSM(block,regx)
if rating!='':
title=title+"("+rating+")"
regx='''<p>(.*?)</p>'''
desc=self.getSM(block,regx)
title=title.replace("’"," ")
title=self.colorize(title,"green")
if 'مسلسل' in title:
mode=201
else:
mode=1
try:self.addDir(title,href,mode,image,name,1,True,desc=desc)
except:pass
if len(blocks)>22:
self.addDir("next page",sterm,103,'img/next.png','',str(page+1),dialog='nsearch')
def getmovies_100(self,name,url,page):
if page>1:
#http://arabseed.net/cat_film/%D8%A7%D9%81%D9%84%D8%A7%D9%85-%D8%A7%D8%AC%D9%86%D8%A8%D9%8A/page/2/
url_page=url+"?page="+str(page)
else:
url_page=url
data=self.getcfPage(url_page)
if data is None:
return
#data=self.getDM(data,'ti-video-library','class="pagination"',False)
blocks=data.split('class="BlockItem ISMovie"')
i=0
blocks.pop(0)
print "block",blocks[0]
for block in blocks:
regx='''href="(.*?)"'''
href=self.getSM(block,regx)
regx='''data-src="(.*?)"'''
image=self.getSM(block,regx)
regx='''title="(.*?)"'''
title=self.getSM(block,regx)
regx='''<div class="Rate">imdb <em>(.*?)</em></div>'''
rating=self.getSM(block,regx)
if rating!='':
title=title+"("+rating+")"
regx='''<p>(.*?)</p>'''
desc=self.getSM(block,regx)
title=title.replace("’"," ")
title=self.colorize(title,"green")
try:self.addDir(title,href,1,image,name,1,True,desc=desc)
except:pass
if len(blocks)>22:
self.addDir("next page",url,100,'img/next.png','',str(page+1))
###############################################series
def getseries_200(self,name,url,page):
if page>1:
#http://arabseed.net/cat_film/%D8%A7%D9%81%D9%84%D8%A7%D9%85-%D8%A7%D8%AC%D9%86%D8%A8%D9%8A/page/2/
url_page=url+"?page="+str(page)
else:
url_page=url
data=self.getPage(url_page)
if data is None:
return
blocks=data.split('class="BlockItem ISMovie"')
i=0
blocks.pop(0)
print "block",blocks[0]
for block in blocks:
regx='''href="(.*?)"'''
href=self.getSM(block,regx)
regx='''data-src="(.*?)"'''
image=self.getSM(block,regx)
regx='''title="(.*?)"'''
title=self.getSM(block,regx)
regx='''<div class="Rate">imdb <em>(.*?)</em></div>'''
rating=self.getSM(block,regx)
if rating!='':
title=title+"("+rating+")"
regx='''<p>(.*?)</p>'''
desc=self.getSM(block,regx)
title=self.colorize(title,"green")
if 'كامل' in title:
continue
title=title.replace("’"," ")
try:self.addDir(title,href,201,image,name,1,True,desc=desc)
except:pass
if len(blocks)>22:
self.addDir("next page",url,200,'img/next.png','',str(page+1))
###############################################series
def getepisode_201(self,name,url,image,page,extra,desc=''):
self.addDir(name,url,1,image,name,1,extra=extra,desc=desc,dialog='servers')
self.addDir("حلقات اخرى",url,202,image,name,1,extra=extra,desc=desc,dialog='servers')
def getepisodes_202(self,name,url,image,page,extra):
print '**************////////////////////////*******************//////////////////'
data=self.getPage(url)
#if 'class="BlockItem ISMovie"' in data:
#self.getepisodes_203( name,url,image,page,extra)
#return
extra,desc,img=self.metaData(url='',data=data,image=image)
regx1='''<li class="keywordsLi"><a href="(.*?)">.*?</a>'''
regx='''<a href="(.*?)" class="content-box ">\s(.*?)<span>(.*?)</span>'''
blocks=data.split('episode-block box-11x1')
blocks.pop(0)
for block in blocks:
href=self.getSM(block,'href="(.*?)"')
episode="episode"+"-"+self.getSM(block,'<span>(.*?)</span>')
self.addDir(episode,href,1,image,name,1,extra=extra,desc=desc,dialog='servers')
def getepisodes_203(self,name,url,image,page,extra):
if page>1:
#http://arabseed.net/cat_film/%D8%A7%D9%81%D9%84%D8%A7%D9%85-%D8%A7%D8%AC%D9%86%D8%A8%D9%8A/page/2/
url_page=url+"?page="+str(page)
else:
url_page=url
data=self.getPage(url_page)
if data is None:
return
blocks=data.split('class="BlockItem ISMovie"')
i=0
blocks.pop(0)
print "block",blocks[0]
for block in blocks:
regx='''href="(.*?)"'''
href=self.getSM(block,regx)
regx='''data-src="(.*?)"'''
image=self.getSM(block,regx)
regx='''title="(.*?)"'''
title=self.getSM(block,regx)
regx='''<div class="Rate">imdb <em>(.*?)</em></div>'''
rating=self.getSM(block,regx)
if rating!='':
title=title+"("+rating+")"
regx='''<p>(.*?)</p>'''
desc=self.getSM(block,regx)
title=self.colorize(title,"green")
try:self.addDir(title,href,202,image,name,1,True,desc=desc)
except:pass
if len(blocks)>22:
self.addDir("next page",url,200,'img/next.png','',str(page+1))
#######################################host resolving
def metaData(self,data='',extra={},image='',url='',desc='',show='movie'):
if show=='tv':
self.metaDataTV(url=url,image=image,data=data,desc=desc,extra=extra)
return
regx='''<i class="fa fa-fw fa-star"></i>(.*?)</span>'''
rating=self.getSM(data,regx)
extra['rating']=rating
year=self.getDM(data,'<span>تاريخ الاصدار','</li>')
extra['year']=self.cleanhtml(year)
country=self.getDM(data,'<span>الدولة','</li>')
extra['country']=self.cleanhtml(country)
language=self.getDM(data,'<span>اللغة','</li>')
extra['language']=self.cleanhtml(language)
duration=self.getDM(data,'<span>مدة العرض','</li>')
extra['duration']=self.cleanhtml(duration)
regx='''<a href="https://arabseed.net/altsnyf/(.*?)" )"'''
pg=self.getSM(data,regx)
pg=self.cleanhtml(pg)
extra['pg']=pg
regx='''<span>النوع"'''
genre=self.getDM(data,'<span>النوع','</li>')
genre=self.cleanhtml(genre,withSpace=True)
extra['genre']=str(genre)
regx='''href="https://arabseed.net/quality/(.*?)"'''
quality=self.getDM(data,'<span>الجودة','</li>')
extra['quality']=self.cleanhtml(quality)
regx='''<meta name="description" content="(.*?)" />'''
desc=self.getDM(data,'"description": "','",')
desc=self.cleanhtml(desc)
poster=self.getDM(data,'"thumbnailUrl": "','"')
if poster!='':
image=poster
return extra,desc,image
def getservers_1(self,name,url,img,extra):
print '7777777777777777777777777777',url
data=self.getPage(url)
extra,desc,img=self.metaData(data=data,extra=extra,image=img)
from arabseed import get_arabseed_Servers
servers=get_arabseed_Servers(url)
for server,href in servers:
if not 'arabseed' in href and not 'mixdrop' in href:
server,image,supported=self.getDomain(href)
self.addDir(server,href,3,img,name,1,extra=extra,dialog='servers',desc=desc)
return
def getservers_2(self,name,url,img,extra,desc):# get server arabseed.me
if 'arabseed' in url :
data=self.getPage(url)
regx='''<source src="(.+?)"'''
hrefs=re.findall(regx,data, re.M|re.I)
for href in hrefs:
print '***************************href__*****************',href
self.addDir('arabseed'+"-"+name,href,0,img,name,1,extra=extra,dialog='servers',desc=desc)
else:
self.resolvehost(name,url)
def resolve_host(self,name,url):
self.resolvehost(name,url)####
def run(self,params={}):
url=None
name=None
mode=None
page=1
name=params.get("name",'')
url=params.get("url",'')
try:mode=int(params.get("mode",None))
except:mode=None
image=params.get("image",'')
section=params.get("section",'')
page=int(params.get("page",1))
extra=params.get("extra",{})
desc=params.get("desc",'')
show=params.get("show",'')
##menu and tools
if mode==None:
self.showmenu()
##hosts
elif mode==1:
self.getservers_1(name,url,image,extra)
elif mode==2:
self.resolve_host(name,url)
elif mode==3:
self.getservers_2(name,url,image,extra,desc)
elif mode==103:
sterm = self.getsearchtext()
self.search_103("Search",sterm,page)
###movies
elif mode==100:
self.getmovies_100(name,url,page)
elif mode==101:
self.years_101()
elif mode==102:
self.getA_Z_102('movies')
###series
elif mode==200:
self.getseries_200(name,url,page)
elif mode==201:
self.getepisode_201(name,url,image,page,extra)
elif mode==202:
self.getepisodes_202(name,url,image,page,extra)
return self.endDir()
def start(params={}):
addon=myaddon()
return addon.run(params)