py_yydshd.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #coding=utf-8
  2. #!/usr/bin/python
  3. import sys
  4. sys.path.append('..')
  5. from base.spider import Spider
  6. import json
  7. class Spider(Spider): # 元类 默认的元类 type
  8. def getDependence(self):
  9. return ['py_ali']
  10. def getName(self):
  11. return "YYDS"
  12. def init(self,extend=""):
  13. self.ali = extend[0]
  14. print("============YYDS============".format(extend))
  15. pass
  16. def homeContent(self,filter):
  17. result = {}
  18. cateManual = {
  19. "热门":"0",
  20. "电影":"3",
  21. "剧集":"12",
  22. "综艺":"10"
  23. }
  24. classes = []
  25. for k in cateManual:
  26. classes.append({
  27. 'type_name':k,
  28. 'type_id':cateManual[k]
  29. })
  30. result['class'] = classes
  31. return result
  32. def homeVideoContent(self):
  33. result = {
  34. 'list':[]
  35. }
  36. return result
  37. def categoryContent(self,tid,pg,filter,extend):
  38. result = {}
  39. form = {
  40. 'limit': 24,
  41. 'skip': int(pg) * 24 - 24,
  42. 'keyword': '',
  43. 'category_id': tid,
  44. }
  45. rsp = self.post("https://cmn.yydshd.com/api/posts",data=form)
  46. jo = json.loads(rsp.text)
  47. vodList = jo['data']['list']
  48. videos = []
  49. for vod in vodList:
  50. name = vod['title']
  51. pic = vod['cover']
  52. sid = vod['id']
  53. suffix = ''
  54. if vod['is_vip'] == 1:
  55. suffix = ' 会员'
  56. mark = str(vod['score']) + suffix
  57. videos.append({
  58. "vod_id":sid,
  59. "vod_name":name,
  60. "vod_pic":pic,
  61. "vod_remarks":mark
  62. })
  63. result['list'] = videos
  64. result['page'] = pg
  65. result['pagecount'] = 9999
  66. result['limit'] = 90
  67. result['total'] = 999999
  68. return result
  69. token = ''
  70. def getHeader(self,force=False):
  71. if len(self.token) == 0 or force:
  72. form = {
  73. 'email': '',
  74. 'password': ''
  75. }
  76. if len(form['password']) > 0:
  77. rsp = self.post("https://cmn.yydshd.com/api/login",data=form)
  78. jo = json.loads(rsp.text)
  79. self.token = jo['data']['token']
  80. return {
  81. 'token':self.token,
  82. 'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.70'
  83. }
  84. def detailContent(self,array):
  85. tid = array[0]
  86. result = {}
  87. form = {
  88. 'id': tid
  89. }
  90. rsp = self.post("https://cmn.yydshd.com/api/post-info",data=form,headers=self.getHeader())
  91. jo = json.loads(rsp.text)
  92. if(jo['status_code'] == 403):
  93. retry = self.post("https://cmn.yydshd.com/api/post-info",data=form,headers=self.getHeader(True))
  94. jo = json.loads(retry.text)
  95. if jo['status_code'] == 403:
  96. return {'list':[]}
  97. vodInfo = jo['data']
  98. videos = []
  99. name = vodInfo['title']
  100. pic = vodInfo['cover']
  101. mark = vodInfo['score']
  102. vod = {
  103. "vod_id":tid,
  104. "vod_name":name,
  105. "vod_pic":pic,
  106. "type_name":"",
  107. "vod_year":vodInfo['year'],
  108. "vod_area":vodInfo['region'],
  109. "vod_remarks":mark,
  110. "vod_actor":vodInfo['actors'],
  111. "vod_director":vodInfo['director'],
  112. "vod_content":vodInfo['desc']
  113. }
  114. playList = vodInfo['links']
  115. tmpLink = ''
  116. for play in playList:
  117. if play['name'] == '阿里网盘':
  118. if len(play['item']) > 0:
  119. tmpLink = play['item'][0]['link']
  120. break
  121. if len(tmpLink) > 0:
  122. vod['vod_play_from'] = 'AliYun$$$AliYun原画'
  123. newArray = [tmpLink]
  124. rs = self.ali.detailContent(newArray)
  125. vod['vod_play_url'] = rs['list'][0]['vod_play_url']
  126. result = {
  127. 'list':[
  128. vod
  129. ]
  130. }
  131. return result
  132. def searchContent(self,key,quick):
  133. result = {}
  134. form = {
  135. 'limit': 24,
  136. 'skip': 0,
  137. 'keyword': key,
  138. 'category_id': -1,
  139. }
  140. rsp = self.post("https://cmn.yydshd.com/api/posts",data=form)
  141. jo = json.loads(rsp.text)
  142. vodList = jo['data']['list']
  143. videos = []
  144. for vod in vodList:
  145. name = vod['title']
  146. pic = vod['cover']
  147. sid = vod['id']
  148. suffix = ''
  149. if vod['is_vip'] == 1:
  150. suffix = ' 会员'
  151. mark = str(vod['score']) + suffix
  152. videos.append({
  153. "vod_id":sid,
  154. "vod_name":name,
  155. "vod_pic":pic,
  156. "vod_remarks":mark
  157. })
  158. result = {
  159. 'list':videos
  160. }
  161. return result
  162. config = {
  163. "player": {},
  164. "filter": {}
  165. }
  166. header = {
  167. "User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
  168. }
  169. def playerContent(self,flag,id,vipFlags):
  170. return self.ali.playerContent(flag,id,vipFlags)
  171. def isVideoFormat(self,url):
  172. pass
  173. def manualVideoCheck(self):
  174. pass
  175. def localProxy(self,param):
  176. return [200, "video/MP2T", action, ""]