py_gitcafe.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #coding=utf-8
  2. #!/usr/bin/python
  3. import sys
  4. sys.path.append('..')
  5. from base.spider import Spider
  6. import requests
  7. import json
  8. class Spider(Spider):
  9. def getDependence(self):
  10. return ['py_ali']
  11. def getName(self):
  12. return "py_gitcafe"
  13. def init(self,extend):
  14. self.ali = extend[0]
  15. print("============py_gitcafe============")
  16. pass
  17. def isVideoFormat(self,url):
  18. pass
  19. def manualVideoCheck(self):
  20. pass
  21. def homeContent(self,filter):
  22. result = {}
  23. cateManual = {
  24. "华语电视" :"hyds",
  25. "日韩电视" :"rhds",
  26. "欧美电视" :"omds",
  27. "其他电视" :"qtds",
  28. "华语电影" :"hydy",
  29. "日韩电影" :"rhdy",
  30. "欧美电影" :"omdy",
  31. "其他电影" :"qtdy",
  32. "华语动漫" :"hydm",
  33. "日韩动漫" :"rhdm",
  34. "欧美动漫" :"omdm",
  35. "纪录片" :"jlp",
  36. "综艺片" :"zyp",
  37. "教育培训" :"jypx",
  38. "其他视频" :"qtsp",
  39. "华语音乐" :"hyyy",
  40. "日韩音乐" :"rhyy",
  41. "欧美音乐" :"omyy",
  42. "其他音乐" :"qtyy"
  43. }
  44. classes = []
  45. for k in cateManual:
  46. classes.append({
  47. 'type_name':k,
  48. 'type_id':cateManual[k]
  49. })
  50. result['class'] = classes
  51. if filter:
  52. result['filter'] = self.config['filter']
  53. return result
  54. def homeVideoContent(self):
  55. result = {}
  56. if len(self.homeData.keys()) == 0:
  57. url = self.baseUrl+'/alipaper/home.json'
  58. self.homeData = self.fetch(url,headers=self.header).json()
  59. cateList = self.homeData['data']
  60. videos = []
  61. for cate in cateList:
  62. if cate['info']['code'] in self.category:
  63. vodList = cate['data']
  64. for vod in vodList:
  65. videos.append({
  66. "vod_id":"https://www.aliyundrive.com/s/" + vod['key'],
  67. "vod_name":vod['title'],
  68. "vod_pic":'https://txc.gtimg.com/data/375895/2022/0214/d6b96cc3799b6417d30e4715d2973f64.png',
  69. "vod_remarks":''
  70. })
  71. result['list']=videos
  72. return result
  73. def categoryContent(self,tid,pg,filter,extend):
  74. result = {}
  75. url = self.baseUrl+'/tool/alipaper/'
  76. form = {
  77. "action": "viewcat",
  78. "cat": tid,
  79. "num":pg
  80. }
  81. rsp = requests.post(url,headers=self.header,data=form)
  82. vodList = json.loads(self.cleanText(rsp.text))
  83. videos = []
  84. for vod in vodList:
  85. videos.append({
  86. "vod_id": 'https://www.aliyundrive.com/s/'+vod["key"],
  87. "vod_name": vod["title"],
  88. "vod_pic": "https://txc.gtimg.com/data/375895/2022/0214/d6b96cc3799b6417d30e4715d2973f64.png",
  89. "vod_remarks": vod['cat']
  90. })
  91. result['list'] = videos
  92. result['page'] = pg
  93. result['pagecount'] = 9999
  94. result['limit'] = 90
  95. result['total'] = 999999
  96. return result
  97. category = ['hydm','hyds','hydy','omdm','omds','omdy','rhdm','rhds','rhdy','qtds','qtdy','qtsp','jlp','zyp']
  98. def detailContent(self,array):
  99. return self.ali.detailContent(array)
  100. def searchContent(self,key,quick):
  101. result = {}
  102. url = self.baseUrl+'/tool/alipaper/'
  103. form = {
  104. "action": "search",
  105. "keyword": key
  106. }
  107. vodList = requests.post(url,headers=self.header,data=form).json()
  108. videos = []
  109. for vod in vodList:
  110. videos.append({
  111. "vod_id": 'https://www.aliyundrive.com/s/'+vod["key"],
  112. "vod_name": vod["title"],
  113. "vod_pic": "https://txc.gtimg.com/data/375895/2022/0214/d6b96cc3799b6417d30e4715d2973f64.png",
  114. "vod_remarks": vod['cat']
  115. })
  116. result = {
  117. 'list':videos
  118. }
  119. return result
  120. def playerContent(self,flag,id,vipFlags):
  121. return self.ali.playerContent(flag,id,vipFlags)
  122. homeData = {}
  123. baseUrl = 'https://gitcafe.net'
  124. config = {
  125. "player": {},
  126. "filter": {}
  127. }
  128. header = {
  129. "User-Agent": "Mozilla/5.0 (Linux; Android 12; V2049A Build/SP1A.210812.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36",
  130. "Referer": "https://u.gitcafe.net/"
  131. }
  132. def localProxy(self,param):
  133. return [200, "video/MP2T", action, ""]