py_czspp.py 9.3 KB

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