py_555dy2.py 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. import urllib.parse
  8. class Spider(Spider): # 元类 默认的元类 type
  9. def getName(self):
  10. return "555影视"
  11. def init(self, extend=""):
  12. print("============{0}============".format(extend))
  13. pass
  14. def homeContent(self, filter):
  15. result = {}
  16. cateManual = {
  17. "电影": "1",
  18. "剧集": "2",
  19. "综艺": "3",
  20. "动漫": "4"
  21. }
  22. classes = []
  23. for k in cateManual:
  24. classes.append({
  25. 'type_name': k,
  26. 'type_id': cateManual[k]
  27. })
  28. result['class'] = classes
  29. if (filter):
  30. result['filters'] = self.config['filter']
  31. return result
  32. def homeVideoContent(self):
  33. result = {
  34. 'list': []
  35. }
  36. return result
  37. def categoryContent(self, tid, pg, filter, extend):
  38. result = {}
  39. header = {"User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36"}
  40. url = 'https://555dy1.com/vodtype/{0}-{1}.html'.format(tid, pg)
  41. rsp = self.fetch(url,headers=header)
  42. root = self.html(self.cleanText(rsp.text))
  43. aList = root.xpath("//div[@class='module-items module-poster-items-base ']/a"")
  44. videos = []
  45. for a in aList:
  46. name = a.xpath('./@title')[0]
  47. pic = a.xpath('.//div[@class='module-item-pic']/img/@data-original"')[0]
  48. mark = a.xpath(".//div[@class='module-item-note']/text()")[0]
  49. sid = a.xpath("./@href")[0].replace("/", "").replace("voddetail", "").replace(".html", "")
  50. videos.append({
  51. "vod_id": sid,
  52. "vod_name": name,
  53. "vod_pic": pic,
  54. "vod_remarks": mark
  55. })
  56. result['list'] = videos
  57. result['page'] = pg
  58. result['pagecount'] = 999
  59. result['limit'] = 5
  60. result['total'] = 9999
  61. return result
  62. def detailContent(self, array):
  63. tid = array[0]
  64. url = 'https://555dy1.com/vodtype/{0}.html'.format(tid)
  65. header = {"User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36"}
  66. rsp = self.fetch(url,headers=header)
  67. root = self.html(self.cleanText(rsp.text))
  68. divContent = root.xpath("//div[@class='col-lg-wide-75 col-md-wide-7 col-xs-1 padding-0']")[0]
  69. title = divContent.xpath(".//div[@class='myui-content__detail']/h1/text()")[0]
  70. pic = divContent.xpath(".//div[@class='myui-content__thumb']/a/img/@data-original")[0]
  71. det = divContent.xpath(".//div[@class='col-pd text-collapse content']/span[@class='data']")[0]
  72. if det.text is None:
  73. detail = det.xpath(".//p/text()")[0]
  74. else:
  75. detail = det.text
  76. vod = {
  77. "vod_id": tid,
  78. "vod_name": title,
  79. "vod_pic": pic,
  80. "type_name": "",
  81. "vod_year": "",
  82. "vod_area": "",
  83. "vod_remarks": "",
  84. "vod_actor": "",
  85. "vod_director": "",
  86. "vod_content": detail
  87. }
  88. infoArray = divContent.xpath(".//div[@class='myui-content__detail']/p[contains(@class,'data')]")
  89. for info in infoArray:
  90. content = info.xpath('string(.)')
  91. flag = "分类" in content
  92. if flag == True:
  93. infon = content.replace("\t","").replace("\n","").strip().split('\r')
  94. for inf in infon:
  95. if inf.startswith('分类'):
  96. vod['type_name'] = inf.replace("分类:", "")
  97. if inf.startswith('地区'):
  98. vod['vod_area'] = inf.replace("地区:", "")
  99. if inf.startswith('年份'):
  100. vod['vod_year'] = inf.replace("年份:", "")
  101. if content.startswith('主演'):
  102. vod['vod_actor'] = content.replace("\xa0", "/").replace("主演:", "").strip('/')
  103. if content.startswith('更新'):
  104. vod['vod_remarks'] = content.replace("更新:", "")
  105. if content.startswith('导演'):
  106. vod['vod_director'] = content.replace("\xa0", "").replace("导演:", "").strip('/')
  107. vod_play_from = '$$$'
  108. playFrom = []
  109. vodHeader = divContent.xpath(".//div[@class='myui-panel_hd']/div/ul/li/a[contains(@href,'playlist')]/text()")
  110. for v in vodHeader:
  111. playFrom.append(v.replace(" ", ""))
  112. vod_play_from = vod_play_from.join(playFrom)
  113. vod_play_url = '$$$'
  114. playList = []
  115. vodList = divContent.xpath(".//div[contains(@id,'playlist')]")
  116. for vl in vodList:
  117. vodItems = []
  118. aList = vl.xpath('./ul/li/a')
  119. if len(aList) <= 0:
  120. name = '无法找到播放源'
  121. tId = '00000'
  122. vodItems.append(name + "$" + tId)
  123. else:
  124. for tA in aList:
  125. href = tA.xpath('./@href')[0]
  126. name = tA.xpath("./text()")[0].replace(" ", "")
  127. tId = self.regStr(href, '/vodplay/(\\S+).html')
  128. vodItems.append(name + "$" + tId)
  129. joinStr = '#'
  130. joinStr = joinStr.join(vodItems)
  131. playList.append(joinStr)
  132. vod_play_url = vod_play_url.join(playList)
  133. vod['vod_play_from'] = vod_play_from
  134. vod['vod_play_url'] = vod_play_url
  135. result = {
  136. 'list': [
  137. vod
  138. ]
  139. }
  140. return result
  141. def searchContent(self, key, quick):
  142. url = 'https://www.30dian.cn/vodsearch/-------------.html?wd={0}'.format(key)
  143. header = {
  144. "User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36"}
  145. rsp = self.fetch(url, headers=header)
  146. root = self.html(self.cleanText(rsp.text))
  147. aList = root.xpath("//ul[contains(@class,'myui-vodlist__media clearfix')]/li")
  148. videos = []
  149. for a in aList:
  150. name = a.xpath(".//div[@class='detail']/h4/a/text()")[0]
  151. pic = a.xpath(".//a[contains(@class,'myui-vodlist__thumb')]//@data-original")[0]
  152. mark = a.xpath(".//span[@class='tag']/text()")[0]
  153. sid = a.xpath(".//div[@class='detail']/h4/a/@href")[0]
  154. sid = self.regStr(sid,'/voddetail/(\\S+).html')
  155. videos.append({
  156. "vod_id": sid,
  157. "vod_name": name,
  158. "vod_pic": pic,
  159. "vod_remarks": mark
  160. })
  161. result = {
  162. 'list': videos
  163. }
  164. return result
  165. def playerContent(self, flag, id, vipFlags):
  166. result = {}
  167. header = {
  168. "User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36"}
  169. if id == '00000':
  170. return {}
  171. url = 'https://www.30dian.cn/vodplay/{0}.html'.format(id)
  172. rsp = self.fetch(url,headers=header)
  173. root = self.html(self.cleanText(rsp.text))
  174. scripts = root.xpath("//div[@class='embed-responsive clearfix']/script[@type='text/javascript']/text()")[0]
  175. ukey = re.findall(r"url(.*)url_next", scripts)[0].replace('"', "").replace(',', "").replace(':', "")
  176. purl = urllib.parse.unquote(ukey)
  177. result["parse"] = 0
  178. result["playUrl"] = ''
  179. result["url"] =purl
  180. 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"}
  181. return result
  182. config = {
  183. "player": {},
  184. "filter": {}
  185. }
  186. header = {}
  187. def isVideoFormat(self, url):
  188. pass
  189. def manualVideoCheck(self):
  190. pass
  191. def localProxy(self, param):
  192. action = {
  193. 'url': '',
  194. 'header': '',
  195. 'param': '',
  196. 'type': 'string',
  197. 'after': ''
  198. }
  199. return [200, "video/MP2T", action, ""]