抖音直播.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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):
  8. def getName(self):
  9. return "抖音"
  10. def init(self,extend=""):
  11. pass
  12. def isVideoFormat(self,url):
  13. pass
  14. def manualVideoCheck(self):
  15. pass
  16. def homeContent(self,filter):
  17. result = {}
  18. cateManual = {
  19. "抖音": "douyin"
  20. }
  21. classes = []
  22. for k in cateManual:
  23. classes.append({
  24. 'type_name': k,
  25. 'type_id': cateManual[k]
  26. })
  27. result['class'] = classes
  28. if (filter):
  29. result['filters'] = self.config['filter']
  30. return result
  31. def homeVideoContent(self):
  32. result = {}
  33. url = 'http://yj1211.work:8013/api/live/getRecommendByPlatform?platform=douyin&size=20&page=1'.format()
  34. rsp = self.fetch(url)
  35. content = rsp.text
  36. jo = json.loads(content)
  37. videos = []
  38. vodList = jo['data']
  39. for vod in vodList:
  40. aid = (vod['roomId']).strip()
  41. title = vod['roomName'].strip()
  42. img = vod['roomPic'].strip()
  43. remark = (vod['ownerName']).strip()
  44. videos.append({
  45. "vod_id": aid,
  46. "vod_name": title,
  47. "vod_pic": img,
  48. "vod_remarks": remark
  49. })
  50. result['list'] = videos
  51. return result
  52. def categoryContent(self,tid,pg,filter,extend):
  53. result = {}
  54. url = 'http://yj1211.work:8013/api/live/getRecommendByPlatform?platform={0}&size=20&page={1}'.format(tid, pg)
  55. rsp = self.fetch(url)
  56. content = rsp.text
  57. jo = json.loads(content)
  58. videos = []
  59. vodList = jo['data']
  60. for vod in vodList:
  61. aid = (vod['roomId']).strip()
  62. title = vod['roomName'].strip()
  63. img = vod['roomPic'].strip()
  64. remark = (vod['ownerName']).strip()
  65. videos.append({
  66. "vod_id": aid,
  67. "vod_name": title,
  68. "vod_pic": img,
  69. "vod_remarks": remark
  70. })
  71. result['list'] = videos
  72. result['page'] = pg
  73. result['pagecount'] = 9999
  74. result['limit'] = 90
  75. result['total'] = 999999
  76. return result
  77. def detailContent(self,array):
  78. aid = array[0]
  79. url = "http://live.yj1211.work/api/live/getRoomInfo?platform=douyin&roomId={0}".format(aid)
  80. rsp = self.fetch(url)
  81. jRoot = json.loads(rsp.text)
  82. jo = jRoot['data']
  83. title = jo['roomName']
  84. pic = jo['roomPic']
  85. desc = str(jo['online'])
  86. dire = jo['ownerName']
  87. typeName = jo['categoryName']
  88. remark = jo['categoryName']
  89. vod = {
  90. "vod_id": aid,
  91. "vod_name": title,
  92. "vod_pic": pic,
  93. "type_name": typeName,
  94. "vod_year": "",
  95. "vod_area": "",
  96. "vod_remarks": remark,
  97. "vod_actor": '在线人数:' + desc,
  98. "vod_director": dire,
  99. "vod_content": ""
  100. }
  101. playUrl = '原画' + '${0}#'.format(aid)
  102. vod['vod_play_from'] = '抖音直播'
  103. vod['vod_play_url'] = playUrl
  104. result = {
  105. 'list': [
  106. vod
  107. ]
  108. }
  109. return result
  110. def searchContent(self,key,quick):
  111. result = {}
  112. return result
  113. def playerContent(self,flag,id,vipFlags):
  114. result = {}
  115. url = 'http://yj1211.work:8013/api/live/getRealUrlMultiSource?platform=douyin&roomId={0}'.format(id)
  116. rsp = self.fetch(url)
  117. jRoot = json.loads(rsp.text)
  118. jo = jRoot['data']['flv'][0]
  119. ja = jo['playUrl']
  120. url = ja
  121. result["parse"] = 0
  122. result["playUrl"] = ''
  123. result["url"] = url
  124. result["header"] = {
  125. "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"
  126. }
  127. result["contentType"] = 'video/x-flv'
  128. return result
  129. config = {
  130. "player": {},
  131. "filter": {}
  132. }
  133. header = {}
  134. config = {
  135. "player": {},
  136. "filter": {}
  137. }
  138. header = {}
  139. def localProxy(self,param):
  140. action = {
  141. 'url':'',
  142. 'header':'',
  143. 'param':'',
  144. 'type':'string',
  145. 'after':''
  146. }
  147. return [200, "video/MP2T", action, ""]