py_cokemv.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. import requests
  8. import base64
  9. class Spider(Spider): # 元类 默认的元类 type
  10. def getName(self):
  11. return "Cokemv"
  12. def init(self,extend=""):
  13. print("============{0}============".format(extend))
  14. pass
  15. def homeContent(self,filter):
  16. result = {}
  17. cateManual = {
  18. "抖音电影":"5",
  19. "电视剧":"2",
  20. "电影":"1",
  21. "动漫":"4",
  22. "综艺":"3"
  23. }
  24. classes = []
  25. for k in cateManual:
  26. classes.append({
  27. 'type_name':k,
  28. 'type_id':cateManual[k]
  29. })
  30. result['class'] = classes
  31. if(filter):
  32. result['filters'] = self.config['filter']
  33. return result
  34. def homeVideoContent(self):
  35. rsp = self.fetch("https://cokemv.me/")
  36. root = self.html(rsp.text)
  37. aList = root.xpath("//div[@class='main']//div[contains(@class,'module-items')]/a")
  38. videos = []
  39. for a in aList:
  40. name = a.xpath('./@title')[0]
  41. pic = a.xpath('.//img/@data-original')[0]
  42. mark = a.xpath(".//div[@class='module-item-note']/text()")[0]
  43. sid = a.xpath("./@href")[0]
  44. sid = self.regStr(sid,"/voddetail/(\\S+).html")
  45. videos.append({
  46. "vod_id":sid,
  47. "vod_name":name,
  48. "vod_pic":pic,
  49. "vod_remarks":mark
  50. })
  51. result = {
  52. 'list':videos
  53. }
  54. return result
  55. def categoryContent(self,tid,pg,filter,extend):
  56. result = {}
  57. urlParams = ["", "", "", "", "", "", "", "", "", "", "", ""]
  58. urlParams[0] = tid
  59. urlParams[8] = pg
  60. for key in extend:
  61. urlParams[int(key)] = extend[key]
  62. params = '-'.join(urlParams)
  63. url = 'https://cokemv.me/vodshow/{0}.html'.format(params)
  64. rsp = self.fetch(url)
  65. root = self.html(rsp.text)
  66. aList = root.xpath("//div[contains(@class, 'module-items')]/a")
  67. videos = []
  68. for a in aList:
  69. name = a.xpath('./@title')[0]
  70. pic = a.xpath('.//img/@data-original')[0]
  71. mark = a.xpath(".//div[contains(@class,'module-item-note')]/text()")[0]
  72. sid = a.xpath("./@href")[0]
  73. sid = self.regStr(sid,"/voddetail/(\\d+).html")
  74. videos.append({
  75. "vod_id":sid,
  76. "vod_name":name,
  77. "vod_pic":pic,
  78. "vod_remarks":mark
  79. })
  80. result['list'] = videos
  81. result['page'] = pg
  82. result['pagecount'] = 9999
  83. result['limit'] = 90
  84. result['total'] = 999999
  85. return result
  86. def detailContent(self,array):
  87. tid = array[0]
  88. url = 'https://cokemv.me/voddetail/{0}.html'.format(tid)
  89. rsp = self.fetch(url)
  90. root = self.html(rsp.text)
  91. divContent = root.xpath("//div[@class='module-info-main']")[0]
  92. title = divContent.xpath('.//h1/text()')[0]
  93. year = divContent.xpath('.//div/div/div[1]/a/text()')[0]
  94. area = divContent.xpath('.//div/div/div[2]/a/text()')[0]
  95. typ = divContent.xpath('.//div/div/div[3]/a/text()')
  96. type = ', '.join(typ)
  97. dir = divContent.xpath(".//div[@class='module-info-items']/div[2]/div[1]/a/text()")[0]
  98. act = divContent.xpath(".//div[@class='module-info-items']/div[4]/div/a/text()")
  99. actor = ', '.join(act)
  100. pic = root.xpath(".//div[@class='module-poster-bg']//img/@data-original")[0]
  101. detail = root.xpath(".//div[@class='module-info-introduction-content']/p/text()")[0]
  102. vod = {
  103. "vod_id":tid,
  104. "vod_name":title,
  105. "vod_pic":pic,
  106. "type_name":type,
  107. "vod_year":year,
  108. "vod_area":area,
  109. "vod_remarks":"",
  110. "vod_actor":actor,
  111. "vod_director":dir,
  112. "vod_content":detail
  113. }
  114. vod_play_from = '$$$'
  115. playFrom = []
  116. vodHeader = root.xpath("//div[@class='module-tab-item tab-item']/span/text()")
  117. for v in vodHeader:
  118. playFrom.append(v)
  119. vod_play_from = vod_play_from.join(playFrom)
  120. vod_play_url = '$$$'
  121. playList = []
  122. vodList = root.xpath("//div[@class='module-play-list']")
  123. for vl in vodList:
  124. vodItems = []
  125. aList = vl.xpath('./div/a')
  126. for tA in aList:
  127. href = tA.xpath('./@href')[0]
  128. name = tA.xpath('.//span/text()')[0]
  129. tId = self.regStr(href,'/vodplay/(\\S+).html')
  130. vodItems.append(name + "$" + tId)
  131. joinStr = '#'
  132. joinStr = joinStr.join(vodItems)
  133. playList.append(joinStr)
  134. vod_play_url = vod_play_url.join(playList)
  135. vod['vod_play_from'] = vod_play_from
  136. vod['vod_play_url'] = vod_play_url
  137. result = {
  138. 'list':[
  139. vod
  140. ]
  141. }
  142. return result
  143. def verifyCode(self, url):
  144. retry = 5
  145. header = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"}
  146. while retry:
  147. try:
  148. session = requests.session()
  149. img = session.get('https://cokemv.me/index.php/verify/index.html?', headers=header).content
  150. code = session.post('https://api.nn.ci/ocr/b64/text', data=base64.b64encode(img).decode()).text
  151. res = session.post(url=f"https://cokemv.me/index.php/ajax/verify_check?type=search&verify={code}", headers=header).json()
  152. if res["msg"] == "ok":
  153. return session
  154. except Exception as e:
  155. print(e)
  156. finally:
  157. retry = retry - 1
  158. def searchContent(self, key, quick):
  159. url = 'https://cokemv.me/vodsearch/-------------.html?wd={0}'.format(key)
  160. session = self.verifyCode(url)
  161. rsp = session.get(url)
  162. root = self.html(rsp.text)
  163. vodList = root.xpath("//div[@class='module-card-item module-item']/a[@class='module-card-item-poster']")
  164. videos = []
  165. for vod in vodList:
  166. name = vod.xpath(".//img/@alt")[0]
  167. pic = vod.xpath(".//img/@data-original")[0]
  168. mark = vod.xpath(".//div[@class='module-item-note']/text()")[0]
  169. sid = vod.xpath("./@href")[0]
  170. sid = self.regStr(sid,"/voddetail/(\\S+).html")
  171. videos.append({
  172. "vod_id":sid,
  173. "vod_name":name,
  174. "vod_pic":pic,
  175. "vod_remarks":mark
  176. })
  177. result = {
  178. 'list':videos
  179. }
  180. return result
  181. config = {
  182. "player": {"cokemv0555":{"show":"COKEMV","des":"","ps":"0","parse":""},"cokeqie01":{"show":"極速路線","des":"","ps":"0","parse":""},"xin":{"show":"高速路線","des":"","ps":"0","parse":""},"90mm":{"show":"COKEMV(測試)","des":"","ps":"0","parse":""},"toutiao":{"show":"海外路線","des":"","ps":"0","parse":""},"age01":{"show":"動漫一線","des":"","ps":"0","parse":""},"mahua":{"show":"海外(禁國內)","des":"","ps":"0","parse":""},"age02":{"show":"動漫二線","des":"","ps":"0","parse":""}},
  183. "filter": {"5":[{"key":3,"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":4,"name":"语言","value":[{"n":"全部","v":""},{"n":"國語","v":"國語"},{"n":"英語","v":"英語"},{"n":"粵語","v":"粵語"},{"n":" 閩南語","v":"閩南語"},{"n":"韓語","v":"韓語"},{"n":"日語","v":"日語"},{"n":"法語","v":"法語"},{"n":"德語","v":"德語"},{"n":"其它","v":"其它"}]},{"key":11,"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"}]},{"key":5,"name":"字母","value":[{"n":"字母","v":""},{"n":"A","v":"A"},{"n":"B","v":"B"},{"n":"C","v":"C"},{"n":"D","v":"D"},{"n":"E","v":"E"},{"n":"F","v":"F"},{"n":"G","v":"G"},{"n":"H","v":"H"},{"n":"I","v":"I"},{"n":"J","v":"J"},{"n":"K","v":"K"},{"n":"L","v":"L"},{"n":"M","v":"M"},{"n":"N","v":"N"},{"n":"O","v":"O"},{"n":"P","v":"P"},{"n":"Q","v":"Q"},{"n":"R","v":"R"},{"n":"S","v":"S"},{"n":"T","v":"T"},{"n":"U","v":"U"},{"n":"V","v":"V"},{"n":"W","v":"W"},{"n":"X","v":"X"},{"n":"Y","v":"Y"},{"n":"Z","v":"Z"},{"n":"0-9","v":"0-9"}]},{"key":2,"name":"排序","value":[{"n":"时间排序","v":"time"},{"n":"人气排序","v":"hits"},{"n":"评分排序","v":"score"}]}],"2":[{"key":0,"name":"类型","value":[{"n":"全部","v":"2"},{"n":"大陸劇","v":"13"},{"n":"香港劇","v":"14"},{"n":"韓國劇","v":"15"},{"n":"歐美劇","v":"16"},{"n":"日本劇","v":"20"},{"n":"台灣劇","v":"21"},{"n":"泰國劇","v":"22"}]},{"key":1,"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":"其他"}]},{"key":4,"name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"其它","v":"其它"}]},{"key":11,"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"}]},{"key":5,"name":"字母","value":[{"n":"字母","v":""},{"n":"A","v":"A"},{"n":"B","v":"B"},{"n":"C","v":"C"},{"n":"D","v":"D"},{"n":"E","v":"E"},{"n":"F","v":"F"},{"n":"G","v":"G"},{"n":"H","v":"H"},{"n":"I","v":"I"},{"n":"J","v":"J"},{"n":"K","v":"K"},{"n":"L","v":"L"},{"n":"M","v":"M"},{"n":"N","v":"N"},{"n":"O","v":"O"},{"n":"P","v":"P"},{"n":"Q","v":"Q"},{"n":"R","v":"R"},{"n":"S","v":"S"},{"n":"T","v":"T"},{"n":"U","v":"U"},{"n":"V","v":"V"},{"n":"W","v":"W"},{"n":"X","v":"X"},{"n":"Y","v":"Y"},{"n":"Z","v":"Z"},{"n":"0-9","v":"0-9"}]},{"key":2,"name":"排序","value":[{"n":"时间排序","v":"time"},{"n":"人气排序","v":"hits"},{"n":"评分排序","v":"score"}]}],"1":[{"key":0,"name":"类型","value":[{"n":"全部","v":"1"},{"n":"動作片","v":"6"},{"n":"喜劇片","v":"7"},{"n":"愛情片","v":"8"},{"n":"科幻片","v":"9"},{"n":"恐怖片","v":"10"},{"n":"劇情片","v":"11"},{"n":"戰爭片","v":"12"},{"n":"犯罪片","v":"23"},{"n":"奇幻片","v":"24"},{"n":"懸疑片","v":"25"},{"n":"記錄片","v":"27"}]},{"key":1,"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":"其他"}]},{"key":4,"name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"法语","v":"法语"},{"n":"德语","v":"德语"},{"n":"其它","v":"其它"}]},{"key":11,"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"}]},{"key":5,"name":"字母","value":[{"n":"字母","v":""},{"n":"A","v":"A"},{"n":"B","v":"B"},{"n":"C","v":"C"},{"n":"D","v":"D"},{"n":"E","v":"E"},{"n":"F","v":"F"},{"n":"G","v":"G"},{"n":"H","v":"H"},{"n":"I","v":"I"},{"n":"J","v":"J"},{"n":"K","v":"K"},{"n":"L","v":"L"},{"n":"M","v":"M"},{"n":"N","v":"N"},{"n":"O","v":"O"},{"n":"P","v":"P"},{"n":"Q","v":"Q"},{"n":"R","v":"R"},{"n":"S","v":"S"},{"n":"T","v":"T"},{"n":"U","v":"U"},{"n":"V","v":"V"},{"n":"W","v":"W"},{"n":"X","v":"X"},{"n":"Y","v":"Y"},{"n":"Z","v":"Z"},{"n":"0-9","v":"0-9"}]},{"key":2,"name":"排序","value":[{"n":"时间排序","v":"time"},{"n":"人气排序","v":"hits"},{"n":"评分排序","v":"score"}]}],"4":[{"key":0,"name":"类型","value":[{"n":"全部","v":"4"},{"n":"動畫電影","v":"41"}]},{"key":1,"name":"地区","value":[{"n":"全部","v":""},{"n":"中国大陆","v":"中国大陆"},{"n":"日本","v":"日本"},{"n":"美国","v":"美国"}]},{"key":4,"name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"其它","v":"其它"}]},{"key":11,"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"}]},{"key":5,"name":"字母","value":[{"n":"字母","v":""},{"n":"A","v":"A"},{"n":"B","v":"B"},{"n":"C","v":"C"},{"n":"D","v":"D"},{"n":"E","v":"E"},{"n":"F","v":"F"},{"n":"G","v":"G"},{"n":"H","v":"H"},{"n":"I","v":"I"},{"n":"J","v":"J"},{"n":"K","v":"K"},{"n":"L","v":"L"},{"n":"M","v":"M"},{"n":"N","v":"N"},{"n":"O","v":"O"},{"n":"P","v":"P"},{"n":"Q","v":"Q"},{"n":"R","v":"R"},{"n":"S","v":"S"},{"n":"T","v":"T"},{"n":"U","v":"U"},{"n":"V","v":"V"},{"n":"W","v":"W"},{"n":"X","v":"X"},{"n":"Y","v":"Y"},{"n":"Z","v":"Z"},{"n":"0-9","v":"0-9"}]},{"key":2,"name":"排序","value":[{"n":"时间排序","v":"time"},{"n":"人气排序","v":"hits"},{"n":"评分排序","v":"score"}]}],"3":[{"key":1,"name":"地区","value":[{"n":"全部","v":""},{"n":"中国大陆","v":"中国大陆"},{"n":"韩国","v":" 韩国"}]},{"key":4,"name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩 语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"其它","v":"其它"}]},{"key":11,"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"}]},{"key":5,"name":"字母","value":[{"n":"字母","v":""},{"n":"A","v":"A"},{"n":"B","v":"B"},{"n":"C","v":"C"},{"n":"D","v":"D"},{"n":"E","v":"E"},{"n":"F","v":"F"},{"n":"G","v":"G"},{"n":"H","v":"H"},{"n":"I","v":"I"},{"n":"J","v":"J"},{"n":"K","v":"K"},{"n":"L","v":"L"},{"n":"M","v":"M"},{"n":"N","v":"N"},{"n":"O","v":"O"},{"n":"P","v":"P"},{"n":"Q","v":"Q"},{"n":"R","v":"R"},{"n":"S","v":"S"},{"n":"T","v":"T"},{"n":"U","v":"U"},{"n":"V","v":"V"},{"n":"W","v":"W"},{"n":"X","v":"X"},{"n":"Y","v":"Y"},{"n":"Z","v":"Z"},{"n":"0-9","v":"0-9"}]},{"key":2,"name":"排序","value":[{"n":" 时间排序","v":"time"},{"n":"人气排序","v":"hits"},{"n":"评分排序","v":"score"}]}]}
  184. }
  185. header = {
  186. "origin":"https://cokemv.me",
  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. url = 'https://cokemv.me/vodplay/{0}.html'.format(id)
  194. rsp = self.fetch(url)
  195. root = self.html(rsp.text)
  196. scripts = root.xpath("//script/text()")
  197. jo = {}
  198. result = {}
  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. playerConfig = self.config['player']
  206. if jo['from'] in self.config['player']:
  207. playerConfig = self.config['player'][jo['from']]
  208. videoUrl = jo['url']
  209. playerUrl = playerConfig['parse']
  210. result["parse"] = playerConfig['ps']
  211. result["playUrl"] = playerUrl
  212. result["url"] = videoUrl
  213. result["header"] = json.dumps(self.header)
  214. return result
  215. def isVideoFormat(self,url):
  216. pass
  217. def manualVideoCheck(self):
  218. pass
  219. def localProxy(self,param):
  220. return [200, "video/MP2T", action, ""]