py_ddys.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #coding=utf-8
  2. #!/usr/bin/python
  3. import sys
  4. sys.path.append('..')
  5. from base.spider import Spider
  6. import re
  7. import math
  8. import json
  9. class Spider(Spider):
  10. def getName(self):
  11. return "企鹅体育"
  12. def init(self,extend=""):
  13. pass
  14. def isVideoFormat(self,url):
  15. pass
  16. def manualVideoCheck(self):
  17. pass
  18. def homeContent(self,filter):
  19. result = {}
  20. cateManual = {
  21. "全部": ""
  22. }
  23. classes = []
  24. for k in cateManual:
  25. classes.append({
  26. 'type_name': k,
  27. 'type_id': cateManual[k]
  28. })
  29. result['class'] = classes
  30. if (filter):
  31. result['filters'] = self.config['filter']
  32. return result
  33. def homeVideoContent(self):
  34. result = {}
  35. return result
  36. def categoryContent(self,tid,pg,filter,extend):
  37. result = {}
  38. url = 'https://m.jrskbs.com'
  39. rsp = self.fetch(url)
  40. html = self.html(rsp.text)
  41. aList = html.xpath("//div[contains(@class, 'contentList')]/a")
  42. videos = []
  43. numvL = len(aList)
  44. pgc = math.ceil(numvL/15)
  45. for a in aList:
  46. aid = a.xpath("./@href")[0]
  47. aid = self.regStr(reg=r'/live/(.*?).html', src=aid)
  48. img = a.xpath(".//div[@class='contentLeft']/p/img/@src")[0]
  49. home = a.xpath(".//div[@class='contentLeft']/p[@class='false false']/text()")[0]
  50. away = a.xpath(".//div[@class='contentRight']/p[@class='false false']/text()")[0]
  51. infoArray = a.xpath(".//div[@class='contentCenter']/p")
  52. remark = ''
  53. for info in infoArray:
  54. content = info.xpath('string(.)').replace(' ','')
  55. remark = remark + '|' + content
  56. videos.append({
  57. "vod_id": aid,
  58. "vod_name": home + 'vs' + away,
  59. "vod_pic": img,
  60. "vod_remarks": remark.strip('|')
  61. })
  62. result['list'] = videos
  63. result['page'] = pg
  64. result['pagecount'] = pgc
  65. result['limit'] = numvL
  66. result['total'] = numvL
  67. return result
  68. def detailContent(self,array):
  69. aid = array[0]
  70. url = 'https://ddys.tv/{0}/'.format(aid)
  71. rsp = self.fetch(url)
  72. self.cookies = rsp.cookies
  73. self.url = url
  74. html = self.html(rsp.text)
  75. title = html.xpath("//div[@class='title']/a/text()")[0]
  76. infoList = html.xpath("//div[@class='abstract']/text()")
  77. cont = infoList[-1].replace('简介: ','').replace('\u3000',' ')
  78. pic = html.xpath("//div[@class='post']/img/@src")[0]
  79. remark = html.xpath("//div[@class='entry']/font/text()")[0]
  80. for info in infoList:
  81. if info.startswith('导演'):
  82. dir = info.replace('导演: ','').strip()
  83. if info.startswith('演员'):
  84. act = info.replace('演员: ','').replace(' / ','').strip()
  85. if info.startswith('类型'):
  86. typeName = info.replace('类型: ','').replace(' ','')
  87. if info.startswith('制片国家/地区'):
  88. area = info.replace('制片国家/地区: ','').replace(' ','')
  89. if info.startswith('年份'):
  90. year = info.replace('年份: ','').replace(' ','')
  91. vod = {
  92. "vod_id": aid,
  93. "vod_name": title,
  94. "vod_pic": pic,
  95. "type_name": typeName,
  96. "vod_year": year,
  97. "vod_area": area,
  98. "vod_remarks": remark,
  99. "vod_actor": act,
  100. "vod_director": dir,
  101. "vod_content": cont
  102. }
  103. rootList = html.xpath("//script[@class='wp-playlist-script']/text()")[0]
  104. jo = json.loads(rootList.replace(' ', '').replace('\n', ''))['tracks']
  105. playUrl = ''
  106. for tmpJo in jo:
  107. purl = tmpJo['src1']
  108. name = tmpJo['caption']
  109. playUrl = playUrl + '{0}${1}#'.format(name, purl)
  110. vod['vod_play_from'] = '低端影视'
  111. vod['vod_play_url'] = playUrl
  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. headers = {
  124. "referer": self.url,
  125. "sec-fetch-dest": "empty",
  126. "sec-fetch-mode": "cors",
  127. "sec-fetch-site": "same-origin",
  128. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"
  129. }
  130. url = 'https://ddys.tv/getvddr/video?id={0}&dim=1080P&type=mix'.format(id)
  131. rsp = self.fetch(url,cookies=self.cookies,headers=headers)
  132. jo = json.loads(rsp.text)
  133. url = jo['url']
  134. result["parse"] = 0
  135. result["playUrl"] = ''
  136. result["url"] = url
  137. result["header"] = ''
  138. return result
  139. config = {
  140. "player": {},
  141. "filter": {}
  142. }
  143. header = {}
  144. def localProxy(self,param):
  145. action = {
  146. 'url':'',
  147. 'header':'',
  148. 'param':'',
  149. 'type':'string',
  150. 'after':''
  151. }
  152. return [200, "video/MP2T", action, ""]