def get_folder(self,url): if '/file/' in url:return {'pagename':'','items':[]} response=self.fetch(url) if not response or response.status!=200:self.fetch(url) body=response.body if response and response.status==200 else '' pagename=utils.xsearch('<title>(.+?)</title>',body).replace('Fshare - ','') items=list() for content in re.findall('<div class="pull-left file_name(.+?)<div class="clearfix"></div>',body,re.S): item=re.search('data-id="(.+?)".+?href="(.+?)".+?title="(.+?)"',content) if item: size=utils.xsearch('<div class="pull-left file_size align-right">(.+?)</div>',content).strip() id=item.group(1);type='file' if 'file' in item.group(2) else 'folder';title=item.group(3) if type=='file':link='https://www.fshare.vn/file/%s'%id elif re.search('(\w{10,20} )',title): iD=utils.xsearch('(\w{10,20} )',title) if 'FOLDER' in iD:link='https://www.fshare.vn/folder/%s'%iD.replace('FOLDER','') elif 'FILE' in iD:link='https://www.fshare.vn/file/%s'%iD.replace('FILE','') else: link='https://www.fshare.vn/folder/%s'%iD try: if self.session.get(link).status!=200:link='https://www.fshare.vn/file/%s'%iD except:pass title=' '.join(s for s in title[title.find(' '):].split()) else:link='https://www.fshare.vn/folder/%s'%id;title=' '.join(s for s in title.split()) date=utils.xsearch('"pull-left file_date_modify align-right">(.+?)</div>',content).strip() items.append((title,link,id,size,date)) return {'pagename':pagename,'items':items}
def get_maxlink(self,url): response=self.fetch(url);result=pw=None if not response:print 'Not response' elif response.status==302:result=response.headers['location'] elif response.status==200: if re.search('<title>.*Lỗi 404.*</title>|"index-404"',response.body): utils.mess(u'Tập tin quý khách yêu cầu không tồn tại!','Fshare.vn');result='fail' elif 'sử dụng nhiều địa chỉ IP' in response.body: utils.mess(u'Quý khách đang sử dụng nhiều địa chỉ IP để tải xuống!','Fshare.vn',10000) result='fail' elif re.search('<i class="fa fa-star">',response.body):utils.mess('Your Fshare acc is FREE','Fshare.vn') if re.search('class="fa fa-lock"',response.body): pw=utils.get_input(u'Hãy nhập: Mật khẩu tập tin') if pw: try: data={'fs_csrf':utils.xsearch('value="(.+?)" name="fs_csrf"',response.body), 'DownloadForm[pwd]':pw,'ajax':'download-form','DownloadForm[linkcode]':url.split('/')[4]} response=self.fetch('https://www.fshare.vn/download/get',data).json except:response={} if not response:utils.mess(u'Get maxspeed link fail!','Fshare.vn');result='fail' elif response.get('url'):result=response.get('url') elif response.get('DownloadForm_pwd'):utils.mess(u'Mật khẩu không chính xác!','Fshare.vn') else: print response elif re.search('action="/download/get"',response.body): href='https://www.fshare.vn'+utils.xsearch('action="(/download/get)"',response.body) fs_csrf=utils.xsearch('value="(.+?)" name="fs_csrf"',response.body) downloadForm=utils.xsearch('id="DownloadForm_linkcode" type="hidden" value="(.+?)"',response.body) data={'fs_csrf':fs_csrf,'DownloadForm[pwd]':'','DownloadForm[linkcode]':downloadForm, 'ajax':'download-form','undefined':'undefined'} response=self.fetch(href,data) try:result=response.json.get('url') except:pass
def phimnhanh(b): href = xsearch('link_url.+?(http.+?)"', b).replace("\\", "") + xsearch( '"key\W+"(.+?)"', b) try: j = json.loads(xread(href)) except: j = {} return j
def getLink(url): if 'http://thvl.vn/jwplayer/' not in url: b = xread(url, {"Referer":"http://thvl.vn/"}) url = xsearch('<iframe src="(.+?)"',b) if 'youtu.be' in url or 'youtube.com' in url: return url b = xread(fixLink(url), {"Referer":"http://thvl.vn/"}) link = xsearch('file: *"(.+?)"',b) return link
def __init__(self, s): try: w, i, s, e=s.split(',') s=self.dec(w, i, s, e) b=utils.xsearch("(\w{100,},\w+,\w+,\w+)",s.replace("'",'')) w, i, s, e=b.split(',') s=self.dec(w, i, s, e) b=utils.xsearch("(\w{100,},\w+,\w+,\w+)",s.replace("'",'')) w, i, s, e=b.split(',') s=self.dec(w, i, s, e) except:s='' self.string=s
def pageNext(b, items, query): s = xsearch("(<div class='wp-pagenavi'.+?/div>)",b,1,re.S) href = xsearch("<span class='current'>\d+</span><a href='([^']+?)'",s).replace('#038;','') if href: next = xsearch('paged=(\d+)',href) last = xsearch("<a href='[^']+?(\d+)' class='last'>Cuối »</a>",s) if not last: last = re.findall('>(\d+)</a>',s) last = last[-1] if last else '' title = "Trang kế: %s/%s"%(next, last) items.append((namecolor(title,'lime'), fixLink(href), "", query, True))
def chuongtrinh21h(url): b = xread(url) items = [] for s in re.findall('(<h3>».+?"post-info">)',b,re.S): title = s2c(xsearch('>([^<]+?)</a>',s)) href = xsearch('href="([^"]+?)"',s) if not title or not href: continue img = xsearch('src="([^"].+?)"',s) items.append((namecolor(title, c), fixLink(href), img, 'eps', True)) return items
def tonghop(url): b = xread(url) items = [] for s in re.findall('(<div class="post-content clearfix".+?"content clearfix">)',b,re.S): title = '[COLOR cyan]%s[/COLOR]'%xsearch('class="date">([^<].+?)<',s) title = title + ' ' + s2c(xsearch('alt="([^"].+?)"',s)) href = xsearch('href="([^"].+?)"',s) img = xsearch('src="([^"].+?)"',s) items.append((namecolor(title,c), fixLink(href), img, 'eps', True)) pageNext(b, items, 'tonghop') return items
def recode(b): def getcode(s): w, i, s, e=s.split(',') a=b=c=0;d=[];f=[] while True: if a < 5:f.append(w[a]) elif a < len(w):d.append(w[a]) a+=1 if b < 5 :f.append(i[b]) elif b < len(i):d.append(i[b]) b+=1 if c < 5:f.append(s[c]) elif c < len(s):d.append(s[c]) c+=1 if len(w) + len(i) + len(s) + len(e) == len(d) + len(f) + len(e):break k=''.join(s for s in d);m=''.join(s for s in f);b=0;o=[] for a in range(0,len(d),2): n = -1 if ord(m[b]) % 2:n = 1 o.append(chr(int(k[a:a+2], 36) - n)) b+=1 if b >= len(f):b = 0 return ''.join(s for s in o) l=0 while l<5 or 'decodeLink' not in b: try:b=getcode(utils.xsearch("(\w{100,},\w+,\w+,\w+)",b.replace("'",'')));l+=1 except:break return b
def myFshare_upload(self,name,size,content): response=self.fetch('https://www.fshare.vn/home');result=False if not response or response.status!=200: content=self.fetch('https://www.fshare.vn/home') if not response or response.status!=200:utils.mess(u'Get home page fail!','Fshare.vn');return result token=utils.xsearch('data-token="(.+?)"',response.body) path=utils.xsearch('data-id="%s" path-origin = "" data-path="(.+?)"'%self.myFshare,response.body) SESSID=self.session.cookies.get('session_id') data='{"SESSID":"%s","name":"%s","size":"%s","path":"%s","token":"%s","secured":1}'%( SESSID,name,size,path,token);print data response=self.fetch('https://www.fshare.vn/api/session/upload',data) if response and response.status==200: response=self.fetch(response.json['location'],content) if response and response.status==200:result=True;utils.mess(u'Upload file to MyFshare success','Fshare.vn') if result is False:utils.mess(u'Upload file to MyFshare fail!','Fshare.vn');print response.status return result
def phim(url): b = xread(url) b = b[b.find('<div id="main-content">'):] s = re.findall('(<div class="video-clip-box".+?/div)', b, re.S) items = [] for s in s: title = xsearch('class="date">([^<].+?)<', s) if title: title = '[COLOR cyan]%s[/COLOR] ' % title title = title + s2c(xsearch('alt="([^"].+?)"', s)) href = xsearch('href="([^"].+?)"', s) img = xsearch('src="([^"].+?)"', s) items.append((namecolor(title, c), fixLink(href), img, 'eps', True)) pageNext(b, items, 'phim') return items
def login(self,username,password): response = self.fetch('https://www.fshare.vn/login') if not response or response.status!=200:utils.mess('Connect to fshare.vn fails','Fshare.vn') else: data = {"LoginForm[email]":username,"LoginForm[password]":password, "fs_csrf":utils.xsearch('value="(.+?)" name="fs_csrf"',response.body)} response = self.fetch('https://www.fshare.vn/login',data) if response and response.status==302:utils.mess(u'Login thành công','Fshare.vn');self.logged='success' else:utils.mess(u'Login không thành công!','Fshare.vn')
def action_bookmark(self, url,action):#add_bookmark/remove_bookmark id=utils.xsearch('_(\d+?)/',url) if id: url='http://phim3s.net/ajax/member/%s/?film_id=%s'%(action,id) response=self.fetch(url) try:response=response.json except:response={} utils.mess(u'%s'%response.get('message','%s thất bại !'%action),'Phim3s.net bookmark') self.fetch('http://phim3s.net/member/logout/')
def schedule1(url): href = "http://thvl.vn/jwplayer/?l=rtmp" if "THVL1" in url: href = "http://thvl.vn/jwplayer/?l=rtmp2" s = xsearch('(<table.+?/table>)',xread(url)) s = [' '.join(re.sub('<.+?>',' ',i).split()) for i in re.findall('(<tr.+?/tr>)',s)] return [(i,href,"","live",False) for i in s if i]
def schedule(url): href = "http://thvl.vn/jwplayer/?l=rtmp" if "THVL1" in url: href = "http://thvl.vn/jwplayer/?l=rtmp2" s = xsearch('(<table.+?/table>)',xread(url)) s = [' '.join(re.sub('<.+?>',' ',i).split()) for i in re.findall('(<tr.+?/tr>)',s)] return [(i,href,"","live",False) for i in s if i]
def episode(name, url, img): b = xread(url) if 'paged=' not in url and '<h3>» <a href="' not in b: hrefs = re.findall( '<a href="(http://thvl.vn/\?cat=\d+)" title="(.+?)">', b) if not hrefs: return [(namecolor(name), url, img, "live", False)] href = [i for i in hrefs if i[1] in name] if href: href = href[0][0] else: href = hrefs[0][0] b = xread(href) if '<h3>» <a href="' not in b: b = b[b.find('<div id="main-content">'):] else: b = b[b.find('<h3>» <a href="'):] s = re.findall('(<div class="video-clip-box".+?/div)', b, re.S) if not s: s = re.findall( '(<div class="post-content clearfix".+?"content clearfix">)', b, re.S) items = [] for s in s: title = xsearch('class="date">([^<].+?)<', s) if title: title = '[COLOR cyan]%s[/COLOR] ' % title title = title + s2c(xsearch('alt="([^"].+?)"', s)) href = xsearch('href="([^"].+?)"', s) img = xsearch('src="([^"].+?)"', s) items.append((title, fixLink(href), img, 'live', False)) pageNext(b, items, 'eps') return items
def phim(url): b = xread(url) b = b[b.find('<div id="main-content">'):] s = re.findall('(<div class="video-clip-box".+?/div)',b,re.S) items = [] for s in s: title = xsearch('class="date">([^<].+?)<',s) if title: title = '[COLOR cyan]%s[/COLOR] '%title title = title + s2c(xsearch('alt="([^"].+?)"',s)) href = xsearch('href="([^"].+?)"',s) img = xsearch('src="([^"].+?)"',s) items.append((namecolor(title, c), fixLink(href), img, 'eps', True)) pageNext(b, items, 'phim') return items
def episode(name, url, img): b = xread(url) if 'paged=' not in url and '<h3>» <a href="' not in b: hrefs = re.findall('<a href="(http://thvl.vn/\?cat=\d+)" title="(.+?)">',b) if not hrefs: return [(namecolor(name), url, img, "live", False)] href = [i for i in hrefs if i[1] in name] if href: href = href[0][0] else: href = hrefs[0][0] b = xread(href) if '<h3>» <a href="' not in b: b = b[b.find('<div id="main-content">'):] else: b = b[b.find('<h3>» <a href="'):] s = re.findall('(<div class="video-clip-box".+?/div)',b,re.S) if not s: s = re.findall('(<div class="post-content clearfix".+?"content clearfix">)',b,re.S) items = [] for s in s: title = xsearch('class="date">([^<].+?)<',s) if title: title = '[COLOR cyan]%s[/COLOR] '%title title = title + s2c(xsearch('alt="([^"].+?)"',s)) href = xsearch('href="([^"].+?)"',s) img = xsearch('src="([^"].+?)"',s) items.append((title, fixLink(href), img, 'live', False)) pageNext(b, items, 'eps') return items
def make_request(url,headers=hd,resp='b',maxr=0): try: if maxr==0:response=get(url,headers=headers)#,timeout=2) else:response=get(url,headers=headers,max_redirects=maxr)#,timeout=2) if resp=='o':resp=response else: if resp=='j':resp=response.json elif resp=='s':resp=response.status elif resp=='u':resp=response.text elif resp=='c':resp=response.cookiestring else:resp=response.body response.close() except: if resp=='j':resp=dict() elif resp=='s':resp=500 else:resp='' if 'vaphim.com' not in url: link=xsearch('//(.{5,20}\.\w{2,3})',s2u(url)) if not link:link=url mess(u'Lỗi kết nối tới: %s!'%xsearch('//(.{5,20}\.\w{2,3})',s2u(url)),'make_request') print 'Lỗi kết nối tới: %s!'%u2s(url); return resp#unicode:body=response.text
def upload_file(self,fn):#Chua xong size=os.path.getsize(fn);name=os.path.basename(fn);path='/' session_id=utils.xsearch('session_id=(.+?)\W',str(self.hd)) data='{"SESSID":"%s","name":"%s","path":"%s","secured":"1","size":"%d","token":"%s"}'%(session_id,name,path,size,self.get_token()) response=self.fetch('https://www.fshare.vn/api/session/upload',data) print 'a',data if response and response.status==200: print response.json['location'] try:response=urlfetch.fetch(response.json['location'].replace('http:','https:'),headers=self.hd,data=data)#files=fn) except:response= None #response=self.fetch(response.json['location'],files=fn) if response and response.status==200: print response.json result=True;utils.mess(u'Upload file to MyFshare success','Fshare.vn')
def kphim(b, url, server_id, video_id): hd = { 'User-Agent': 'Mozilla/5.0', 'X-Requested-With': 'XMLHttpRequest', 'Referer': url } from hashlib import md5 from utils import xsearch ver = xsearch("ver\W*'(.+?)'", b) tk = "kp" + server_id + "dung_get_em_nua" + video_id + ver tk = md5(tk).hexdigest()[1:] href = "http://www.kphim.tv/player/%s/%s/%s" % (server_id + ver, video_id + ver, tk) data = 'mid=%s&vid=%s&sid=%s' % (ver, server_id, video_id) #import xbmc;xbmc.log("b=xread('%s',%s,'%s')"%(href,str(hd),data)) return xread(href, hd, data)
def get_maxlink(self,url): response=self.fetch(url);result=pw=None if not response:print 'Not response' elif response.status==302:result=response.headers['location'] elif response.status==200: if re.search('<title>.*Lỗi 404.*</title>|"index-404"',response.body): utils.mess(u'Tập tin quý khách yêu cầu không tồn tại!','Fshare.vn');result='fail' elif re.search('<i class="fa fa-star">',response.body):utils.mess('Your Fshare acc is FREE','Fshare.vn') if re.search('class="fa fa-lock"',response.body):pw=utils.get_input(u'Hãy nhập: Mật khẩu tập tin') if pw: try: data={'fs_csrf':utils.xsearch('value="(.+?)" name="fs_csrf"',response.body), 'DownloadForm[pwd]':pw,'ajax':'download-form','DownloadForm[linkcode]':url.split('/')[4]} response=self.fetch('https://www.fshare.vn/download/get',data).json except:response={} if not response:utils.mess(u'Get maxspeed link fail!','Fshare.vn');result='fail' elif response.get('url'):result=response.get('url') elif response.get('DownloadForm_pwd'):utils.mess(u'Mật khẩu không chính xác!','Fshare.vn') else: print response
def resolu(s): s=s.replace('HDG','').replace('HD','1080').replace('SD','640').replace('large','640').replace('medium','480').replace('small','360') result=xsearch('(\d+)',s) return result if result else '240'
def get_token(self): response=self.fetch('https://www.fshare.vn/home') if not response or response.status!=200: content=self.fetch('https://www.fshare.vn/home') if not response or response.status!=200:utils.mess(u'Get home page fail!','Fshare.vn');return '' return utils.xsearch('data-token="(.+?)"',response.body)
def unescape(string):return ' '.join(re.sub('&.+;',xsearch('&(\w).+;',s),s) for s in string.split()) def u2s(s):return s.encode('utf-8') if isinstance(s,unicode) else s
def get_token(self,url='https://www.fshare.vn/home'): self.hd['x-pjax']='true' response=self.fetch(url) if not response or response.status!=200:utils.mess(u'Get home page fail!','Fshare.vn');return '' self.token=utils.xsearch('data-token="(.+?)"',response.body) return self.token