剧迷.py 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. class Spider(Spider): # 元类 默认的元类 type
  8. def getName(self):
  9. return "剧迷"
  10. def init(self,extend=""):
  11. print("============{0}============".format(extend))
  12. pass
  13. def isVideoFormat(self,url):
  14. pass
  15. def manualVideoCheck(self):
  16. pass
  17. def homeContent(self,filter):
  18. # https://gimytv.co/
  19. result = {}
  20. cateManual = {
  21. "电影": "movies",
  22. "电视剧": "tvseries",
  23. "综艺": "tv_show",
  24. "动漫": "anime"
  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. rsp = self.fetch("https://gimytv.co/",headers=self.header)
  38. root = self.html(rsp.text)
  39. aList = root.xpath("//ul[@class='myui-vodlist clearfix']/li/div/a")
  40. videos = []
  41. for a in aList:
  42. name = a.xpath("./@title")[0]
  43. pic = a.xpath("./@data-original")[0]
  44. mark = a.xpath("./span[contains(@class, 'pic-text')]/text()")[0]
  45. sid = a.xpath("./@href")[0]
  46. sid = self.regStr(sid,"/(\\S+).html")
  47. videos.append({
  48. "vod_id":sid,
  49. "vod_name":name,
  50. "vod_pic":pic,
  51. "vod_remarks":mark
  52. })
  53. result = {
  54. 'list':videos
  55. }
  56. return result
  57. def categoryContent(self,tid,pg,filter,extend):
  58. result = {}
  59. urlParams = ["", "", "", ""]
  60. urlParams[0] = tid
  61. urlParams[3] = pg
  62. suffix = ''
  63. for key in extend:
  64. if key == 4:
  65. suffix = '/by/'+extend[key]
  66. else:
  67. urlParams[int(key)] = extend[key]
  68. params = '-'.join(urlParams)+suffix
  69. # https://gimytv.co/genre/tvseries--2022-/by/hits_month.html
  70. url = 'https://gimytv.com/genre/{0}.html'.format(params)
  71. rsp = self.fetch(url,headers=self.header)
  72. root = self.html(rsp.text)
  73. aList = root.xpath("//ul[@class='myui-vodlist clearfix']/li/div/a")
  74. videos = []
  75. for a in aList:
  76. name = a.xpath("./@title")[0]
  77. pic = a.xpath("./@data-original")[0]
  78. mark = a.xpath("./span[contains(@class, 'pic-text')]/text()")[0]
  79. sid = a.xpath("./@href")[0]
  80. sid = self.regStr(sid,"/(\\S+).html")
  81. videos.append({
  82. "vod_id":sid,
  83. "vod_name":name,
  84. "vod_pic":pic,
  85. "vod_remarks":mark
  86. })
  87. result['list'] = videos
  88. result['page'] = pg
  89. result['pagecount'] = 9999
  90. result['limit'] = 90
  91. result['total'] = 999999
  92. return result
  93. def detailContent(self,array):
  94. tid = array[0]
  95. url = 'https://gimytv.co/{0}.html'.format(tid)
  96. rsp = self.fetch(url,headers=self.header)
  97. root = self.html(rsp.text)
  98. node = root.xpath("//div[@class='container']")[0]
  99. title = node.xpath(".//div[@class='myui-content__thumb']/a/@title")[0]
  100. pic = node.xpath(".//div[@class='myui-content__thumb']/a/img/@data-original")[0]
  101. vod = {
  102. "vod_id":tid,
  103. "vod_name":title,
  104. "vod_pic":pic,
  105. "type_name":"",
  106. "vod_year":"",
  107. "vod_area":"",
  108. "vod_remarks":"",
  109. "vod_actor":"",
  110. "vod_director":"",
  111. "vod_content":""
  112. }
  113. infoArray = node.xpath(".//div[@class='myui-content__detail']/p")
  114. for info in infoArray:
  115. content = info.xpath('string(.)')
  116. if content.startswith('分類'):
  117. vod['type_name'] = content
  118. # if content.startswith('年份'):
  119. # vod['vod_year'] = content
  120. # if content.startswith('地区'):
  121. # vod['vod_area'] = content
  122. if content.startswith('狀態'):
  123. vod['vod_remarks'] = content
  124. if content.startswith('主演'):
  125. vod['vod_actor'] = content
  126. if content.startswith('導演'):
  127. vod['vod_director'] = content
  128. # if content.startswith('剧情'):
  129. # vod['vod_content'] = content
  130. vod['vod_content'] = node.xpath(".//div[contains(@class,'col-pd')]/p/text()")[0]
  131. vod_play_from = '$$$'
  132. playFrom = []
  133. vodHeader = root.xpath(".//div[@class='myui-panel_hd']/div/h3/text()[2]")
  134. for v in vodHeader:
  135. playFrom.append(v.strip())
  136. vod_play_from = vod_play_from.join(playFrom)
  137. vod_play_url = '$$$'
  138. playList = []
  139. vodList = root.xpath(".//ul[contains(@class,'myui-content__list')]")
  140. for vl in vodList:
  141. vodItems = []
  142. aList = vl.xpath('./li/a')
  143. for tA in aList:
  144. href = tA.xpath('./@href')[0]
  145. name = tA.xpath('./text()')[0]
  146. tId = self.regStr(href,'/(\\S+).html')
  147. vodItems.append(name + "$" + tId)
  148. joinStr = '#'
  149. joinStr = joinStr.join(vodItems)
  150. playList.append(joinStr)
  151. vod_play_url = vod_play_url.join(playList)
  152. vod['vod_play_from'] = vod_play_from
  153. vod['vod_play_url'] = vod_play_url
  154. result = {
  155. 'list':[
  156. vod
  157. ]
  158. }
  159. return result
  160. def searchContent(self,key,quick):
  161. url = "https://gimytv.co/search/-------------.html?wd={0}".format(key)
  162. rsp = self.fetch(url,headers=self.header)
  163. root = self.html(rsp.text)
  164. aList = root.xpath("//ul[contains(@class,'myui-vodlist__media')]/li")
  165. videos = []
  166. for a in aList:
  167. name = a.xpath(".//a/@title")[0]
  168. pic = a.xpath(".//a/@data-original")[0]
  169. mark = a.xpath(".//span[contains(@class, 'pic-text')]/text()")[0]
  170. sid = a.xpath(".//a/@href")[0]
  171. sid = self.regStr(sid,"/(\\S+).html")
  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. url = 'https://gimytv.co/{0}.html'.format(id)
  184. rsp = self.fetch(url,headers=self.header)
  185. root = self.html(rsp.text)
  186. scripts = root.xpath("//script/text()")
  187. jo = {}
  188. for script in scripts:
  189. if(script.startswith("var player_")):
  190. target = script[script.index('{'):]
  191. jo = json.loads(target)
  192. break;
  193. url = jo['url']
  194. result = {}
  195. result["parse"] = 0
  196. result["playUrl"] = ''
  197. result["url"] = url
  198. result["header"] = ''
  199. return result
  200. cookie = {}
  201. config = {
  202. "player": {},
  203. "filter": {"movies":[{"key":0,"name":"分类","value":[{"n":"全部","v":""},{"n":"劇情片","v":"drama"},{"n":"動作片","v":"action"},{"n":"科幻片","v":"scifi"},{"n":"喜劇片","v":"comedymovie"},{"n":"愛情片","v":"romance"},{"n":"戰爭片","v":"war"},{"n":"恐怖片","v":"horror"},{"n":"動畫電影","v":"animation"}]},{"key":1,"name":"地区","value":[{"n":"全部","v":""},{"n":"美國","v":"美國"},{"n":"歐美","v":"歐美"},{"n":"大陸","v":"大陸"},{"n":"中國大陸","v":"中國大陸"},{"n":"韓國","v":"韓國"},{"n":"香港","v":"香港"},{"n":"日本","v":"日本"},{"n":"英國","v":"英國"}]},{"key":2,"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"}]},{"key":4,"name":"排序","value":[{"n":"按更新","v":"time"},{"n":"周人气","v":"hits_week"},{"n":"月人气","v":"hits_month"}]}],"tvseries":[{"key":0,"name":"分类","value":[{"n":"全部","v":""},{"n":"陸劇","v":"cn"},{"n":"韓劇","v":"kr"},{"n":"美劇","v":"us"},{"n":"日劇","v":"jp"},{"n":"台劇","v":"tw"},{"n":"港劇","v":"hks"},{"n":"海外劇","v":"ot"},{"n":"紀錄片","v":"documentary"}]},{"key":2,"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"}]},{"key":4,"name":"排序","value":[{"n":"按更新","v":"time"},{"n":"周人气","v":"hits_week"},{"n":"月人气","v":"hits_month"}]}],"anime":[{"key":1,"name":"地区","value":[{"n":"全部","v":""},{"n":"日本","v":"日本"},{"n":"美國","v":"美國"},{"n":"歐美","v":"歐美"},{"n":"大陸","v":"大陸"},{"n":"臺灣","v":"臺灣"},{"n":"香港","v":"香港"}]},{"key":2,"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"}]},{"key":4,"name":"排序","value":[{"n":"按更新","v":"time"},{"n":"周人气","v":"hits_week"},{"n":"月人气","v":"hits_month"}]}],"tv_show":[{"key":0,"name":"分类","value":[{"n":"全部","v":""},{"n":"纪录片","v":"28"}]},{"key":1,"name":"地区","value":[{"n":"全部","v":""},{"n":"大陸","v":"大陸"},{"n":"中國大陸","v":"中國大陸"},{"n":"韓國","v":"韓國"},{"n":"臺灣","v":"臺灣"},{"n":"美國","v":"美國"},{"n":"歐美","v":"歐美"},{"n":"日本","v":"日本"},{"n":"香港","v":"香港"}]},{"key":2,"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"}]},{"key":4,"name":"排序","value":[{"n":"按更新","v":"time"},{"n":"周人气","v":"hits_week"},{"n":"月人气","v":"hits_month"}]}]}
  204. }
  205. header = {
  206. 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.81 Safari/537.36 Edg/104.0.1293.47'
  207. }
  208. def localProxy(self,param):
  209. return [200, "video/MP2T", action, ""]