py_wmkk.py 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. # coding=utf-8
  2. # !/usr/bin/python
  3. import sys
  4. import re
  5. sys.path.append('..')
  6. from base.spider import Spider
  7. class Spider(Spider): # 元类 默认的元类 type
  8. def getName(self):
  9. return "完美看看"
  10. def init(self, extend=""):
  11. print("============{0}============".format(extend))
  12. pass
  13. def homeContent(self, filter):
  14. result = {}
  15. cateManual = {
  16. "电影": "1",
  17. "国产剧": "5",
  18. "欧美剧": "2",
  19. "韩剧": "3",
  20. "泰剧": "9",
  21. "日剧": "4",
  22. "动漫": "6",
  23. "综艺": "7",
  24. "纪录片": "10"
  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. if (filter):
  34. result['filters'] = self.config['filter']
  35. return result
  36. def homeVideoContent(self):
  37. result = {
  38. 'list': []
  39. }
  40. return result
  41. def categoryContent(self, tid, pg, filter, extend):
  42. result = {}
  43. url = 'https://www.wanmeikk.film/category/{0}-{1}.html'.format(tid, pg)
  44. rsp = self.fetch(url)
  45. root = self.html(rsp.text)
  46. aList = root.xpath("//div[@class='stui-pannel_bd']/ul[1]/li")
  47. videos = []
  48. for a in aList:
  49. name = a.xpath('./div/a/@title')[0]
  50. pic = a.xpath('./div/a/@data-original')[0]
  51. mark = a.xpath("./div/a/span[@class='pic-text text-right']/text()")[0]
  52. sid = a.xpath("./div/a/@href")[0].replace("/", "").replace("project", "").replace(".html", "")
  53. videos.append({
  54. "vod_id": sid,
  55. "vod_name": name,
  56. "vod_pic": pic,
  57. "vod_remarks": mark
  58. })
  59. result['list'] = videos
  60. result['page'] = pg
  61. result['pagecount'] = 9999
  62. result['limit'] = 90
  63. result['total'] = 999999
  64. return result
  65. def detailContent(self, array):
  66. tid = array[0]
  67. url = 'https://www.wanmeikk.film/project/{0}.html'.format(tid)
  68. header = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"}
  69. rsp = self.fetch(url, headers=header)
  70. root = self.html(rsp.content)
  71. divContent = root.xpath("//div[@class='col-lg-wide-75 col-xs-1']")[0]
  72. title = divContent.xpath(".//h1[@class='title']/text()")[0]
  73. pic = divContent.xpath(".//a[@class='stui-vodlist__thumb picture v-thumb']/img/@data-original")[0]
  74. detail = divContent.xpath(".//p[@class='desc detail hidden-xs']/span[@class='detail-content']/text()")[0]
  75. vod = {
  76. "vod_id": tid,
  77. "vod_name": title,
  78. "vod_pic": pic,
  79. "type_name": "",
  80. "vod_year": "",
  81. "vod_area": "",
  82. "vod_remarks": "",
  83. "vod_actor": "",
  84. "vod_director": "",
  85. "vod_content": detail
  86. }
  87. infoArray = divContent.xpath(".//div[@class='stui-content__detail']/p[@class='data']")
  88. for info in infoArray:
  89. content = info.xpath('string(.)')
  90. if content.startswith('类型'):
  91. infon = content.split('\xa0')
  92. for inf in infon:
  93. if inf.startswith('类型'):
  94. vod['type_name'] = inf.replace("类型:", "")
  95. if inf.startswith('地区'):
  96. vod['vod_area'] = inf.replace("地区:", "")
  97. if inf.startswith('年份'):
  98. vod['vod_year'] = inf.replace("年份:", "")
  99. if content.startswith('主演'):
  100. vod['vod_actor'] = content.replace("\xa0", "/").replace("主演:", "")
  101. if content.startswith('导演'):
  102. vod['vod_director'] = content.replace("\xa0", "").replace("导演:", "")
  103. vod_play_url = '$$$'
  104. vod['vod_play_from'] = '完美看看'
  105. purl = divContent.xpath(".//div[@class='stui-pannel_bd col-pd clearfix']/ul/li")
  106. playList = []
  107. vodItems = []
  108. for plurl in purl:
  109. plaurl = plurl.xpath(".//a/@href")[0]
  110. name = plurl.xpath(".//a/text()")[0]
  111. tId = self.regStr(plaurl, '/play/(\\S+).html')
  112. vodItems.append(name + "$" + tId)
  113. joinStr = '#'
  114. joinStr = joinStr.join(vodItems)
  115. playList.append(joinStr)
  116. vod_play_url = vod_play_url.join(playList)
  117. vod['vod_play_url'] = vod_play_url
  118. result = {
  119. 'list': [
  120. vod
  121. ]
  122. }
  123. return result
  124. def searchContent(self, key, quick):
  125. result = {}
  126. return result
  127. def playerContent(self, flag, id, vipFlags):
  128. result = {}
  129. url = 'https://www.wanmeikk.film/play/{0}.html'.format(id)
  130. rsp = self.fetch(url)
  131. root = self.html(rsp.text)
  132. scripts = root.xpath("//div[@class='stui-player__video embed-responsive embed-responsive-16by9 clearfix']/script/text()")[0]
  133. key = scripts.split("url")[1].replace('"', "").replace(':', "").replace(',', "").replace("'", "")
  134. surl = 'https://www.wanmeikk.film/dplayer.php?url={0}'.format(key)
  135. srsp = self.fetch(surl)
  136. sroot = self.html(srsp.text)
  137. murl = sroot.xpath("//script[@type='text/javascript']/text()")[0]
  138. mp4url = re.findall(r"var urls = '(.*)';", murl)[0]
  139. result["parse"] = 0
  140. result["playUrl"] = ''
  141. result["url"] = mp4url
  142. result["header"] = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"}
  143. return result
  144. config = {
  145. "player": {},
  146. "filter": {}
  147. }
  148. header = {}
  149. def isVideoFormat(self, url):
  150. pass
  151. def manualVideoCheck(self):
  152. pass
  153. def localProxy(self, param):
  154. action = {
  155. 'url': '',
  156. 'header': '',
  157. 'param': '',
  158. 'type': 'string',
  159. 'after': ''
  160. }
  161. return [200, "video/MP2T", action, ""]