麦豆TV.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 json
  8. class Spider(Spider): # 元类 默认的元类 type
  9. def getName(self):
  10. return "麦豆TV"
  11. def init(self, extend=""):
  12. print("============{0}============".format(extend))
  13. pass
  14. def homeContent(self, filter):
  15. result = {}
  16. cateManual = {
  17. "国产": "guocanju",
  18. "港台": "gangtai",
  19. "欧美": "en",
  20. "韩剧": "hanju",
  21. "日剧": "riju",
  22. "泰剧": "taiju",
  23. "集剧": "tv",
  24. "电影": "movie",
  25. "动漫": "ac",
  26. "综艺": "zongyi"
  27. }
  28. classes = []
  29. for k in cateManual:
  30. classes.append({
  31. 'type_name': k,
  32. 'type_id': cateManual[k]
  33. })
  34. result['class'] = classes
  35. if (filter):
  36. result['filters'] = self.config['filter']
  37. return result
  38. def homeVideoContent(self):
  39. result = {
  40. 'list': []
  41. }
  42. return result
  43. def categoryContent(self, tid, pg, filter, extend):
  44. result = {}
  45. url = 'https://www.mdoutv.com/movie_bt_series/{0}/page/{1}'.format(tid, pg)
  46. rsp = self.fetch(url)
  47. root = self.html(rsp.text)
  48. aList = root.xpath("//li/a[@target='_blank']")
  49. videos = []
  50. for a in aList:
  51. name = a.xpath('./img/@alt')
  52. pic = a.xpath('./img/@data-original')
  53. mark = a.xpath('./div/span/text()')
  54. sid = a.xpath('./@href')
  55. videos.append({
  56. "vod_id": ''.join(sid),
  57. "vod_name": ''.join(name),
  58. "vod_pic": ''.join(pic),
  59. "vod_remarks": ''.join(mark)
  60. })
  61. result['list'] = videos
  62. result['page'] = pg
  63. result['pagecount'] = 9999
  64. result['limit'] = 90
  65. result['total'] = 999999
  66. return result
  67. def detailContent(self, array):
  68. tid = array[0]
  69. url = '{0}'.format(tid)
  70. 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"}
  71. rsp = self.fetch(url,)
  72. root = self.html(rsp.text)
  73. title = root.xpath("//div[@class='mi_ne_kd dypre']/div[2]/div/h1/text()")[0]
  74. pic = root.xpath("//div[@class='mi_ne_kd dypre']/div[1]/img/@src")[0]
  75. detail = root.xpath("//div[@class='yp_context']/p/text()")[0]
  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 = root.xpath("//ul[@class='moviedteail_list']/li")
  89. for info in infoArray:
  90. content = info.xpath('string(.)')
  91. if content.startswith('地区'):
  92. vod['vod_area'] = content.replace("地区:", "")
  93. if content.startswith('年份'):
  94. vod['vod_year'] = content.replace("年份:", "")
  95. if content.startswith('主演'):
  96. vod['vod_actor'] = content.replace("主演:", "")
  97. if content.startswith('导演'):
  98. vod['vod_director'] = content.replace("导演:", "")
  99. vod_play_from = '$$$'
  100. playFrom = []
  101. vod_play_url = '$$$'
  102. playList = []
  103. vodHeader = root.xpath("//div[@class='paly_list_btn']/a")
  104. for v in vodHeader:
  105. playFrom.append(v.xpath('./text()')[0])
  106. playList.append(v.xpath('./text()')[0] + '$' +v.xpath('./@href')[0] + '#')
  107. vod_play_url = vod_play_url.join(playList)
  108. vod_play_from = vod_play_from.join(playFrom)
  109. vod['vod_play_from'] = vod_play_from
  110. vod['vod_play_url'] = vod_play_url
  111. result = {
  112. 'list':[
  113. vod
  114. ]
  115. }
  116. return result
  117. def searchContent(self, key, quick):
  118. result = {}
  119. return result
  120. def playerContent(self, flag, id, vipFlags):
  121. result = {}
  122. rsp = self.fetch(id)
  123. root = self.html(rsp.text)
  124. vl = root.xpath("//div[@class='xilubg xla']/a")[0]
  125. vurl = vl.xpath("./@vurl")[0]
  126. vurl1 = vurl.split('?url=')
  127. vurl = vurl1[1]
  128. url = 'https://jxdp.codermart.net/jxplayer.php?v={0}'.format(vurl)
  129. rsp = self.fetch(url)
  130. root = self.html(rsp.text)
  131. si = root.xpath("//script[@type='text/javascript']/text()")
  132. for info in si:
  133. if info.startswith('\nvar canPlay'):
  134. si1 = info
  135. si1 = self.regStr(si1,"var urls = \"(\\S+)\";")
  136. break
  137. result["parse"] = 0
  138. result["playUrl"] = ''
  139. result["url"] = si1
  140. result["header"] = ''
  141. return result
  142. config = {
  143. "player": {},
  144. "filter": {}
  145. }
  146. header = {}
  147. def isVideoFormat(self, url):
  148. pass
  149. def manualVideoCheck(self):
  150. pass
  151. def localProxy(self, param):
  152. return [200, "video/MP2T", action, ""]