voflix.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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 time
  8. import base64
  9. class Spider(Spider): # 元类 默认的元类 type
  10. def getName(self):
  11. return "Voflix"
  12. def init(self,extend=""):
  13. print("============{0}============".format(extend))
  14. pass
  15. def isVideoFormat(self,url):
  16. pass
  17. def manualVideoCheck(self):
  18. pass
  19. def homeContent(self,filter):
  20. # https://meijuchong.cc/
  21. result = {}
  22. cateManual = {
  23. "电影": "1",
  24. "剧集": "2",
  25. "综艺": "3",
  26. "动漫": "4"
  27. }
  28. classes = []
  29. for k in cateManual:
  30. classes.append({
  31. 'type_name':k,
  32. 'type_id':cateManual[k]
  33. })
  34. result['class'] = classes
  35. if(filter):
  36. result['filters'] = self.config['filter']
  37. return result
  38. def homeVideoContent(self):
  39. rsp = self.fetch("https://www.voflix.com/",headers=self.header)
  40. root = self.html(rsp.text)
  41. vodList = root.xpath("//div[@class='module']/div[contains(@class,'tab-list')]//a")
  42. videos = []
  43. for vod in vodList:
  44. name = vod.xpath("./@title")[0]
  45. pic = vod.xpath(".//img/@data-original")[0]
  46. mark = vod.xpath(".//div[@class='module-item-note']/text()")[0]
  47. sid = vod.xpath("./@href")[0]
  48. sid = self.regStr(sid,"/detail/(\\S+).html")
  49. videos.append({
  50. "vod_id":sid,
  51. "vod_name":name,
  52. "vod_pic":pic,
  53. "vod_remarks":mark
  54. })
  55. result = {
  56. 'list':videos
  57. }
  58. return result
  59. def categoryContent(self,tid,pg,filter,extend):
  60. result = {}
  61. if 'id' not in extend.keys():
  62. extend['id'] = tid
  63. extend['page'] = pg
  64. filterParams = ["id", "area", "by", "class", "", "", "", "", "page", "", "", "year"]
  65. params = ["", "", "", "", "", "", "", "", "", "", "", ""]
  66. for idx in range(len(filterParams)):
  67. fp = filterParams[idx]
  68. if fp in extend.keys():
  69. params[idx] = extend[fp]
  70. suffix = '-'.join(params)
  71. url = 'https://www.voflix.com/show/{0}.html'.format(suffix)
  72. rsp = self.fetch(url,headers=self.header)
  73. root = self.html(rsp.text)
  74. vodList = root.xpath("//div[contains(@class, 'module-items')]/a")
  75. videos = []
  76. for vod in vodList:
  77. name = vod.xpath("./@title")[0]
  78. pic = vod.xpath(".//img/@data-original")[0]
  79. mark = vod.xpath(".//div[contains(@class,'module-item-note')]/text()")[0]
  80. sid = vod.xpath("./@href")[0]
  81. sid = self.regStr(sid,"/detail/(\\S+).html")
  82. videos.append({
  83. "vod_id":sid,
  84. "vod_name":name,
  85. "vod_pic":pic,
  86. "vod_remarks":mark
  87. })
  88. result['list'] = videos
  89. result['page'] = pg
  90. result['pagecount'] = 9999
  91. result['limit'] = 90
  92. result['total'] = 999999
  93. return result
  94. def detailContent(self,array):
  95. tid = array[0]
  96. url = 'https://www.voflix.com/detail/{0}.html'.format(tid)
  97. rsp = self.fetch(url,headers=self.header)
  98. root = self.html(rsp.text)
  99. node = root.xpath("//div[@class='main']")[0]
  100. title = node.xpath(".//div[@class='module-info-heading']/h1/text()")[0]
  101. pic = root.xpath(".//div[@class='module-item-pic']/img/@data-original")[0]
  102. vod = {
  103. "vod_id":tid,
  104. "vod_name":title,
  105. "vod_pic":pic,
  106. "type_name":"",
  107. "vod_year":"",
  108. "vod_area":"",
  109. "vod_remarks":"",
  110. "vod_actor":"",
  111. "vod_director":"",
  112. "vod_content":""
  113. }
  114. infoArray = node.xpath(".//div[@class='module-info-item']")
  115. for info in infoArray:
  116. content = info.xpath('string(.)')
  117. # if content.startswith('分類'):
  118. # vod['type_name'] = content
  119. # if content.startswith('年份'):
  120. # vod['vod_year'] = content
  121. # if content.startswith('地区'):
  122. # vod['vod_area'] = content
  123. if content.startswith('片长'):
  124. vod['vod_remarks'] = content.replace('\n','').replace('\t','')
  125. if content.startswith('主演'):
  126. vod['vod_actor'] = content.replace('\n','').replace('\t','')
  127. if content.startswith('导演'):
  128. vod['vod_director'] = content.replace('\n','').replace('\t','')
  129. # if content.startswith('剧情'):
  130. # vod['vod_content'] = content.replace('\n','').replace('\t','')
  131. vod['vod_content'] = node.xpath(".//div[contains(@class,'module-info-introduction-content')]/p/text()")[0].replace('\n','').replace('\t','')
  132. vod_play_from = '$$$'
  133. playFrom = []
  134. vodHeader = root.xpath(".//div[contains(@class,'module-tab-items-box')]/div/span/text()")
  135. for v in vodHeader:
  136. playFrom.append(v.strip())
  137. vod_play_from = vod_play_from.join(playFrom)
  138. vod_play_url = '$$$'
  139. playList = []
  140. vodList = root.xpath(".//div[contains(@class,'module-play-list-content')]")
  141. for vl in vodList:
  142. vodItems = []
  143. aList = vl.xpath('./a')
  144. for tA in aList:
  145. href = tA.xpath('./@href')[0]
  146. name = tA.xpath('.//span/text()')[0]
  147. tId = self.regStr(href,'/play/(\\S+).html')
  148. vodItems.append(name + "$" + tId)
  149. joinStr = '#'
  150. joinStr = joinStr.join(vodItems)
  151. playList.append(joinStr)
  152. vod_play_url = vod_play_url.join(playList)
  153. vod['vod_play_from'] = vod_play_from
  154. vod['vod_play_url'] = vod_play_url
  155. result = {
  156. 'list':[
  157. vod
  158. ]
  159. }
  160. return result
  161. def searchContent(self,key,quick):
  162. url = "https://www.voflix.com/index.php/ajax/suggest?mid=1&wd={0}".format(key)
  163. rsp = self.fetch(url,headers=self.header)
  164. jo = json.loads(rsp.text)
  165. vodList = jo['list']
  166. videos = []
  167. for vod in vodList:
  168. name = vod['name']
  169. pic = vod['pic']
  170. mark = ''
  171. sid = vod['id']
  172. videos.append({
  173. "vod_id":sid,
  174. "vod_name":name,
  175. "vod_pic":pic,
  176. "vod_remarks":mark
  177. })
  178. result = {
  179. 'list':videos
  180. }
  181. return result
  182. def playerContent(self,flag,id,vipFlags):
  183. # https://meijuchong.cc/static/js/playerconfig.js
  184. result = {}
  185. url = 'https://www.voflix.com/play/{0}.html'.format(id)
  186. rsp = self.fetch(url,headers=self.header)
  187. root = self.html(rsp.text)
  188. scripts = root.xpath("//script/text()")
  189. jo = {}
  190. for script in scripts:
  191. if(script.startswith("var player_")):
  192. target = script[script.index('{'):]
  193. jo = json.loads(target)
  194. break;
  195. parseUrl = 'https://play.shtpin.com/xplay/?url={0}'.format(jo['url'])
  196. parseRsp = self.fetch(parseUrl,headers={'referer':'https://www.voflix.com/'})
  197. configStr = self.regStr(parseRsp.text,'var config = ({[\\s\\S]+})')
  198. configJo = json.loads(configStr)
  199. playUrl = 'https://play.shtpin.com/xplay/555tZ4pvzHE3BpiO838.php?tm={0}&url={1}&vkey={2}&token={3}&sign=F4penExTGogdt6U8'
  200. playUrl.format(time.time(),configJo['url'],configJo['vkey'],configJo['token'])
  201. playRsp = self.fetch(playUrl.format(time.time(),configJo['url'],configJo['vkey'],configJo['token'])
  202. ,headers={'referer':'https://www.voflix.com/'})
  203. playJo = json.loads(playRsp.text)
  204. b64 = playJo['url'][8:]
  205. targetUrl = base64.b64decode(b64)[8:-8].decode()
  206. result["parse"] = 0
  207. result["playUrl"] = ''
  208. result["url"] = targetUrl
  209. result["header"] = ''
  210. return result
  211. config = {
  212. "player": {},
  213. "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":"23"}]},{"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":"日本"},{"n":"韩国","v":"韩国"},{"n":"德国","v":"德国"},{"n":"泰国","v":"泰国"},{"n":"印度","v":"印度"},{"n":"意大利","v":"意大利"},{"n":"西班牙","v":"西班牙"},{"n":"加拿大","v":"加拿大"},{"n":"其他","v":"其他"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":""},{"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":"time"},{"n":"最热","v":"hits"},{"n":"评分","v":"score"}]}],"2":[{"key":"id","name":"类型","value":[{"n":"全部","v":"2"},{"n":"国产剧","v":"13"},{"n":"港台剧","v":"14"},{"n":"日韩剧","v":"15"},{"n":"欧美剧","v":"16"},{"n":"纪 录片","v":"21"},{"n":"泰国剧","v":"24"}]},{"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":"泰国"},{"n":"英国","v":"英国"},{"n":"新加坡","v":"新加坡"},{"n":"其他","v":"其他"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":""},{"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"},{"n":"2009","v":"2009"},{"n":"2008","v":"2008"},{"n":"2006","v":"2006"},{"n":"2005","v":"2005"},{"n":"2004","v":"2004"}]},{"key":"by","name":"排序","value":[{"n":"最新","v":"time"},{"n":"最热","v":"hits"},{"n":"评分","v":"score"}]}],"3":[{"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":"求职"}]},{"key":"area","name":"地区","value":[{"n":"全部","v":""},{"n":"内地","v":"内地"},{"n":"港台","v":"港台"},{"n":"日韩","v":"日韩"},{"n":"欧美","v":"欧美"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":""},{"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"},{"n":"2009","v":"2009"},{"n":"2008","v":"2008"},{"n":"2007","v":"2007"},{"n":"2006","v":"2006"},{"n":"2005","v":"2005"},{"n":"2004","v":"2004"}]},{"key":"by","name":"排序","value":[{"n":"最新","v":"time"},{"n":"最热","v":"hits"},{"n":"评分","v":"score"}]}],"4":[{"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":"其他"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":""},{"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"},{"n":"2009","v":"2009"},{"n":"2008","v":"2008"},{"n":"2007","v":"2007"},{"n":"2006","v":"2006"},{"n":"2005","v":"2005"},{"n":"2004","v":"2004"}]},{"key":"by","name":"排序","value":[{"n":"最新","v":"time"},{"n":"最热","v":"hits"},{"n":"评分","v":"score"}]}]}
  214. }
  215. header = {}
  216. def localProxy(self,param):
  217. return [200, "video/MP2T", action, ""]