通用免嗅.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # File : 通用免嗅.py
  4. # Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
  5. # Date : 2022/8/28
  6. import requests
  7. import re
  8. import json
  9. from urllib.parse import urljoin,quote,unquote
  10. import base64
  11. def lazyParse(input,d):
  12. print('通用免嗅:',input)
  13. r = requests.get(input, headers=d.headers,timeout=d.timeout)
  14. r.encoding = d.encoding
  15. html = r.text
  16. # print(html)
  17. # js = jsp.pdfh(html,'.stui-player__video script:eq(0)&&Html')
  18. # print(js)
  19. try:
  20. ret = re.search('var player_(.*?)=(.*?)<', html, re.M | re.I).groups()[1]
  21. ret = json.loads(ret)
  22. url = ret.get('url','')
  23. if len(url) > 10:
  24. if url.find('.m3u8') > -1 or url.find('.mp4') > -1:
  25. return url
  26. elif url.find('http') < 0:
  27. try:
  28. l = unquote(base64.b64decode(url).decode("utf-8"))
  29. print(l)
  30. return l
  31. except Exception as e:
  32. print(f'非url和base64编码:{e}')
  33. return input
  34. else:
  35. return input
  36. except Exception as e:
  37. print(f'错误:{e}')
  38. return input