酷云筛选.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # File : 酷云筛选.py
  4. # Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
  5. # Date : 2022/9/24
  6. import requests
  7. headers = {
  8. "User-Agent": "Dalvik/2.1.0"
  9. }
  10. def getClass():
  11. url = 'http://api.kunyu77.com/api.php/provide/filter'
  12. r = requests.get(url, headers=headers)
  13. html = r.json()
  14. class_names = []
  15. class_urls = []
  16. data = html['data']
  17. for i in data:
  18. class_names.append(data[i][0]['cat'])
  19. class_urls.append(i)
  20. print('&'.join(class_names))
  21. print('&'.join(class_urls))
  22. ft_dict = {}
  23. def getCate():
  24. # url = 'http://api.kunyu77.com/api.php/provide/searchFilter?devid=EA83E58357FC020ABA526E9620AD7E89&package=com.sevenVideo.app.android&pcode=010110004&year=&category=&area=&pagenum=1&type_id=0&pagesize=24'
  25. url = 'http://api.kunyu77.com/api.php/provide/searchFilter?year=&category=&area=&pagenum=1&type_id=1&pagesize=24'
  26. r = requests.get(url,headers=headers)
  27. html = r.json()
  28. print(html)
  29. filters = html['data']['conditions']
  30. print(filters)
  31. cates = [0,1,2,3,4] # 全部&电影&电视剧&综艺&动漫
  32. for cate in cates:
  33. getOne(cate,filters)
  34. print(ft_dict)
  35. def getOne(cate_id,filters):
  36. ft_dict[cate_id] = []
  37. print(filters)
  38. if 'cat' in filters.keys():
  39. del filters['cat']
  40. for key in (filters):
  41. value = [{"n":"全部","v":""}]
  42. name_dict = {
  43. 'y':'年代',
  44. 'a':'地区',
  45. 'scat':'类型',
  46. }
  47. # value = []
  48. vl = [{"n": i['name'], "v": i.get('value', '')} for i in filters[key]]
  49. value.extend(vl)
  50. ft_dict[cate_id].append({
  51. 'key': key,
  52. 'name': name_dict[key],
  53. 'value': value
  54. })
  55. return ft_dict
  56. if __name__ == '__main__':
  57. getCate()