py_czspp.py 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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.replace("类型:", "")
  107. if content.startswith('地区'):
  108. vod['vod_area'] = content.replace("地区:", "")
  109. if content.startswith('豆瓣'):
  110. vod['vod_remarks'] = content
  111. if content.startswith('主演'):
  112. vod['vod_actor'] = content.replace("主演:", "")
  113. if content.startswith('导演'):
  114. vod['vod_director'] = content.replace("导演:", "")
  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. result = {}
  145. url = 'https://czspp.com/xssearch?q={0}'.format(key)
  146. # getHeader()
  147. rsp = self.fetch(url)
  148. root = self.html(rsp.text)
  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. res = vod.xpath('./div[@class="jidi"]/span/text()')
  157. if len(res) == 0:
  158. remark = '全1集'
  159. else:
  160. remark = vod.xpath('./div[@class="jidi"]/span/text()')[0]
  161. videos.append({
  162. "vod_id": tid,
  163. "vod_name": name,
  164. "vod_pic": pic,
  165. "vod_remarks": remark
  166. })
  167. result = {
  168. 'list': videos
  169. }
  170. return result
  171. config = {
  172. "player": {},
  173. "filter": {}
  174. }
  175. header = {
  176. "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"
  177. }
  178. def parseCBC(self, enc, key, iv):
  179. keyBytes = key.encode("utf-8")
  180. ivBytes = iv.encode("utf-8")
  181. cipher = AES.new(keyBytes, AES.MODE_CBC, ivBytes)
  182. msg = cipher.decrypt(enc)
  183. paddingLen = msg[len(msg) - 1]
  184. return msg[0:-paddingLen]
  185. def playerContent(self, flag, id, vipFlags):
  186. url = 'https://czspp.com/v_play/{0}.html'.format(id)
  187. pat = '\\"([^\\"]+)\\";var [\\d\\w]+=function dncry.*md5.enc.Utf8.parse\\(\\"([\\d\\w]+)\\".*md5.enc.Utf8.parse\\(([\\d]+)\\)'
  188. rsp = self.fetch(url)
  189. html = rsp.text
  190. content = self.regStr(html, pat)
  191. if content == '':
  192. return {}
  193. key = self.regStr(html, pat, 2)
  194. iv = self.regStr(html, pat, 3)
  195. decontent = self.parseCBC(base64.b64decode(content), key, iv).decode()
  196. urlPat = 'video: \\{url: \\\"([^\\\"]+)\\\"'
  197. vttPat = 'subtitle: \\{url:\\\"([^\\\"]+\\.vtt)\\\"'
  198. str3 = self.regStr(decontent, urlPat)
  199. str4 = self.regStr(decontent, vttPat)
  200. self.loadVtt(str3)
  201. result = {
  202. 'parse': '0',
  203. 'playUrl': '',
  204. 'url': str3,
  205. 'header': ''
  206. }
  207. if len(str4) > 0:
  208. result['subf'] = '/vtt/utf-8'
  209. # result['subt'] = Proxy.localProxyUrl() + "?do=czspp&url=" + URLEncoder.encode(str4)
  210. result['subt'] = ''
  211. return result
  212. def loadVtt(self, url):
  213. print(url)
  214. def isVideoFormat(self, url):
  215. pass
  216. def manualVideoCheck(self):
  217. pass
  218. def localProxy(self, param):
  219. action = {}
  220. return [200, "video/MP2T", action, ""]