py_czspp.py 9.2 KB

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