干饭.py 1.0 KB
Newer Older
H
hjdhnx 已提交
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File  : 干饭.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date  : 2022/8/28

import requests
import re
import json
from urllib.parse import urljoin,quote,unquote
import base64

13 14 15
def lazyParse(input,d):
    cacheUrl = d.getParse(input)
    print(f'干饭免嗅:cacheUrl:{cacheUrl}')
H
hjdhnx 已提交
16 17
    if cacheUrl:
        return cacheUrl
18 19
    r = requests.get(input, headers=d.headers,timeout=d.timeout)
    r.encoding = d.encoding
H
hjdhnx 已提交
20 21
    html = r.text
    # print(html)
22 23
    # js = d.jsp.pdfh(html,'.stui-player__video script:eq(0)&&Html')
    # print(js)
H
hjdhnx 已提交
24 25 26 27 28 29
    try:
        ret = re.search('var player_(.*?)=(.*?)<', html, re.M | re.I).groups()[1]
        ret = json.loads(ret)
        url = ret.get('url','')
        if len(url) > 10:
            real_url = 'https://player.buyaotou.xyz/?url='+url
30
            d.saveParse(input,real_url)
H
hjdhnx 已提交
31 32 33 34 35 36
            return real_url
        else:
            return input
    except Exception as e:
        print(f'错误:{e}')
    return input