From c00b2d63377ba32334a1c56ced7ea9cb8a11c0a2 Mon Sep 17 00:00:00 2001 From: wbt5 Date: Sun, 21 Nov 2021 01:45:52 +0800 Subject: [PATCH] =?UTF-8?q?:coffin:=20Remove=20=E7=81=AB=E7=8C=AB=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=20-=E7=81=AB=E7=8C=AB=E7=9B=B4=E6=92=AD=E5=AE=98?= =?UTF-8?q?=E7=BD=91=E4=B8=80=E7=9B=B4=E6=89=93=E4=B8=8D=E5=BC=80=EF=BC=8C?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E5=B7=B2=E7=BB=8F=E5=80=92=E9=97=AD=E4=BA=86?= =?UTF-8?q?=20-=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- huomao.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/huomao.py b/huomao.py index 8577147..b49c20a 100644 --- a/huomao.py +++ b/huomao.py @@ -12,34 +12,33 @@ import re class HuoMao: def __init__(self, rid): + """ + 火猫直播已经倒闭了 + Args: + rid: 房间号 + """ self.rid = rid - @staticmethod - def get_time(): - tt = str(int((time.time() * 1000))) - return tt - @staticmethod def get_videoids(rid): - room_url = 'https://www.huomao.com/mobile/mob_live/' + str(rid) + room_url = f'https://www.huomao.com/mobile/mob_live/{rid}' response = requests.get(url=room_url).text try: videoids = re.findall(r'var stream = "([\w\W]+?)";', response)[0] - except: + except IndexError: videoids = 0 return videoids @staticmethod - def get_token(videoids, time): - token = hashlib.md5((str(videoids) + 'huomaoh5room' + str(time) + - '6FE26D855E1AEAE090E243EB1AF73685').encode('utf-8')).hexdigest() + def get_token(videoids): + tt = str(int((time.time() * 1000))) + token = hashlib.md5(f'{videoids}huomaoh5room{tt}6FE26D855E1AEAE090E243EB1AF73685'.encode('utf-8')).hexdigest() return token def get_real_url(self): videoids = self.get_videoids(self.rid) if videoids: - time = self.get_time() - token = self.get_token(videoids, time) + token = self.get_token(videoids) room_url = 'https://www.huomao.com/swf/live_data' post_data = { 'cdns': 1,