# coding=utf-8 # !/usr/bin/python """ 作者 丢丢喵 内容均从互联网收集而来 仅供交流学习使用 严禁用于商业用途 请于24小时内删除 ====================Diudiumiao==================== """ from Crypto.Util.Padding import unpad from Crypto.Util.Padding import pad from urllib.parse import urlparse from urllib.parse import unquote from Crypto.Cipher import ARC4 from urllib.parse import quote from base.spider import Spider from Crypto.Cipher import AES from datetime import datetime from bs4 import BeautifulSoup from base64 import b64decode import concurrent.futures import urllib.request import urllib.parse import datetime import binascii import requests import base64 import zlib import json import time import sys import re import os sys.path.append('..') xurl = "https://yhecfhhm.top:2549" # http://104.255.229.161:6688/?r=aHR0cDovL2hoZTQ5LmNvbS8= headerx = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36' } class Spider(Spider): def getName(self): return "丢丢喵" def init(self, extend): pass def searchContentPage(self, key, quick, pg): pass def isVideoFormat(self, url): pass def manualVideoCheck(self): pass def homeVideoContent(self): pass def extract_middle_text(self, text, start_str, end_str, pl, start_index1: str = '', end_index2: str = ''): if pl == 3: plx = [] while True: start_index = text.find(start_str) if start_index == -1: break end_index = text.find(end_str, start_index + len(start_str)) if end_index == -1: break middle_text = text[start_index + len(start_str):end_index] plx.append(middle_text) text = text.replace(start_str + middle_text + end_str, '') if len(plx) > 0: purl = '' for i in range(len(plx)): matches = re.findall(start_index1, plx[i]) output = "" for match in matches: match3 = re.search(r'(?:^|[^0-9])(\d+)(?:[^0-9]|$)', match[1]) if match3: number = match3.group(1) else: number = 0 if 'http' not in match[0]: output += f"#{match[1]}${number}{xurl}{match[0]}" else: output += f"#{match[1]}${number}{match[0]}" output = output[1:] purl = purl + output + "$$$" purl = purl[:-3] return purl else: return "" else: start_index = text.find(start_str) if start_index == -1: return "" end_index = text.find(end_str, start_index + len(start_str)) if end_index == -1: return "" if pl == 0: middle_text = text[start_index + len(start_str):end_index] return middle_text.replace("\\", "") if pl == 1: middle_text = text[start_index + len(start_str):end_index] matches = re.findall(start_index1, middle_text) if matches: jg = ' '.join(matches) return jg if pl == 2: middle_text = text[start_index + len(start_str):end_index] matches = re.findall(start_index1, middle_text) if matches: new_list = [f'{item}' for item in matches] jg = '$$$'.join(new_list) return jg def decrypt_data(self, Toubu, Zhongbu): key_bytes = self.get_key_bytes(Toubu) iv_bytes = key_bytes encrypted_bytes = self.decode_encrypted_data(Zhongbu) cipher = self.create_aes_cipher(key_bytes, iv_bytes) decrypted_padded = self.decrypt_data_bytes(cipher, encrypted_bytes) decrypted_bytes = self.unpad_data(decrypted_padded) decompressed_bytes = self.try_decompress(decrypted_bytes) result = self.decode_to_string(decompressed_bytes) return result def get_key_bytes(self, Toubu): return Toubu[:16].encode('utf-8') def decode_encrypted_data(self, Zhongbu): return base64.b64decode(Zhongbu.replace('\n', '').strip()) def create_aes_cipher(self, key_bytes, iv_bytes): return AES.new(key_bytes, AES.MODE_CBC, iv_bytes) def decrypt_data_bytes(self, cipher, encrypted_bytes): return cipher.decrypt(encrypted_bytes) def unpad_data(self, decrypted_padded): return unpad(decrypted_padded, AES.block_size) def try_decompress(self, decrypted_bytes): try: return zlib.decompress(decrypted_bytes, zlib.MAX_WBITS | 32) except: try: return zlib.decompress(decrypted_bytes, -zlib.MAX_WBITS) except: return None def decode_to_string(self, decompressed_bytes): return decompressed_bytes.decode('utf-8', errors='ignore') def homeContent(self, filter): result = {"class": []} res = self.get_main_page() Toubu = self.extract_toubu(res) Zhongbu = self.extract_zhongbu(res) decrypted = self.decrypt_data(Toubu, Zhongbu) res1 = self.extract_movie_channel(decrypted) soups = self.parse_html(res1) self.process_soups(soups, result) return result def get_main_page(self): detail = requests.get(url=xurl + "/main.html", headers=headerx) detail.encoding = "utf-8" return detail.text def extract_toubu(self, res): return self.extract_middle_text(res, '头部加载中