kugou.py 833 B

12345678910111213141516171819202122232425262728
  1. import requests
  2. class KuGou:
  3. def __init__(self, url):
  4. self.url = url
  5. self.headers = {
  6. "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36¬"
  7. }
  8. self.base = url.split("#")[-1].split("&")
  9. self.hash = self.base[0].split("=")[-1]
  10. self.album_id = self.base[1].split("=")[-1]
  11. def start(self):
  12. params = {
  13. "r": "play/getdata",
  14. "hash": self.hash,
  15. "album_id": self.album_id,
  16. "mid": "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456"
  17. }
  18. res = requests.get("https://wwwapi.kugou.com/yy/index.php?", params=params, headers=self.headers)
  19. print(res.json())
  20. return res.json()
  21. if __name__ == '__main__':
  22. KuGou().start()