py_czspp.py 8.3 KB

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