py_czspp.py 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. "豆瓣电影Top250": "dbtop250",
  19. "最新电影": "zuixindianying",
  20. "电视剧": "dsj",
  21. "国产剧": "gcj",
  22. "美剧": "meijutt",
  23. "韩剧": "hanjutv",
  24. "番剧": "fanju",
  25. "动漫": "dm"
  26. }
  27. classes = []
  28. for k in cateManual:
  29. classes.append({
  30. 'type_name':k,
  31. 'type_id':cateManual[k]
  32. })
  33. result['class'] = classes
  34. return result
  35. def homeVideoContent(self):
  36. rsp = self.fetch("https://czspp.com")
  37. root = self.html(rsp.text)
  38. aList = root.xpath("//div[@class='mi_btcon']//ul/li")
  39. videos = []
  40. for a in aList:
  41. name = a.xpath('./a/img/@alt')[0]
  42. pic = a.xpath('./a/img/@data-original')[0]
  43. mark = a.xpath("./div[@class='hdinfo']/span/text()")[0]
  44. sid = a.xpath("./a/@href")[0]
  45. sid = self.regStr(sid,"/movie/(\\S+).html")
  46. videos.append({
  47. "vod_id":sid,
  48. "vod_name":name,
  49. "vod_pic":pic,
  50. "vod_remarks":mark
  51. })
  52. result = {
  53. 'list':videos
  54. }
  55. return result
  56. def categoryContent(self,tid,pg,filter,extend):
  57. result = {}
  58. url = 'https://czspp.com/{0}/page/{1}'.format(tid,pg)
  59. rsp = self.fetch(url)
  60. root = self.html(rsp.text)
  61. aList = root.xpath("//div[contains(@class,'mi_cont')]//ul/li")
  62. videos = []
  63. for a in aList:
  64. name = a.xpath('./a/img/@alt')[0]
  65. pic = a.xpath('./a/img/@data-original')[0]
  66. mark = a.xpath("./div[@class='hdinfo']/span/text()")[0]
  67. sid = a.xpath("./a/@href")[0]
  68. sid = self.regStr(sid,"/movie/(\\S+).html")
  69. videos.append({
  70. "vod_id":sid,
  71. "vod_name":name,
  72. "vod_pic":pic,
  73. "vod_remarks":mark
  74. })
  75. result['list'] = videos
  76. result['page'] = pg
  77. result['pagecount'] = 9999
  78. result['limit'] = 90
  79. result['total'] = 999999
  80. return result
  81. def detailContent(self,array):
  82. tid = array[0]
  83. url = 'https://czspp.com/movie/{0}.html'.format(tid)
  84. rsp = self.fetch(url)
  85. root = self.html(rsp.text)
  86. node = root.xpath("//div[@class='dyxingq']")[0]
  87. pic = node.xpath(".//div[@class='dyimg fl']/img/@src")[0]
  88. title = node.xpath('.//h1/text()')[0]
  89. detail = root.xpath(".//div[@class='yp_context']//p/text()")[0]
  90. vod = {
  91. "vod_id":tid,
  92. "vod_name":title,
  93. "vod_pic":pic,
  94. "type_name":"",
  95. "vod_year":"",
  96. "vod_area":"",
  97. "vod_remarks":"",
  98. "vod_actor":"",
  99. "vod_director":"",
  100. "vod_content":detail
  101. }
  102. infoArray = node.xpath(".//ul[@class='moviedteail_list']/li")
  103. for info in infoArray:
  104. content = info.xpath('string(.)')
  105. if content.startswith('类型'):
  106. vod['type_name'] = content
  107. if content.startswith('年份'):
  108. vod['vod_year'] = content
  109. if content.startswith('地区'):
  110. vod['vod_area'] = content
  111. if content.startswith('豆瓣'):
  112. vod['vod_remarks'] = content
  113. if content.startswith('主演'):
  114. vod['vod_actor'] = content
  115. if content.startswith('导演'):
  116. vod['vod_director'] = content
  117. # if content.startswith('剧情'):
  118. # vod['vod_content'] = content
  119. vod_play_from = '$$$'
  120. playFrom = ['厂长']
  121. vod_play_from = vod_play_from.join(playFrom)
  122. vod_play_url = '$$$'
  123. playList = []
  124. vodList = root.xpath("//div[@class='paly_list_btn']")
  125. for vl in vodList:
  126. vodItems = []
  127. aList = vl.xpath('./a')
  128. for tA in aList:
  129. href = tA.xpath('./@href')[0]
  130. name = tA.xpath('./text()')[0]
  131. tId = self.regStr(href,'/v_play/(\\S+).html')
  132. vodItems.append(name + "$" + tId)
  133. joinStr = '#'
  134. joinStr = joinStr.join(vodItems)
  135. playList.append(joinStr)
  136. vod_play_url = vod_play_url.join(playList)
  137. vod['vod_play_from'] = vod_play_from
  138. vod['vod_play_url'] = vod_play_url
  139. result = {
  140. 'list':[
  141. vod
  142. ]
  143. }
  144. return result
  145. def searchContent(self,key,quick):
  146. url = 'https://czspp.com/xssearch?q={0}'.format(key)
  147. # getHeader()
  148. rsp = self.fetch(url)
  149. root = self.html(rsp.text)
  150. result = {}
  151. vodList = root.xpath("//div[contains(@class,'mi_ne_kd')]/ul/li/a")
  152. videos = []
  153. for vod in vodList:
  154. name = vod.xpath('./img/@alt')[0]
  155. pic = vod.xpath('./img/@data-original')[0]
  156. href = vod.xpath('./@href')[0]
  157. tid = self.regStr(href,'movie/(\\S+).html')
  158. remark = ""
  159. videos.append({
  160. "vod_id": tid,
  161. "vod_name": name,
  162. "vod_pic": pic,
  163. "vod_remarks": remark
  164. })
  165. result = {
  166. 'list':videos
  167. }
  168. return result
  169. config = {
  170. "player": { },
  171. "filter": { }
  172. }
  173. header = {
  174. "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"
  175. }
  176. def parseCBC(self, enc, key, iv):
  177. keyBytes = key.encode("utf-8")
  178. ivBytes = iv.encode("utf-8")
  179. cipher = AES.new(keyBytes, AES.MODE_CBC, ivBytes)
  180. msg = cipher.decrypt(enc)
  181. paddingLen = msg[len(msg)-1]
  182. return msg[0:-paddingLen]
  183. def playerContent(self,flag,id,vipFlags):
  184. url = 'https://czspp.com/v_play/{0}.html'.format(id)
  185. pat = '\\"([^\\"]+)\\";var [\\d\\w]+=function dncry.*md5.enc.Utf8.parse\\(\\"([\\d\\w]+)\\".*md5.enc.Utf8.parse\\(([\\d]+)\\)'
  186. rsp = self.fetch(url)
  187. html = rsp.text
  188. content = self.regStr(html,pat)
  189. key = self.regStr(html,pat,2)
  190. iv = self.regStr(html,pat,3)
  191. decontent = self.parseCBC(base64.b64decode(content),key,iv).decode()
  192. urlPat = 'video: \\{url: \\\"([^\\\"]+)\\\"'
  193. vttPat = 'subtitle: \\{url:\\\"([^\\\"]+\\.vtt)\\\"'
  194. str3 = self.regStr(decontent,urlPat)
  195. str4 = self.regStr(decontent,vttPat)
  196. self.loadVtt(str3)
  197. result = {
  198. 'parse':'0',
  199. 'playUrl':'',
  200. 'url':str3,
  201. 'header':''
  202. }
  203. if len(str4) > 0:
  204. result['subf'] = '/vtt/utf-8'
  205. # result['subt'] = Proxy.localProxyUrl() + "?do=czspp&url=" + URLEncoder.encode(str4)
  206. result['subt'] = ''
  207. return result
  208. def loadVtt(self,url):
  209. print(url)
  210. def isVideoFormat(self,url):
  211. pass
  212. def manualVideoCheck(self):
  213. pass
  214. def localProxy(self,param):
  215. action = {}
  216. return [200, "video/MP2T", action, ""]