干饭.py 1.0 KB

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