白嫖.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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 urllib.parse import unquote
  9. import re
  10. from Crypto.Cipher import ARC4
  11. class Spider(Spider): # 元类 默认的元类 type
  12. def getName(self):
  13. return "白嫖影视"
  14. def init(self,extend=""):
  15. print("============{0}============".format(extend))
  16. pass
  17. def isVideoFormat(self,url):
  18. pass
  19. def rc4_decrypt(self,data, key1):
  20. data = base64.b64decode(data)
  21. key = bytes(key1, encoding='utf-8')
  22. enc = ARC4.new(key)
  23. res = enc.decrypt(data)
  24. res = str(res,'utf-8')
  25. return res
  26. def manualVideoCheck(self):
  27. pass
  28. def homeContent(self,filter):
  29. result = {}
  30. cateManual = {
  31. "电影":"1",
  32. "电视剧":"2",
  33. "动漫":"3",
  34. "爽文短剧":"4",
  35. "综艺":"5"
  36. }
  37. classes = []
  38. for k in cateManual:
  39. classes.append({
  40. 'type_name':k,
  41. 'type_id':cateManual[k]
  42. })
  43. result['class'] = classes
  44. if(filter):
  45. result['filters'] = self.config['filter']
  46. return result
  47. def homeVideoContent(self):
  48. rsp = self.fetch("https://www.baipiaoys.com:9092")
  49. root = self.html(rsp.text)
  50. aList = root.xpath("//div[@class='stui-vodlist__box']/a")
  51. videos = []
  52. for a in aList:
  53. name = a.xpath('./@title')[0]
  54. pic = a.xpath('./@data-original')[0]
  55. remark = a.xpath("./span[@class='pic-text text-right']/text()")[0]
  56. sid = a.xpath("./@href")[0]
  57. sid = self.regStr(sid,"/detail/(\\S+).html")
  58. videos.append({
  59. "vod_id":sid,
  60. "vod_name":name,
  61. "vod_pic":pic,
  62. "vod_remarks":remark
  63. })
  64. result = {
  65. 'list':videos
  66. }
  67. return result
  68. def categoryContent(self,tid,pg,filter,extend):
  69. result = {}
  70. if 'id' not in extend.keys():
  71. extend['id'] = tid
  72. extend['page'] = pg
  73. filterParams = ["area", "by", "class", "id", "lang", "", "", "", "page", "", "", "year"]
  74. params = ["", "", "", "", "", "", "", "", "", "", "", ""]
  75. for idx in range(len(filterParams)):
  76. fp = filterParams[idx]
  77. if fp in extend.keys():
  78. params[idx] = fp + '/' + extend[fp]
  79. suffix = '/'.join(params)
  80. url = 'https://www.baipiaoys.com:9092/show/{0}.html'.format(suffix)
  81. rsp = self.fetch(url)
  82. root = self.html(rsp.text)
  83. aList = root.xpath("//div[@class='stui-vodlist__box']/a")
  84. videos = []
  85. for a in aList:
  86. name = a.xpath('./@title')[0]
  87. pic = a.xpath('./@data-original')[0]
  88. mark = a.xpath("./span[@class='pic-text text-right']/text()")[0]
  89. sid = a.xpath("./@href")[0]
  90. sid = self.regStr(sid,"/detail/(\\d+).html")
  91. videos.append({
  92. "vod_id":sid,
  93. "vod_name":name,
  94. "vod_pic":pic,
  95. "vod_remarks":mark
  96. })
  97. result['list'] = videos
  98. result['page'] = pg
  99. result['pagecount'] = 9999
  100. result['limit'] = 90
  101. result['total'] = 999999
  102. return result
  103. def detailContent(self,array):
  104. tid = array[0]
  105. url = 'https://www.baipiaoys.com:9092/detail/{0}.html'.format(tid)
  106. rsp = self.fetch(url)
  107. root = self.html(rsp.text)
  108. node = root.xpath("//div[@class='stui-pannel-box']//div[2]")[0]
  109. pic = node.xpath("//div[@class='stui-content__thumb']/a/img/@data-original")[0]
  110. title = node.xpath("//div[@class='stui-content__thumb']/a/@title")[0]
  111. # detail = node.xpath("//div[@class='stui-content__detail']/text()")[0]
  112. vod = {
  113. "vod_id":tid,
  114. "vod_name":title,
  115. "vod_pic":pic,
  116. "type_name":"",
  117. "vod_year":"",
  118. "vod_area":"",
  119. "vod_remarks":"",
  120. "vod_actor":"",
  121. "vod_director":"",
  122. "vod_content":""
  123. }
  124. infoArray = node.xpath("//div[@class='stui-content__detail']/p")
  125. for info in infoArray:
  126. content = info.xpath('string(.)')
  127. if content.startswith('类型'):
  128. vod['type_name'] = content.replace('类型:','')
  129. # if content.startswith('年份'):
  130. # vod['vod_year'] = content
  131. # if content.startswith('地区'):
  132. # vod['vod_area'] = content
  133. # if content.startswith('更新'):
  134. # vod['vod_remarks'] = content.replace('\n','').replace('\t','')
  135. if content.startswith('主演'):
  136. vod['vod_actor'] = content.replace('\n','').replace('\t','').replace('主演:','').replace('演员:','')
  137. if content.startswith('导演'):
  138. vod['vod_director'] = content.replace('\n','').replace('\t','').replace('导演:','')
  139. if content.startswith('简介'):
  140. vod['vod_content'] = content.replace('\n','').replace('\t','').replace('简介:','')
  141. vod_play_from = '$$$'
  142. playFrom = []
  143. vodHeader = root.xpath("//div[@class='stui-pannel-box b playlist mb']/div[@class='stui-pannel_hd']/div/h3/text()")
  144. for v in vodHeader:
  145. playFrom.append(v)
  146. vod_play_from = vod_play_from.join(playFrom)
  147. vod_play_url = '$$$'
  148. host = 'https://www.baipiaoys.com:9092'
  149. playList = []
  150. vodList = root.xpath("//ul[contains(@class,'stui-content__playlist')]")
  151. for vl in vodList:
  152. vodItems = []
  153. aList = vl.xpath('./li/a')
  154. for tA in aList:
  155. href = tA.xpath('./@href')[0]
  156. name = tA.xpath('./text()')[0]
  157. tId = self.regStr(href,'/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://www.baipiaoys.com:9092/search.html?wd={0}'.format(key)
  173. rsp = self.fetch(url)
  174. root = self.html(rsp.text)
  175. aList = root.xpath("//ul[@class='stui-vodlist__media col-pd clearfix']/li/div[1]/a")
  176. videos = []
  177. for a in aList:
  178. name = a.xpath('./@title')[0]
  179. pic = a.xpath('./@data-original')[0]
  180. mark = a.xpath("./span[@class='pic-text text-right']/text()")[0]
  181. sid = a.xpath("./@href")[0]
  182. sid = self.regStr(sid,"/detail/(\\S+).html")
  183. videos.append({
  184. "vod_id":sid,
  185. "vod_name":name,
  186. "vod_pic":pic,
  187. "vod_remarks":mark
  188. })
  189. result = {
  190. 'list':videos
  191. }
  192. return result
  193. config = {
  194. "player": {},
  195. #"baipiaom3u8": {
  196. # "sh": "白嫖播放器",
  197. # "pu": "https://www.baipiao-ys.cc:6062/player/?url=",
  198. # "sn": 1,
  199. # "or": 999
  200. # }
  201. # },
  202. "filter": {"1": [{"key": "id", "name": "类型", "value": [{"n": "全部", "v": "1"}, {"n": "动作", "v": "6"}, {"n": "喜剧", "v": "7"}, {"n": "爱情", "v": "8"}, {"n": "科幻", "v": "9"}, {"n": "恐怖", "v": "10"}, {"n": "剧情", "v": "11"}, {"n": "战争", "v": "12"}, {"n": "动画", "v": "13"}, {"n": "记录", "v": "14"}]}, {"key": "class", "name": "剧情", "value": [{"n": "全部", "v": ""}, {"n": "喜剧", "v": "喜剧"}, {"n": "爱情", "v": "爱情"}, {"n": "恐怖", "v": "恐怖"}, {"n": "动作", "v": "动作"}, {"n": "科幻", "v": "科幻"}, {"n": "剧情", "v": "剧情"}, {"n": "战争", "v": "战争"}, {"n": "警匪", "v": "警匪"}, {"n": "犯罪", "v": "犯罪"}, {"n": "动画", "v": "动画"}, {"n": "奇幻", "v": "奇幻"}, {"n": "武侠", "v": "武侠"}, {"n": "冒险", "v": "冒险"}, {"n": "枪战", "v": "枪战"}, {"n": "恐怖", "v": "恐怖"}, {"n": "悬疑", "v": "悬疑"}, {"n": "惊悚", "v": "惊悚"}, {"n": "经典", "v": "经典"}, {"n": "青春", "v": "青春"}, {"n": "文艺", "v": "文艺"}, {"n": "微电影", "v": "微电影"}, {"n": "古装", "v": "古装"}, {"n": "历史", "v": "历史"}, {"n": "运动", "v": "运动"}, {"n": "农村", "v": "农村"}, {"n": "儿童", "v": "儿童"}, {"n": "网络电影", "v": "网络电影"}]}, {"key": "area", "name": "地区", "value": [{"n": "全部", "v": ""}, {"n": "大陆", "v": "中国大陆"}, {"n": "香港", "v": "中国香港"}, {"n": "台湾", "v": "中国台湾"}, {"n": "美国", "v": "美国"}, {"n": "日本", "v": "日本"}, {"n": "韩国", "v": "韩国"}, {"n": "其他", "v": "其他"}]}, {"key": "year", "name": "年份", "value": [{"n": "全部", "v": ""}, {"n": "2024", "v": "2024"},{"n": "2023", "v": "2023"}, {"n": "2022", "v": "2022"}, {"n": "2021", "v": "2021"}, {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"}, {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"}, {"n": "2015", "v": "2015"}, {"n": "2014", "v": "2014"}, {"n": "2013", "v": "2013"}, {"n": "2012", "v": "2012"}, {"n": "2011", "v": "2011"}, {"n": "2010", "v": "2010"}]}, {"key": "by", "name": "排序", "value": [{"n": "全部", "v": ""}, {"n": "时间", "v": "time"}, {"n": "人气", "v": "hits"}, {"n": "评分", "v": "score"}]}],"2": [{"key": "class", "name": "剧情", "value": [{"n": "全部", "v": ""}, {"n": "古装", "v": "古装"}, {"n": "战争", "v": "战争"}, {"n": "青春偶像", "v": "青春偶像"}, {"n": "喜剧", "v": "喜剧"}, {"n": "家庭", "v": "家庭"}, {"n": "犯罪", "v": "犯罪"}, {"n": "动作", "v": "动作"}, {"n": "奇幻", "v": "奇幻"}, {"n": "剧情", "v": "剧情"}, {"n": "历史", "v": "历史"}, {"n": "经典", "v": "经典"}, {"n": "乡村", "v": "乡村"}, {"n": "情景", "v": "情景"}, {"n": "商战", "v": "商战"}, {"n": "网剧", "v": "网剧"}, {"n": "其他", "v": "其他"}]}, {"key": "area", "name": "地区", "value": [{"n": "全部", "v": ""}, {"n": "大陆", "v": "中国大陆"}, {"n": "香港", "v": "中国香港"}, {"n": "台湾", "v": "中国台湾"}, {"n": "美国", "v": "美国"}, {"n": "日本", "v": "日本"}, {"n": "韩国", "v": "韩国"}, {"n": "其他", "v": "其他"}]}, {"key": "year", "name": "年份", "value": [{"n": "全部", "v": ""}, {"n": "2024", "v": "2024"},{"n": "2023", "v": "2023"}, {"n": "2022", "v": "2022"}, {"n": "2021", "v": "2021"}, {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"}, {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"}, {"n": "2015", "v": "2015"}, {"n": "2014", "v": "2014"}, {"n": "2013", "v": "2013"}]}, {"key": "by", "name": "排序", "value": [{"n": "全部", "v": ""}, {"n": "时间", "v": "time"}, {"n": "人气", "v": "hits"}, {"n": "评分", "v": "score"}]}], "3": [{"key": "id", "name": "类型", "value": [{"n": "全部", "v": "3"}, {"n": "国产动漫", "v": "25"}, {"n": "日韩动漫", "v": "26"}, {"n": "欧美动漫", "v": "27"}, {"n": "其他", "v": "28"}]},{"key": "class", "name": "剧情", "value": [{"n": "全部", "v": ""}, {"n": "情感", "v": "情感"}, {"n": "科幻", "v": "科幻"}, {"n": "热血", "v": "热血"}, {"n": "推理", "v": "推理"}, {"n": "搞笑", "v": "搞笑"}, {"n": "冒险", "v": "冒险"}, {"n": "萝莉", "v": "萝莉"}, {"n": "校园", "v": "校园"}, {"n": "动作", "v": "动作"}, {"n": "机战", "v": "机战"}, {"n": "运动", "v": "运动"}, {"n": "战争", "v": "战争"}, {"n": "少年", "v": "少年"}, {"n": "少女", "v": "少女"}, {"n": "社会", "v": "社会"}, {"n": "原创", "v": "原创"}, {"n": "亲子", "v": "亲子"}, {"n": "益智", "v": "益智"}, {"n": "励志", "v": "励志"}, {"n": "其他", "v": "其他"}]}, {"key": "area", "name": "地区", "value": [{"n": "全部", "v": ""}, {"n": "大陆", "v": "中国大陆"}, {"n": "香港", "v": "中国香港"}, {"n": "台湾", "v": "中国台湾"}, {"n": "美国", "v": "美国"}, {"n": "日本", "v": "日本"}, {"n": "韩国", "v": "韩国"}, {"n": "其他", "v": "其他"}]}, {"key": "year", "name": "年份", "value": [{"n": "全部", "v": ""}, {"n": "2024", "v": "2024"},{"n": "2023", "v": "2023"}, {"n": "2022", "v": "2022"}, {"n": "2021", "v": "2021"}, {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"}, {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"}, {"n": "2015", "v": "2015"}, {"n": "2014", "v": "2014"}, {"n": "2013", "v": "2013"}]}, {"key": "by", "name": "排序", "value": [{"n": "全部", "v": ""}, {"n": "时间", "v": "time"}, {"n": "人气", "v": "hits"}, {"n": "评分", "v": "score"}]}],"5": [{"key": "id", "name": "类型", "value": [{"n": "全部", "v": "5"}, {"n": "大陆综艺", "v": "30"}, {"n": "日韩综艺", "v": "31"}, {"n": "港台综艺", "v": "32"}, {"n": "欧美综艺", "v": "33"}]},{"key": "area", "name": "地区", "value": [{"n": "全部", "v": ""}, {"n": "大陆", "v": "中国大陆"}, {"n": "香港", "v": "中国香港"}, {"n": "台湾", "v": "中国台湾"}, {"n": "美国", "v": "美国"}, {"n": "日本", "v": "日本"}, {"n": "韩国", "v": "韩国"}, {"n": "其他", "v": "其他"}]}, {"key": "year", "name": "年份", "value": [{"n": "全部", "v": ""}, {"n": "2024", "v": "2024"},{"n": "2023", "v": "2023"}, {"n": "2022", "v": "2022"}, {"n": "2021", "v": "2021"}, {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"}, {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"}, {"n": "2015", "v": "2015"}, {"n": "2014", "v": "2014"}, {"n": "2013", "v": "2013"}]}, {"key": "by", "name": "排序", "value": [{"n": "全部", "v": ""}, {"n": "时间", "v": "time"}, {"n": "人气", "v": "hits"}, {"n": "评分", "v": "score"}]}]}
  203. }
  204. header = {
  205. #"Referer":"https://www.baipiaoys.com:9092/",
  206. "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36"
  207. }
  208. def playerContent(self,flag,id,vipFlags):
  209. url = 'https://www.baipiaoys.com:9092/play/{0}.html'.format(id)
  210. rsp = self.fetch(url)
  211. root = self.html(rsp.text)
  212. scripts = root.xpath("//script/text()")
  213. jo = {}
  214. result = {}
  215. for script in scripts:
  216. if(script.startswith("var player_")):
  217. target = script[script.index('{'):]
  218. jo = json.loads(target)
  219. break;
  220. videoUrl = jo['url']
  221. parseUrl = 'https://www.baipiao-ys.cc:6062/player/analysis.php?v=' + videoUrl
  222. parseRsp = self.fetch(parseUrl)
  223. info = re.findall(r'"url":(.*?),',parseRsp.text,re.S)[0]
  224. data = info.replace('"','').strip()
  225. decUrl = self.rc4_decrypt(data, '202205051426239465')
  226. realUrl = unquote(decUrl)
  227. result["parse"] = 0
  228. result["playUrl"] = ''
  229. result["url"] = realUrl
  230. result["header"] = ''
  231. return result
  232. def localProxy(self,param):
  233. return [200, "video/MP2T", action, ""]