py_mdoutv.py 5.3 KB

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