py_kunyu77.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 "77"
  10. def init(self,extend=""):
  11. print("============{0}============".format(extend))
  12. pass
  13. def homeContent(self,filter):
  14. result = {}
  15. url = 'http://api.kunyu77.com/api.php/provide/filter'
  16. rsp = self.fetch(url,headers=self.header)
  17. jo = json.loads(rsp.text)
  18. classes = []
  19. jData = jo['data']
  20. for cKey in jData.keys():
  21. classes.append({
  22. 'type_name':jData[cKey][0]['cat'],
  23. 'type_id':cKey
  24. })
  25. result['class'] = classes
  26. if(filter):
  27. result['filters'] = self.config['filter']
  28. return result
  29. def homeVideoContent(self):
  30. url = 'http://api.kunyu77.com/api.php/provide/homeBlock?type_id=0'
  31. rsp = self.fetch(url,headers=self.header)
  32. jo = json.loads(rsp.text)
  33. blockList = jo['data']['blocks']
  34. videos = []
  35. for block in blockList:
  36. vodList = block['contents']
  37. for vod in vodList:
  38. videos.append({
  39. "vod_id":vod['id'],
  40. "vod_name":vod['title'],
  41. "vod_pic":vod['videoCover'],
  42. "vod_remarks":vod['msg']
  43. })
  44. result = {
  45. 'list':videos
  46. }
  47. return result
  48. def categoryContent(self,tid,pg,filter,extend):
  49. result = {}
  50. if 'type_id' not in extend.keys():
  51. extend['type_id'] = tid
  52. extend['pagenum'] = pg
  53. filterParams = ["type_id", "pagenum"]
  54. params = ["", ""]
  55. for idx in range(len(filterParams)):
  56. fp = filterParams[idx]
  57. if fp in extend.keys():
  58. params[idx] = '&'+filterParams[idx]+'='+extend[fp]
  59. suffix = ''.join(params)
  60. url = 'http://api.kunyu77.com/api.php/provide/searchFilter?pagesize=24{0}'.format(suffix)
  61. rsp = self.fetch(url,headers=self.header)
  62. jo = json.loads(rsp.text)
  63. vodList = jo['data']['result']
  64. videos = []
  65. for vod in vodList:
  66. videos.append({
  67. "vod_id":vod['id'],
  68. "vod_name":vod['title'],
  69. "vod_pic":vod['videoCover'],
  70. "vod_remarks":vod['msg']
  71. })
  72. result['list'] = videos
  73. result['page'] = pg
  74. result['pagecount'] = 9999
  75. result['limit'] = 90
  76. result['total'] = 999999
  77. return result
  78. def detailContent(self,array):
  79. tid = array[0]
  80. url = 'http://api.kunyu77.com/api.php/provide/videoDetail?devid=453CA5D864457C7DB4D0EAA93DE96E66&package=com.sevenVideo.app.android&version=1.8.7&ids={0}'.format(tid)
  81. rsp = self.fetch(url,headers=self.header)
  82. jo = json.loads(rsp.text)
  83. node = jo['data']
  84. vod = {
  85. "vod_id":node['id'],
  86. "vod_name":node['videoName'],
  87. "vod_pic":node['videoCover'],
  88. "type_name":node['subCategory'],
  89. "vod_year":node['year'],
  90. "vod_area":node['area'],
  91. "vod_remarks":node['msg'],
  92. "vod_actor":node['actor'],
  93. "vod_director":node['director'],
  94. "vod_content":node['brief'].strip()
  95. }
  96. listUrl = 'http://api.kunyu77.com/api.php/provide/videoPlaylist?devid=453CA5D864457C7DB4D0EAA93DE96E66&package=com.sevenVideo.app.android&version=1.8.7&ids={0}'.format(tid)
  97. listRsp = self.fetch(listUrl,headers=self.header)
  98. listJo = json.loads(listRsp.text)
  99. playMap = {}
  100. episodes = listJo['data']['episodes']
  101. for ep in episodes:
  102. playurls = ep['playurls']
  103. for playurl in playurls:
  104. source = playurl['playfrom']
  105. if source not in playMap.keys():
  106. playMap[source] = []
  107. playMap[source].append(playurl['title'].strip() + '$' + playurl['playurl'])
  108. playFrom = []
  109. playList = []
  110. for key in playMap.keys():
  111. playFrom.append(key)
  112. playList.append('#'.join(playMap[key]))
  113. vod_play_from = '$$$'
  114. vod_play_from = vod_play_from.join(playFrom)
  115. vod_play_url = '$$$'
  116. vod_play_url = vod_play_url.join(playList)
  117. vod['vod_play_from'] = vod_play_from
  118. vod['vod_play_url'] = vod_play_url
  119. result = {
  120. 'list':[
  121. vod
  122. ]
  123. }
  124. return result
  125. def searchContent(self,key,quick):
  126. url = 'http://api.kunyu77.com/api.php/provide/searchVideo?searchName={0}'.format(key)
  127. rsp = self.fetch(url,headers=self.header)
  128. jo = json.loads(rsp.text)
  129. vodList = jo['data']
  130. videos = []
  131. for vod in vodList:
  132. videos.append({
  133. "vod_id":vod['id'],
  134. "vod_name":vod['videoName'],
  135. "vod_pic":vod['videoCover'],
  136. "vod_remarks":vod['msg']
  137. })
  138. result = {
  139. 'list':videos
  140. }
  141. return result
  142. config = {
  143. "player": {},
  144. "filter": {}
  145. }
  146. header = {
  147. "User-Agent":"Dalvik/2.1.0"
  148. }
  149. def playerContent(self,flag,id,vipFlags):
  150. result = {}
  151. url = 'http://api.kunyu77.com/api.php/provide/parserUrl?url={0}'.format(id)
  152. jo = self.fetch(url,headers=self.header).json()
  153. result = {
  154. 'parse':0,
  155. 'jx':0,
  156. 'playUrl':'',
  157. 'url':id,
  158. 'header':''
  159. }
  160. if flag in vipFlags:
  161. result['parse'] = 1
  162. result['jx'] = 1
  163. return result
  164. def isVideoFormat(self,url):
  165. pass
  166. def manualVideoCheck(self):
  167. pass
  168. def localProxy(self,param):
  169. return [200, "video/MP2T", action, ""]