py_cup.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 homeContent(self,filter):
  14. result = {}
  15. cateManual = {
  16. "电视剧":"20",
  17. "电影":"21",
  18. "动漫":"22",
  19. "综艺":"23",
  20. "纪录片":"24"
  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. rsp = self.fetch("http://www.qifudata.com/")
  34. root = self.html(rsp.text)
  35. aList = root.xpath("//div[@class='stui-vodlist__box']/a")
  36. videos = []
  37. for a in aList:
  38. name = a.xpath('./@title')[0]
  39. pic = a.xpath('./@data-original')[0]
  40. mark = a.xpath("./span[@class='pic-text text-right']/text()")[0]
  41. sid = a.xpath("./@href")[0]
  42. sid = self.regStr(sid,"/spx/(\\S+).html")
  43. videos.append({
  44. "vod_id":sid,
  45. "vod_name":name,
  46. "vod_pic":pic,
  47. "vod_remarks":mark
  48. })
  49. result = {
  50. 'list':videos
  51. }
  52. return result
  53. def categoryContent(self,tid,pg,filter,extend):
  54. result = {}
  55. if 'id' not in extend.keys():
  56. extend['id'] = tid
  57. extend['page'] = pg
  58. filterParams = ["id", "area", "by", "class", "lang", "", "", "", "page", "", "", "year"]
  59. params = ["", "", "", "", "", "", "", "", "", "", "", ""]
  60. for idx in range(len(filterParams)):
  61. fp = filterParams[idx]
  62. if fp in extend.keys():
  63. params[idx] = extend[fp]
  64. suffix = '-'.join(params)
  65. url = 'http://www.qifudata.com/vodshow/{0}.html'.format(suffix)
  66. rsp = self.fetch(url)
  67. root = self.html(rsp.text)
  68. aList = root.xpath("//div[@class='stui-vodlist__box']/a")
  69. videos = []
  70. for a in aList:
  71. name = a.xpath('./@title')[0]
  72. pic = a.xpath('./@data-original')[0]
  73. mark = a.xpath("./span[@class='pic-text text-right']/b/text()")[0]
  74. sid = a.xpath("./@href")[0]
  75. sid = self.regStr(sid,"/spx/(\\S+).html")
  76. videos.append({
  77. "vod_id":sid,
  78. "vod_name":name,
  79. "vod_pic":pic,
  80. "vod_remarks":mark
  81. })
  82. result['list'] = videos
  83. result['page'] = pg
  84. result['pagecount'] = 9999
  85. result['limit'] = 90
  86. result['total'] = 999999
  87. return result
  88. def detailContent(self,array):
  89. tid = array[0]
  90. url = 'http://www.qifudata.com/spx/{0}.html'.format(tid)
  91. rsp = self.fetch(url)
  92. root = self.html(rsp.text)
  93. node = root.xpath("//div[@class='stui-content']")[0]
  94. pic = node.xpath(".//img/@data-original")[0]
  95. title = node.xpath('.//h1/text()')[0]
  96. detail = node.xpath(".//span[@class='detail-content']/text()")[0]
  97. vod = {
  98. "vod_id":tid,
  99. "vod_name":title,
  100. "vod_pic":pic,
  101. "type_name":"",
  102. "vod_year":"",
  103. "vod_area":"",
  104. "vod_remarks":"",
  105. "vod_actor":"",
  106. "vod_director":"",
  107. "vod_content":detail
  108. }
  109. infoArray = node.xpath(".//div[@class='stui-content__detail']/p")
  110. for info in infoArray:
  111. content = info.xpath('string(.)')
  112. if content.startswith('类型'):
  113. vod['type_name'] = content
  114. # if content.startswith('年份'):
  115. # vod['vod_year'] = content
  116. # if content.startswith('地区'):
  117. # vod['vod_area'] = content
  118. # if content.startswith('更新'):
  119. # vod['vod_remarks'] = content.replace('\n','').replace('\t','')
  120. if content.startswith('主演'):
  121. vod['vod_actor'] = content.replace('\n','').replace('\t','')
  122. if content.startswith('导演'):
  123. vod['vod_director'] = content.replace('\n','').replace('\t','')
  124. # if content.startswith('剧情'):
  125. # vod['vod_content'] = content.replace('\n','').replace('\t','')
  126. vod_play_from = '$$$'
  127. playFrom = []
  128. vodHeader = root.xpath("//div[@class='stui-vodlist__head']/h3/text()")
  129. for v in vodHeader:
  130. playFrom.append(v)
  131. vod_play_from = vod_play_from.join(playFrom)
  132. vod_play_url = '$$$'
  133. playList = []
  134. vodList = root.xpath("//ul[contains(@class,'stui-content__playlist')]")
  135. for vl in vodList:
  136. vodItems = []
  137. aList = vl.xpath('./li/a')
  138. for tA in aList:
  139. href = tA.xpath('./@href')[0]
  140. name = tA.xpath('./text()')[0]
  141. tId = self.regStr(href,'/sp/(\\S+).html')
  142. vodItems.append(name + "$" + tId)
  143. joinStr = '#'
  144. joinStr = joinStr.join(vodItems)
  145. playList.append(joinStr)
  146. vod_play_url = vod_play_url.join(playList)
  147. vod['vod_play_from'] = vod_play_from
  148. vod['vod_play_url'] = vod_play_url
  149. result = {
  150. 'list':[
  151. vod
  152. ]
  153. }
  154. return result
  155. def searchContent(self,key,quick):
  156. url = 'http://www.qifudata.com/index.php/ajax/suggest?mid=1&wd={0}'.format(key)
  157. # getHeader()
  158. rsp = self.fetch(url)
  159. jo = json.loads(rsp.text)
  160. result = {}
  161. jArray = []
  162. if int(jo['total']) > 0:
  163. for j in jo['list']:
  164. jArray.append({
  165. "vod_id": j['id'],
  166. "vod_name": j['name'],
  167. "vod_pic": j['pic'],
  168. "vod_remarks": ""
  169. })
  170. result = {
  171. 'list':jArray
  172. }
  173. return result
  174. config = {
  175. "player": {
  176. "dpp": {
  177. "sh": "DP播放",
  178. "pu": "https://jx.qifudata.com/?url=",
  179. "sn": 1,
  180. "or": 999
  181. }
  182. },
  183. "filter": {"20": [{"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": "运动"},{"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": "2007", "v": "2007"}, {"n": "2006", "v": "2006"}, {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"}, {"n": "2003", "v": "2003"}, {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"}, {"n": "2000", "v": "2000"}]}, {"key": "lang", "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": "by", "name": "排序", "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "21": [{"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": "运动"},{"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": "lang", "name": "语言", "value": [{"n": "全部", "v": ""}, {"n": "英语", "v": "英语"}, {"n": "法语", "v": "法语"}]}, {"key": "by", "name": "排序", "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "22": [{"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": "音乐"},{"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": "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"}, {"n": "2003", "v": "2003"}, {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"}, {"n": "2000", "v": "2000"}]}, {"key": "by", "name": "排序", "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "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": "晚会"}]}, {"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"}, {"n": "2003", "v": "2003"}, {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"}, {"n": "2000", "v": "2000"}]}, {"key": "by", "name": "排序", "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "24": [{"key": "class", "name": "剧情", "value": [{"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": "lang", "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"}, {"n": "2003", "v": "2003"}, {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"}, {"n": "2000", "v": "2000"}]}, {"key": "by", "name": "排序", "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}]}
  184. }
  185. header = {
  186. "origin":"http://www.qifudata.com/",
  187. "User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
  188. "Accept":" */*",
  189. "Accept-Language":"zh-CN,zh;q=0.9,en-US;q=0.3,en;q=0.7",
  190. "Accept-Encoding":"gzip, deflate"
  191. }
  192. def playerContent(self,flag,id,vipFlags):
  193. result = {}
  194. url = 'http://www.qifudata.com/sp/{0}.html'.format(id)
  195. rsp = self.fetch(url)
  196. root = self.html(rsp.text)
  197. scripts = root.xpath("//script/text()")
  198. jo = {}
  199. for script in scripts:
  200. if(script.startswith("var player_")):
  201. target = script[script.index('{'):]
  202. jo = json.loads(target)
  203. break;
  204. parseUrl = ''
  205. # src="(\S+url=)
  206. # playerConfig = self.config['player']
  207. # if jo['from'] in self.config['player']:
  208. # playerConfig = self.config['player'][jo['from']]
  209. # parseUrl = playerConfig['pu'] + jo['url']
  210. scriptUrl = 'http://www.qifudata.com/static/js/playerconfig.js'
  211. scriptRsp = self.fetch(scriptUrl)
  212. scriptRsp = scriptRsp.text
  213. parseUrl = self.regStr(scriptRsp, 'player_list=(.*?),Mac')
  214. if len(parseUrl) > 0:
  215. jo1 = json.loads(parseUrl)
  216. jo1 = jo1[jo['from']]
  217. realUrl = jo['url']
  218. result["parse"] = 1
  219. result["playUrl"] = jo1['parse']
  220. result["url"] = realUrl
  221. result["header"] = json.dumps(self.header)
  222. return result
  223. def isVideoFormat(self,url):
  224. pass
  225. def manualVideoCheck(self):
  226. pass
  227. def localProxy(self,param):
  228. return [200, "video/MP2T", action, ""]