def handleFolder(self, url=None, code=None): if not code: code = re.search(r'/folder/([^\?]+)', url).group(1) r = self.request.get( 'https://www.fshare.vn/api/v3/files/folder?linkcode=%s&sort=type,name' % code) r = json.loads(r) listitems = [] if 'items' in r and len(r['items']) > 0: listitems = [ "[%s] %s" % (i['type'] == 1 and helper.humanbytes(i["size"]) or 'Folder', i["name"]) for i in r['items'] ] else: helper.message("Fshare link folder die") return index = helper.create_select_dialog(listitems) if index == -1: return None if r['items'][index]['type'] == 1: return r['items'][index]['linkcode'] else: return self.handleFolder(code=r['items'][index]['linkcode'])
def get_link(url, media): print("*********************** Apply Lotus url %s" % url) header = { 'referer': 'https://lotus.vn/', 'User-Agent': "Chrome/59.0.3071.115 Safari/537.36", } req = Request() response = req.get(url, headers=header) print(response.encode('utf8')) source = re.search(r'"link":\s?"(.*?)",', response) if '.mp4' in source.group(1): url = source.group(1) return url, 'lotus' if source: master_url = source.group(1) playlist = get_adaptive_link(Request().get(master_url, headers=header)) listitems = [] for i in playlist: listitems.append("%s (%s)" % (i[0], i[1])) index = helper.create_select_dialog(listitems) if index == -1: return None, None else: url = playlist[index][1] url = "{}|{}".format(url, urlencode(header)) return url, 'lotus'
def get_link(url): response = Request().get(url) enc = re.search(r'(eval\(function\(p,a,c,k,e,d\).*)\s+?</script>', response) enc2 = re.search(r'sources:\s?(\[.*?\]),', response) found = False print "Apply VUVIPHIM parser" if enc: sources = enc.group(1) sources = Packer().unpack(sources) sources = re.search(r'sources:\s?(.*?\]),', sources) found = True elif enc2: sources = enc2.group(1) found = True if found: try: sources = re.sub(r'(?<={|,)([a-zA-Z][a-zA-Z0-9]*)(?=:)', r'"\1"', sources.group(1)) except: pass sources = json.loads(sources) print sources score = {'sd': 1, 'hd': 2, '360p': 1, '480p': 2, '720p': 3, '1080p': 3} if len(sources) > 0: try: sources = sorted(sources, key=lambda elem: elem['label'].lower() in score and score[elem['label'].lower()] or 3, reverse=True) except: pass if len(sources) > 1: listitems = [ "Link %s (%s)" % (i["label"], i["file"]) for i in sources ] index = helper.create_select_dialog(listitems) if index == -1: return None, 'mp4' else: return sources[index][ 'file'] + '|referer=' + urllib.quote_plus( url), sources[index]['type'] else: return sources[0]['file'] + '|referer=' + urllib.quote_plus( url), sources[0]['type'] return url, 'vuviphim'