当前位置:   article > 正文

真实、迅雷、QQ旋风下载地址转换_ed2k获取真实地址

ed2k获取真实地址
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # 真实、迅雷、QQ旋风下载地址之间的转换
  4. import base64
  5. import urllib
  6. import re
  7. __Author__ = "kingking"
  8. '''
  9. 原理:
  10. 迅雷下载地址:"thunder://"+Base64编码("AA"+"真实地址"+"ZZ")
  11. QQ旋风下载地址:"qqdl://"+Base64编码("真实地址")
  12. '''
  13. #############
  14. # 常量定义区 #
  15. #############
  16. THUNDER_HEADER = "thunder://"
  17. THUNDER_PREFIX = "AA"
  18. THUNDER_SUFFIX = "ZZ"
  19. QQ_HEADER = "qqdl://"
  20. ERROR = "传入的URL有误,请检查!"
  21. # 判断url是否有效
  22. def checkUrl(func):
  23. def wrapper(url):
  24. if re.match(r"(http|https|ftp|ed2k|thunder|qqdl)://", url):
  25. return func(url)
  26. else:
  27. return ERROR
  28. return wrapper
  29. def real2QQ(url):
  30. url = base64.b64encode(url.encode("utf-8"))
  31. url = QQ_HEADER + url.decode("utf-8")
  32. return url
  33. def qq2Real(url):
  34. url = url[len(QQ_HEADER):]
  35. url = base64.b64decode(url.encode("utf-8"))
  36. url = url.decode("utf-8")
  37. return url
  38. def real2Thunder(url):
  39. url = THUNDER_PREFIX + url + THUNDER_SUFFIX
  40. url = base64.b64encode(url.encode("utf-8"))
  41. url = THUNDER_HEADER + url.decode("utf-8")
  42. return url
  43. def thunder2Real(url):
  44. url = url[len(THUNDER_HEADER):]
  45. url = base64.b64decode(url.encode("utf-8"))
  46. url = url.decode("utf-8")
  47. url = url[len(THUNDER_PREFIX):-len(THUNDER_SUFFIX)]
  48. return url
  49. def qq2Thunder(url):
  50. return real2Thunder(qq2Real(url))
  51. def thunder2QQ(url):
  52. return real2QQ(thunder2Real(url))
  53. if __name__ == "__main__":
  54. # 测试用,SuperGirl第一季第2集下载地址:
  55. url_1 = r'ed2k://|file|Supergirl.S01E02.720p.HDTV.X264-DIMENSION.mkv|947617048|5D430BBD720C13598D867C3424B50B8D|h=2AG3ZXRLCWNGC4K5WFNC4QOMVDSXWBBM|/'
  56. url_2 = r'd2k://|file|Supergirl.S01E02.720p.HDTV.X264-DIMENSION.mkv|947617048|5D430BBD720C13598D867C3424B50B8D|h=2AG3ZXRLCWNGC4K5WFNC4QOMVDSXWBBM|/'
  57. url = 'thunder://QUFmdHA6Ly95Z2R5ODp5Z2R5OEB5ZzQ1LmR5ZHl0dC5uZXQ6NjAwNC9bJUU5JTk4JUIzJUU1JTg1JTg5JUU3JTk0JUI1JUU1JUJEJUIxd3d3LnlnZHk4LmNvbV0uJUU2JTgyJTlGJUU3JUE5JUJBJUU0JUJDJUEwLkhELjcyMHAuJUU1JTlCJUJEJUU4JUFGJUFEJUU0JUI4JUFEJUU1JUFEJTk3Lm1rdlpa'
  58. print(real2QQ(url_1))
  59. print(thunder2QQ(real2Thunder(url_1)))
  60. print(real2QQ(url_2))
  61. print(thunder2Real(url))

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/154561
推荐阅读
相关标签
  

闽ICP备14008679号