py_3qu.py 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. import json
  9. class Spider(Spider): # 元类 默认的元类 type
  10. def getName(self):
  11. return "快播影视"
  12. def init(self, extend=""):
  13. print("============{0}============".format(extend))
  14. pass
  15. def homeContent(self, filter):
  16. result = {}
  17. cateManual = {
  18. "电影": "movie",
  19. "剧集": "serie",
  20. "综艺": "variety",
  21. "动漫": "anime"
  22. }
  23. classes = []
  24. for k in cateManual:
  25. classes.append({
  26. 'type_name': k,
  27. 'type_id': cateManual[k]
  28. })
  29. result['class'] = classes
  30. if (filter):
  31. result['filters'] = self.config['filter']
  32. return result
  33. def homeVideoContent(self):
  34. result = {
  35. 'list': []
  36. }
  37. return result
  38. def categoryContent(self, tid, pg, filter, extend):
  39. result = {}
  40. 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"}
  41. url = 'https://www.3qu.live/videos/{0}?page={1}'.format(tid, pg)
  42. rsp = self.fetch(url,headers=header)
  43. root = self.html(self.cleanText(rsp.text))
  44. aList = root.xpath("//div[@class='main-content-box']/div/div/div/div/div/div/a")
  45. videos = []
  46. for a in aList:
  47. name = a.xpath('./@title')[0]
  48. picl = a.xpath('./@style')[0]
  49. pica = re.findall(r"url\(\'(.*)\'\);", picl)[0]
  50. pic = 'https://www.3qu.live{0}'.format(pica)
  51. sidh = a.xpath("./@href")[0]
  52. sid = self.regStr(sidh,'/videos/(\\S+).html')
  53. videos.append({
  54. "vod_id": sid,
  55. "vod_name": name,
  56. "vod_pic": pic,
  57. "vod_remarks": ""
  58. })
  59. result['list'] = videos
  60. result['page'] = pg
  61. result['pagecount'] = 9999
  62. result['limit'] = 100
  63. result['total'] = 99999
  64. return result
  65. def detailContent(self, array):
  66. tid = array[0]
  67. url = 'https://www.3qu.live/videos/{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(self.cleanText(rsp.text))
  71. divContent = root.xpath("//div[@class='video-detail row']")[0]
  72. title = divContent.xpath(".//div[@class='info-box']/a/h1/text()")[0]
  73. pica = divContent.xpath(".//div[@class='thumb-box']/img/@src")[0]
  74. pic = 'https://www.3qu.live{0}'.format(pica)
  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": ""
  86. }
  87. infoArray = divContent.xpath(".//div[@class='info-box']/ul/li")
  88. for info in infoArray:
  89. content = info.xpath('string(.)')
  90. flag = "类型" in content
  91. if flag == True:
  92. infon = content.strip().split(' ')
  93. for inf in infon:
  94. if inf.startswith('类型'):
  95. vod['type_name'] = inf.replace("类型:", "")
  96. if inf.startswith('地区'):
  97. vod['vod_area'] = inf.replace("地区:", "")
  98. if inf.startswith('语言'):
  99. vod['vod_remarks'] = inf.replace("语言:", "")
  100. if content.startswith('演员'):
  101. vod['vod_actor'] = content.replace("演员:", "")
  102. if content.startswith('年份'):
  103. yearl = content.split(' ')
  104. year = yearl[0].replace("年份:", "")
  105. vod['vod_year'] = year
  106. if content.startswith('导演'):
  107. vod['vod_director'] = content.replace("导演:", "")
  108. if content.startswith('简介'):
  109. vod['vod_content'] = content.replace("简介:", "")
  110. vodList = root.xpath(".//div[@class='tab-content']/div[@id='playlist']/a")
  111. playUrl = ''
  112. for vl in vodList:
  113. name = vl.xpath("./text()")[0]
  114. did = vl.xpath("./@data-id")[0]
  115. playUrl = playUrl + '{0}${1}_{2}#'.format(name,tid,did)
  116. vod['vod_play_from'] = '快播影视'
  117. vod['vod_play_url'] = playUrl
  118. result = {
  119. 'list': [
  120. vod
  121. ]
  122. }
  123. return result
  124. def searchContent(self, key, quick):
  125. header = {
  126. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"}
  127. url = 'https://www.3qu.live/api/v1/search?page=1&q={0}&type=all&period=0'.format(key)
  128. rsp = self.fetch(url, headers=header)
  129. jRoot = json.loads(rsp.text)
  130. videos = []
  131. vodList = jRoot['data']['videos']
  132. for vod in vodList:
  133. id = vod['id']
  134. title = vod['name']
  135. img = vod['coverURL']
  136. pic = 'https://www.3qu.live{0}'.format(img)
  137. videos.append({
  138. "vod_id": id,
  139. "vod_name": title,
  140. "vod_pic": pic,
  141. "vod_remarks": ""
  142. })
  143. result = {
  144. 'list': videos
  145. }
  146. return result
  147. def playerContent(self, flag, id, vipFlags):
  148. result = {}
  149. ids = id.split("_")
  150. 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"}
  151. url = 'https://www.3qu.live/api/v1/videos/{0}/{1}/playUrl'.format(ids[0],ids[1])
  152. rsp = self.fetch(url,headers=header)
  153. jRoot = json.loads(rsp.text)
  154. apiurl = jRoot['data']['url']
  155. url = 'https://www.3qu.live{0}'.format(apiurl)
  156. result["parse"] = 0
  157. result["playUrl"] = ''
  158. result["url"] =url
  159. 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"}
  160. return result
  161. config = {
  162. "player": {},
  163. "filter": {}
  164. }
  165. header = {}
  166. def isVideoFormat(self, url):
  167. pass
  168. def manualVideoCheck(self):
  169. pass
  170. def localProxy(self, param):
  171. action = {
  172. 'url': '',
  173. 'header': '',
  174. 'param': '',
  175. 'type': 'string',
  176. 'after': ''
  177. }
  178. return [200, "video/MP2T", action, ""]