py_jubaibai.py 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. import base64
  8. from Crypto.Cipher import AES
  9. class Spider(Spider): # 元类 默认的元类 type
  10. def getName(self):
  11. return "剧白白"
  12. def init(self,extend=""):
  13. print("============{0}============".format(extend))
  14. pass
  15. def homeContent(self,filter):
  16. result = {}
  17. cateManual = {
  18. "电影": "dianying",
  19. "电视剧": "dianshiju",
  20. "综艺": "zongyi",
  21. "动漫": "dongman",
  22. "纪录片": "jilupian",
  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. rsp = self.fetch("https://www.jubaibai.cc/")
  34. root = self.html(rsp.text)
  35. aList = root.xpath("(//ul[@class='stui-vodlist clearfix'])[1]")
  36. videos = []
  37. for a in aList:
  38. name = a.xpath('(//a[@title=''])[1]')[0]
  39. pic = a.xpath('./@data-original')[0]
  40. mark = a.xpath(".//span[contains(@class,'pic-text text-right')]/b/text()")[0]
  41. sid = a.xpath("./@href")[0]
  42. sid = self.regStr(sid,"/vod/(\\w+).html")
  43. videos.append({
  44. "vod_id":sid,
  45. "vod_name":name,
  46. "vod_pic":pic,
  47. "vod_remarks":mark
  48. })
  49. result = {
  50. 'list':videos
  51. }
  52. return result
  53. def categoryContent(self,tid,pg,filter,extend):
  54. result = {}
  55. urlParams[0] = tid
  56. url = 'https://www.jubaibai.cc/type/{0}.html'.format(params)
  57. rsp = self.fetch(url)
  58. root = self.html(rsp.text)
  59. aList = root.xpath("//body")
  60. videos = []
  61. for a in aList:
  62. name = a.xpath('./a/img/@alt')[0]
  63. pic = a.xpath('./a/img/@data-original')[0]
  64. mark = a.xpath("./div[@class='hdinfo']/span/text()")[0]
  65. sid = a.xpath("./a/@href")[0]
  66. sid = self.regStr(sid,"/movie/(\\S+).html")
  67. videos.append({
  68. "vod_id":sid,
  69. "vod_name":name,
  70. "vod_pic":pic,
  71. "vod_remarks":mark
  72. })
  73. result['list'] = videos
  74. result['page'] = pg
  75. result['pagecount'] = 9999
  76. result['limit'] = 90
  77. result['total'] = 999999
  78. return result
  79. def detailContent(self,array):
  80. tid = array[0]
  81. url = 'https://czspp.com/movie/{0}.html'.format(tid)
  82. rsp = self.fetch(url)
  83. root = self.html(rsp.text)
  84. node = root.xpath("//div[@class='dyxingq']")[0]
  85. pic = node.xpath(".//div[@class='dyimg fl']/img/@src")[0]
  86. title = node.xpath('.//h1/text()')[0]
  87. detail = root.xpath(".//div[@class='yp_context']//p/text()")[0]
  88. vod = {
  89. "vod_id":tid,
  90. "vod_name":title,
  91. "vod_pic":pic,
  92. "type_name":"",
  93. "vod_year":"",
  94. "vod_area":"",
  95. "vod_remarks":"",
  96. "vod_actor":"",
  97. "vod_director":"",
  98. "vod_content":detail
  99. }
  100. infoArray = node.xpath(".//ul[@class='moviedteail_list']/li")
  101. for info in infoArray:
  102. content = info.xpath('string(.)')
  103. if content.startswith('类型'):
  104. vod['type_name'] = content
  105. if content.startswith('年份'):
  106. vod['vod_year'] = content
  107. if content.startswith('地区'):
  108. vod['vod_area'] = content
  109. if content.startswith('豆瓣'):
  110. vod['vod_remarks'] = content
  111. if content.startswith('主演'):
  112. vod['vod_actor'] = content
  113. if content.startswith('导演'):
  114. vod['vod_director'] = content
  115. # if content.startswith('剧情'):
  116. # vod['vod_content'] = content
  117. vod_play_from = '$$$'
  118. playFrom = ['厂长']
  119. vod_play_from = vod_play_from.join(playFrom)
  120. vod_play_url = '$$$'
  121. playList = []
  122. vodList = root.xpath("//div[@class='paly_list_btn']")
  123. for vl in vodList:
  124. vodItems = []
  125. aList = vl.xpath('./a')
  126. for tA in aList:
  127. href = tA.xpath('./@href')[0]
  128. name = tA.xpath('./text()')[0]
  129. tId = self.regStr(href,'/v_play/(\\S+).html')
  130. vodItems.append(name + "$" + tId)
  131. joinStr = '#'
  132. joinStr = joinStr.join(vodItems)
  133. playList.append(joinStr)
  134. vod_play_url = vod_play_url.join(playList)
  135. vod['vod_play_from'] = vod_play_from
  136. vod['vod_play_url'] = vod_play_url
  137. result = {
  138. 'list':[
  139. vod
  140. ]
  141. }
  142. return result
  143. def searchContent(self,key,quick):
  144. url = 'https://czspp.com/xssearch?q={0}'.format(key)
  145. # getHeader()
  146. rsp = self.fetch(url)
  147. root = self.html(rsp.text)
  148. result = {}
  149. vodList = root.xpath("//div[contains(@class,'mi_ne_kd')]/ul/li/a")
  150. videos = []
  151. for vod in vodList:
  152. name = vod.xpath('./img/@alt')[0]
  153. pic = vod.xpath('./img/@data-original')[0]
  154. href = vod.xpath('./@href')[0]
  155. tid = self.regStr(href,'movie/(\\S+).html')
  156. remark = vod.xpath('./div[@class="jidi"]/span/text()')[0]
  157. videos.append({
  158. "vod_id": tid,
  159. "vod_name": name,
  160. "vod_pic": pic,
  161. "vod_remarks": remark
  162. })
  163. result = {
  164. 'list':videos
  165. }
  166. return result
  167. config = {
  168. "player": { },
  169. "filter": { }
  170. }
  171. header = {
  172. "User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"
  173. }
  174. def parseCBC(self, enc, key, iv):
  175. keyBytes = key.encode("utf-8")
  176. ivBytes = iv.encode("utf-8")
  177. cipher = AES.new(keyBytes, AES.MODE_CBC, ivBytes)
  178. msg = cipher.decrypt(enc)
  179. paddingLen = msg[len(msg)-1]
  180. return msg[0:-paddingLen]
  181. def playerContent(self,flag,id,vipFlags):
  182. url = 'https://czspp.com/v_play/{0}.html'.format(id)
  183. pat = '\\"([^\\"]+)\\";var [\\d\\w]+=function dncry.*md5.enc.Utf8.parse\\(\\"([\\d\\w]+)\\".*md5.enc.Utf8.parse\\(([\\d]+)\\)'
  184. rsp = self.fetch(url)
  185. html = rsp.text
  186. content = self.regStr(html,pat)
  187. key = self.regStr(html,pat,2)
  188. iv = self.regStr(html,pat,3)
  189. decontent = self.parseCBC(base64.b64decode(content),key,iv).decode()
  190. urlPat = 'video: \\{url: \\\"([^\\\"]+)\\\"'
  191. vttPat = 'subtitle: \\{url:\\\"([^\\\"]+\\.vtt)\\\"'
  192. str3 = self.regStr(decontent,urlPat)
  193. str4 = self.regStr(decontent,vttPat)
  194. self.loadVtt(str3)
  195. result = {
  196. 'parse':'0',
  197. 'playUrl':'',
  198. 'url':str3,
  199. 'header':''
  200. }
  201. if len(str4) > 0:
  202. result['subf'] = '/vtt/utf-8'
  203. # result['subt'] = Proxy.localProxyUrl() + "?do=czspp&url=" + URLEncoder.encode(str4)
  204. result['subt'] = ''
  205. return result
  206. def loadVtt(self,url):
  207. print(url)
  208. def isVideoFormat(self,url):
  209. pass
  210. def manualVideoCheck(self):
  211. pass
  212. def localProxy(self,param):
  213. action = {}
  214. return [200, "video/MP2T", action, ""]