2
0

py_bilibili3.py 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476
  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. import requests
  8. from requests import session, utils
  9. import os
  10. import time
  11. import base64
  12. from time import strftime
  13. from time import gmtime
  14. class Spider(Spider): # 元类 默认的元类 type
  15. box_video_type = ''
  16. vod_area='bilidanmu'
  17. def getName(self):
  18. return "哔哩3_带直播"
  19. def __init__(self):
  20. self.getCookie()
  21. url = 'http://api.bilibili.com/x/v3/fav/folder/created/list-all?up_mid=%s&jsonp=jsonp' % (self.userid)
  22. rsp = self.fetch(url, cookies=self.cookies)
  23. content = rsp.text
  24. jo = json.loads(content)
  25. fav_list=[]
  26. if jo['code'] == 0:
  27. for fav in jo['data'].get('list'):
  28. fav_dict = {'n':fav['title'].replace("<em class=\"keyword\">", "").replace("</em>", "").replace("&quot;", '"').strip() ,'v':fav['id']}
  29. fav_list.append(fav_dict)
  30. if self.config["filter"].get('收藏夹'):
  31. for i in self.config["filter"].get('收藏夹'):
  32. if i['key']=='mlid':
  33. i['value']=fav_list
  34. def init(self, extend=""):
  35. print("============{0}============".format(extend))
  36. pass
  37. def isVideoFormat(self, url):
  38. pass
  39. def second_to_time(self,a):
  40. #将秒数转化为 时分秒的格式
  41. if a < 3600:
  42. return time.strftime("%M:%S", time.gmtime(a))
  43. else:
  44. return time.strftime("%H:%M:%S", time.gmtime(a))
  45. def manualVideoCheck(self):
  46. pass
  47. #用户userid
  48. userid=''
  49. def get_live_userInfo(self,uid):
  50. url = 'https://api.live.bilibili.com/live_user/v1/Master/info?uid=%s'%uid
  51. rsp = self.fetch(url, cookies=self.cookies)
  52. content = rsp.text
  53. jo = json.loads(content)
  54. if jo['code'] == 0:
  55. return jo['data']["info"]["uname"]
  56. def homeContent(self, filter):
  57. result = {}
  58. cateManual = {
  59. "动态": "动态",
  60. "历史记录": '历史记录',
  61. "收藏夹": '收藏夹',
  62. "热门": "热门",
  63. "排行榜": "排行榜",
  64. "频道": "频道",
  65. "直播": "直播",
  66. "舞蹈": "舞蹈",
  67. "宅舞": "宅舞",
  68. "少女": "少女",
  69. 'cosplay':'cosplay',
  70. 'mmd':'mmd',
  71. "鬼畜": "鬼畜",
  72. "狗狗": "汪星人",
  73. '科技': '科技',
  74. "音声": "音声",
  75. "演唱会": "演唱会",
  76. "番剧": "1",
  77. "国创": "4",
  78. "电影": "2",
  79. "综艺": "7",
  80. "电视剧": "5",
  81. "纪录片": "3",
  82. }
  83. classes = []
  84. for k in cateManual:
  85. classes.append({
  86. 'type_name': k,
  87. 'type_id': cateManual[k]
  88. })
  89. result['class'] = classes
  90. if (filter):
  91. result['filters'] = self.config['filter']
  92. return result
  93. def homeVideoContent(self):
  94. self.box_video_type = '热门'
  95. return self.get_hot(pg='1')
  96. cookies = ''
  97. # def getCookie(self):
  98. # # 在cookies_str中填入会员或大会员cookie,以获得更好的体验。
  99. # cookies_str = "buvid3=CFF74DA7-E79E-4B53-BB96-FC74AB8CD2F3184997infoc; LIVE_BUVID=AUTO4216125328906835; rpdid=|(umRum~uY~R0J'uYukYukkkY; balh_is_closed=; balh_server_inner=__custom__; PVID=4; video_page_version=v_old_home; i-wanna-go-back=-1; CURRENT_BLACKGAP=0; blackside_state=0; fingerprint=8965144a609d60190bd051578c610d72; buvid_fp_plain=undefined; CURRENT_QUALITY=120; hit-dyn-v2=1; nostalgia_conf=-1; buvid_fp=CFF74DA7-E79E-4B53-BB96-FC74AB8CD2F3184997infoc; CURRENT_FNVAL=4048; DedeUserID=85342; DedeUserID__ckMd5=f070401c4c699c83; b_ut=5; hit-new-style-dyn=0; buvid4=15C64651-E8B7-100C-4B1F-C7CFD2DB473007906-022110820-jYQRaMeS%2BRXRfw14q70%2FLQ%3D%3D; b_nut=1667910208; b_lsid=3CE4AE79_184578915C0; is-2022-channel=1; innersign=0; SESSDATA=a5e4d58d%2C1683641322%2C2c39a%2Ab1; bili_jct=2f3126b5954e37f593130f2fef082cd8; sid=p7tjqv22; bp_video_offset_85342=726936847258746900"
  100. # cookies_dic = dict([co.strip().split('=') for co in cookies_str.split(';')])
  101. # rsp = session()
  102. # cookies_jar = utils.cookiejar_from_dict(cookies_dic)
  103. # rsp.cookies = cookies_jar
  104. # content = self.fetch("http://api.bilibili.com/x/web-interface/nav", cookies=rsp.cookies)
  105. # res = json.loads(content.text)
  106. # if res["code"] == 0:
  107. # self.cookies = rsp.cookies
  108. # else:
  109. # rsp = self.fetch("https://www.bilibili.com/")
  110. # self.cookies = rsp.cookies
  111. # return rsp.cookies
  112. def getCookie(self):
  113. #在下方cookies_str 后面 双引号里面放置你的cookies
  114. cookies_str = "buvid3=CFF74DA7-E79E-4B53-BB96-FC74AB8CD2F3184997infoc; LIVE_BUVID=AUTO4216125328906835; rpdid=|(umRum~uY~R0J'uYukYukkkY; balh_is_closed=; balh_server_inner=__custom__; PVID=4; video_page_version=v_old_home; i-wanna-go-back=-1; CURRENT_BLACKGAP=0; blackside_state=0; fingerprint=8965144a609d60190bd051578c610d72; buvid_fp_plain=undefined; CURRENT_QUALITY=120; hit-dyn-v2=1; nostalgia_conf=-1; buvid_fp=CFF74DA7-E79E-4B53-BB96-FC74AB8CD2F3184997infoc; CURRENT_FNVAL=4048; DedeUserID=85342; DedeUserID__ckMd5=f070401c4c699c83; b_ut=5; hit-new-style-dyn=0; buvid4=15C64651-E8B7-100C-4B1F-C7CFD2DB473007906-022110820-jYQRaMeS%2BRXRfw14q70%2FLQ%3D%3D; b_nut=1667910208; b_lsid=3CE4AE79_184578915C0; is-2022-channel=1; innersign=0; SESSDATA=a5e4d58d%2C1683641322%2C2c39a%2Ab1; bili_jct=2f3126b5954e37f593130f2fef082cd8; sid=p7tjqv22; bp_video_offset_85342=726936847258746900"
  115. if cookies_str:
  116. cookies = dict([co.strip().split('=') for co in cookies_str.split(';')])
  117. bili_jct = cookies['bili_jct']
  118. SESSDATA = cookies['SESSDATA']
  119. DedeUserID = cookies['DedeUserID']
  120. cookies_jar={"bili_jct":bili_jct,
  121. 'SESSDATA': SESSDATA,
  122. 'DedeUserID':DedeUserID
  123. }
  124. rsp = session()
  125. rsp.cookies = cookies_jar
  126. content = self.fetch("http://api.bilibili.com/x/web-interface/nav", cookies=rsp.cookies)
  127. res = json.loads(content.text)
  128. if res["code"] == 0:
  129. self.cookies = rsp.cookies
  130. self.userid = res["data"].get('mid')
  131. return rsp.cookies
  132. rsp = self.fetch("https://www.bilibili.com/")
  133. self.cookies = rsp.cookies
  134. return rsp.cookies
  135. def get_hot(self, pg):
  136. self.box_video_type = '热门'
  137. result = {}
  138. url = 'https://api.bilibili.com/x/web-interface/popular?ps=20&pn={0}'.format(pg)
  139. rsp = self.fetch(url, cookies=self.cookies)
  140. content = rsp.text
  141. jo = json.loads(content)
  142. if jo['code'] == 0:
  143. videos = []
  144. vodList = jo['data']['list']
  145. for vod in vodList:
  146. aid = str(vod['aid']).strip()
  147. title = vod['title'].strip().replace("<em class=\"keyword\">", "").replace("</em>", "")
  148. img = vod['pic'].strip()
  149. remark = str(self.second_to_time(vod['duration'])).strip()
  150. videos.append({
  151. "vod_id": aid+'&hot',
  152. "vod_name": title,
  153. "vod_pic": img,
  154. "vod_remarks": remark
  155. })
  156. result['list'] = videos
  157. result['page'] = pg
  158. result['pagecount'] = 9999
  159. result['limit'] = 90
  160. result['total'] = 999999
  161. return result
  162. def str2sec(self,x):
  163. '''
  164. 字符串时分秒转换成秒
  165. '''
  166. x=str(x)
  167. try:
  168. h, m, s = x.strip().split(':') #.split()函数将其通过':'分隔开,.strip()函数用来除去空格
  169. return int(h)*3600 + int(m)*60 + int(s) #int()函数转换成整数运算
  170. except:
  171. m, s = x.strip().split(':') #.split()函数将其通过':'分隔开,.strip()函数用来除去空格
  172. return int(m)*60 + int(s) #int()函数转换成整数运算
  173. def get_rank(self):
  174. self.box_video_type = '排行榜'
  175. result = {}
  176. url = 'https://api.bilibili.com/x/web-interface/ranking/v2?rid=0&type=all'
  177. rsp = self.fetch(url, cookies=self.cookies)
  178. content = rsp.text
  179. jo = json.loads(content)
  180. if jo['code'] == 0:
  181. videos = []
  182. vodList = jo['data']['list']
  183. for vod in vodList:
  184. aid = str(vod['aid']).strip()
  185. title = vod['title'].strip().replace("<em class=\"keyword\">", "").replace("</em>", "")
  186. img = vod['pic'].strip()
  187. remark = str(self.second_to_time(vod['duration'])).strip()
  188. videos.append({
  189. "vod_id": aid+'&rank',
  190. "vod_name": title,
  191. "vod_pic": img,
  192. "vod_remarks": remark
  193. })
  194. result['list'] = videos
  195. result['page'] = 1
  196. result['pagecount'] = 1
  197. result['limit'] = 90
  198. result['total'] = 999999
  199. return result
  200. def filter_duration(self, vodlist, key):
  201. # 按时间过滤
  202. if key == '0':
  203. return vodlist
  204. else:
  205. vod_list_new = [i for i in vodlist if self.time_diff1[key][0] <= self.str2sec(str(i["vod_remarks"])) < self.time_diff1[key][1]]
  206. return vod_list_new
  207. chanel_offset=''
  208. def get_channel(self, pg, cid,extend,order,duration_diff):
  209. result = {}
  210. self.box_video_type = '频道'
  211. url = 'https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword={0}&page={1}&duration={2}&order={3}'.format(
  212. cid, pg,duration_diff,order)
  213. rsp = self.fetch(url, cookies=self.cookies)
  214. content = rsp.text
  215. jo = json.loads(content)
  216. if jo.get('code') == 0:
  217. videos = []
  218. vodList = jo['data']['result']
  219. for vod in vodList:
  220. aid = str(vod['aid']).strip()
  221. title = vod['title'].replace("<em class=\"keyword\">", "").replace("</em>", "").replace("&quot;", '"')
  222. img = 'https:' + vod['pic'].strip()
  223. remark = str( self.second_to_time(self.str2sec(vod['duration']))).strip()
  224. videos.append({
  225. "vod_id": aid+'&channale',
  226. "vod_name": title,
  227. "vod_pic": img,
  228. "vod_remarks": remark
  229. })
  230. #videos=self.filter_duration(videos, duration_diff)
  231. result['list'] = videos
  232. result['page'] = pg
  233. result['pagecount'] = 9999
  234. result['limit'] = 90
  235. result['total'] = 999999
  236. return result
  237. dynamic_offset = ''
  238. def get_dynamic(self, pg):
  239. self.box_video_type = '动态'
  240. result = {}
  241. if str(pg) == '1':
  242. url = 'https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all?timezone_offset=-480&type=all&page=%s' % pg
  243. else:
  244. # print('偏移',self.dynamic_offset)
  245. url = 'https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all?timezone_offset=-480&type=all&offset=%s&page=%s' % (
  246. self.dynamic_offset, pg)
  247. rsp = self.fetch(url, cookies=self.cookies)
  248. content = rsp.text
  249. jo = json.loads(content)
  250. if jo['code'] == 0:
  251. self.dynamic_offset = jo['data'].get('offset')
  252. videos = []
  253. vodList = jo['data']['items']
  254. for vod in vodList:
  255. if vod['type'] == 'DYNAMIC_TYPE_AV':
  256. #up=vod['modules']["module_author"]['name']
  257. ivod = vod['modules']['module_dynamic']['major']['archive']
  258. aid = str(ivod['aid']).strip()
  259. title = ivod['title'].strip().replace("<em class=\"keyword\">", "").replace("</em>", "")
  260. img = ivod['cover'].strip()
  261. #remark = str(ivod['duration_text']).strip()
  262. remark =str( self.second_to_time(self.str2sec(ivod['duration_text']))).strip()
  263. videos.append({
  264. "vod_id": aid+'&dynamic',
  265. "vod_name": title,
  266. "vod_pic": img,
  267. "vod_remarks": remark
  268. })
  269. result['list'] = videos
  270. result['page'] = pg
  271. result['pagecount'] = 9999
  272. result['limit'] = 90
  273. result['total'] = 999999
  274. return result
  275. time_diff1={'1':[0,300],
  276. '2':[300,900],'3':[900,1800],'4':[1800,3600],
  277. '5':[3600,99999999999999999999999999999999]
  278. }
  279. time_diff='0'
  280. def get_fav_detail(self,pg,mlid,order):
  281. result = {}
  282. self.box_video_type = '收藏夹'
  283. url = 'http://api.bilibili.com/x/v3/fav/resource/list?media_id=%s&order=%s&pn=%s&ps=20&platform=web&type=0'%(mlid,order,pg)
  284. rsp = self.fetch(url, cookies=self.cookies)
  285. content = rsp.text
  286. jo = json.loads(content)
  287. if jo['code'] == 0:
  288. videos = []
  289. vodList = jo['data']['medias']
  290. for vod in vodList:
  291. #print(vod)
  292. #只展示类型为 视频的条目
  293. #过滤去掉收藏夹中的 已失效视频;如果不喜欢可以去掉这个 if条件
  294. if vod.get('type') in [2] and vod.get('title') != '已失效视频':
  295. aid = str(vod['id']).strip()
  296. title = vod['title'].replace("<em class=\"keyword\">", "").replace("</em>", "").replace("&quot;", '"')
  297. img = vod['cover'].strip()
  298. remark = str( self.second_to_time(vod['duration'])).strip()
  299. videos.append({
  300. "vod_id": aid+'&fav',
  301. "vod_name": title,
  302. "vod_pic": img,
  303. "vod_remarks": remark
  304. })
  305. #videos=self.filter_duration(videos, duration_diff)
  306. result['list'] = videos
  307. result['page'] = pg
  308. result['pagecount'] = 9999
  309. result['limit'] = 90
  310. result['total'] = 999999
  311. return result
  312. def get_fav(self,pg,order,extend):
  313. self.box_video_type = '收藏夹'
  314. #获取自己的up_mid(也就是用户uid)
  315. mlid=''
  316. fav_config=self.config["filter"].get('收藏夹')
  317. #默认显示第一个收藏夹内容
  318. if fav_config:
  319. for i in fav_config:
  320. if i['key']=='mlid':
  321. if len(i['value'])>0:
  322. mlid=i['value'][0]['v']
  323. #print(self.config["filter"].get('收藏夹'))
  324. if 'mlid' in extend:
  325. mlid = extend['mlid']
  326. if mlid:
  327. return self.get_fav_detail(pg=pg,mlid=mlid,order=order)
  328. else:
  329. return {}
  330. def get_history(self,pg):
  331. result = {}
  332. self.box_video_type = '历史记录'
  333. url = 'http://api.bilibili.com/x/v2/history?pn=%s' % pg
  334. rsp = self.fetch(url,cookies=self.cookies)
  335. content = rsp.text
  336. jo = json.loads(content) #解析api接口,转化成json数据对象
  337. if jo['code'] == 0:
  338. videos = []
  339. vodList = jo['data']
  340. for vod in vodList:
  341. if vod['duration'] > 0: #筛选掉非视频的历史记录
  342. aid = str(vod["aid"]).strip() #获取 aid
  343. #获取标题
  344. title = vod["title"].replace("<em class=\"keyword\">", "").replace("</em>", "").replace("&quot;",
  345. '"')
  346. #封面图片
  347. img = vod["pic"].strip()
  348. #获取已观看时间
  349. if str(vod['progress'])=='-1':
  350. process=str(self.second_to_time(vod['duration'])).strip()
  351. else:
  352. process = str(self.second_to_time(vod['progress'])).strip()
  353. #获取视频总时长
  354. total_time= str(self.second_to_time(vod['duration'])).strip()
  355. #组合 已观看时间 / 总时长 ,赋值给 remark
  356. remark = process+' / '+total_time
  357. videos.append({
  358. "vod_id":aid+'&history',
  359. "vod_name": title,
  360. "vod_pic": img,
  361. "vod_remarks": remark
  362. })
  363. result['list'] = videos
  364. result['page'] = pg
  365. result['pagecount'] = 9999
  366. result['limit'] = 90
  367. result['total'] = 999999
  368. return result
  369. def get_live(self,pg,parent_area_id):
  370. result = {}
  371. self.box_video_type = '直播'
  372. url = 'https://api.live.bilibili.com/room/v3/area/getRoomList?page=%s&sort_type=online&parent_area_id=%s'%(pg,parent_area_id)
  373. rsp = self.fetch(url, cookies=self.cookies)
  374. content = rsp.text
  375. jo = json.loads(content)
  376. if jo['code'] == 0:
  377. videos = []
  378. vodList = jo['data']['list']
  379. for vod in vodList:
  380. aid = str(vod['roomid']).strip()
  381. title = vod['title'].replace("<em class=\"keyword\">", "").replace("</em>", "").replace("&quot;", '"')
  382. img = vod.get('cover').strip()
  383. remark = '直播间人数:'+str( vod['online']).strip()
  384. videos.append({
  385. "vod_id": aid+'&live',
  386. "vod_name": title,
  387. "vod_pic": img,
  388. "vod_remarks": remark
  389. })
  390. #videos=self.filter_duration(videos, duration_diff)
  391. result['list'] = videos
  392. result['page'] = pg
  393. result['pagecount'] = 9999
  394. result['limit'] = 90
  395. result['total'] = 999999
  396. return result
  397. def categoryContent(self, tid, pg, filter, extend):
  398. result = {}
  399. if len(self.cookies) <= 0:
  400. self.getCookie()
  401. if tid == "热门":
  402. self.box_video_type = '热门'
  403. return self.get_hot(pg=pg)
  404. elif tid == "排行榜":
  405. self.box_video_type = '排行榜'
  406. return self.get_rank()
  407. elif tid == "收藏夹":
  408. self.box_video_type = '收藏夹'
  409. order = 'mtime'
  410. if 'order' in extend:
  411. order = extend['order']
  412. return self.get_fav(pg=pg, order=order,extend=extend)
  413. elif tid == '直播':
  414. self.box_video_type = '直播'
  415. parent_area_id = '0'
  416. if 'parent_area_id' in extend:
  417. parent_area_id = extend['parent_area_id']
  418. return self.get_live(pg=pg,parent_area_id=parent_area_id)
  419. elif tid == '频道':
  420. self.box_video_type = '频道'
  421. cid = '搞笑'
  422. if 'cid' in extend:
  423. cid = extend['cid']
  424. duration_diff='0'
  425. if 'duration' in extend:
  426. duration_diff = extend['duration']
  427. order = 'totalrank'
  428. if 'order' in extend:
  429. order = extend['order']
  430. return self.get_channel(pg=pg, cid=cid,extend=extend,order=order,duration_diff=duration_diff)
  431. elif tid == '动态':
  432. self.box_video_type = '动态'
  433. return self.get_dynamic(pg=pg)
  434. elif tid == '历史记录':
  435. self.box_video_type = '历史记录'
  436. return self.get_history(pg=pg)
  437. elif tid.isdigit():
  438. self.box_video_type = '影视'
  439. url = 'https://api.bilibili.com/pgc/season/index/result?order=2&season_status=-1&style_id=-1&sort=0&area=-1&pagesize=20&type=1&st={0}&season_type={0}&page={1}'.format(
  440. tid, pg)
  441. rsp = self.fetch(url, cookies=self.cookies)
  442. content = rsp.text
  443. jo = json.loads(content)
  444. videos = []
  445. vodList = jo['data']['list']
  446. for vod in vodList:
  447. aid = str(vod['season_id']).strip()
  448. title = vod['title'].strip()
  449. img = vod['cover'].strip()
  450. remark = vod['index_show'].strip()
  451. videos.append({
  452. "vod_id": aid+'&movie',
  453. "vod_name": title,
  454. "vod_pic": img,
  455. "vod_remarks": remark # 视频part数量
  456. })
  457. result['list'] = videos
  458. result['page'] = pg
  459. result['pagecount'] = 9999
  460. result['limit'] = 90
  461. result['total'] = 999999
  462. else:
  463. duration_diff='0'
  464. if 'duration' in extend:
  465. duration_diff = extend['duration']
  466. order = 'totalrank'
  467. if 'order' in extend:
  468. order = extend['order']
  469. self.box_video_type = '其他'
  470. url = 'https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword={0}&page={1}&duration={2}&order={3}'.format(
  471. tid, pg,duration_diff,order)
  472. rsp = self.fetch(url, cookies=self.cookies)
  473. content = rsp.text
  474. jo = json.loads(content)
  475. if jo.get('code') == 0:
  476. videos = []
  477. vodList = jo['data']['result']
  478. for vod in vodList:
  479. aid = str(vod['aid']).strip()
  480. title = vod['title'].replace("<em class=\"keyword\">", "").replace("</em>", "").replace("&quot;", '"')
  481. img = 'https:' + vod['pic'].strip()
  482. #remark = str(vod['duration']).strip()
  483. remark =str( self.second_to_time(self.str2sec(vod['duration']))).strip()
  484. videos.append({
  485. "vod_id": aid+'&other',
  486. "vod_name": title,
  487. "vod_pic": img,
  488. "vod_remarks": remark
  489. })
  490. #videos=self.filter_duration(videos, duration_diff)
  491. result['list'] = videos
  492. result['page'] = pg
  493. result['pagecount'] = 9999
  494. result['limit'] = 90
  495. result['total'] = 999999
  496. return result
  497. def cleanSpace(self, str):
  498. return str.replace('\n', '').replace('\t', '').replace('\r', '').replace(' ', '')
  499. def detailContent(self, array):
  500. # if int(array[0])< 1000000:
  501. result={}
  502. arrays = array[0].split("&")
  503. if arrays[-1] == 'movie':
  504. self.box_video_type='影视'
  505. aid = arrays[0]
  506. url = "http://api.bilibili.com/pgc/view/web/season?season_id={0}".format(aid)
  507. rsp = self.fetch(url, headers=self.header)
  508. jRoot = json.loads(rsp.text)
  509. if jRoot['code'] == 0:
  510. jo = jRoot['result']
  511. id = jo['season_id']
  512. title = jo['title']
  513. pic = jo['cover']
  514. areas = jo['areas'][0]['name']
  515. typeName = jo['share_sub_title']
  516. dec = jo['evaluate']
  517. remark = jo['new_ep']['desc']
  518. vod = {
  519. "vod_id": id,
  520. "vod_name": title,
  521. "vod_pic": pic,
  522. "type_name": typeName,
  523. "vod_year": "",
  524. # "vod_area":areas,
  525. "vod_area": self.vod_area, #弹幕是否显示的开关
  526. "vod_remarks": remark,
  527. "vod_actor": "",
  528. "vod_director": "",
  529. "vod_content": dec
  530. }
  531. ja = jo['episodes']
  532. playUrl = ''
  533. for tmpJo in ja:
  534. eid = tmpJo['id']
  535. cid = tmpJo['cid']
  536. part = tmpJo['title'].replace("#", "-")
  537. playUrl = playUrl + '{0}${1}_{2}#'.format(part, eid, cid)
  538. vod['vod_play_from'] = 'B站'
  539. vod['vod_play_url'] = playUrl
  540. result = {
  541. 'list': [
  542. vod
  543. ]
  544. }
  545. elif arrays[-1] == 'live':
  546. self.box_video_type='直播'
  547. aid = arrays[0]
  548. url = "https://api.live.bilibili.com/room/v1/Room/get_info?room_id=%s"%aid
  549. rsp = self.fetch(url, headers=self.header,cookies=self.cookies)
  550. jRoot = json.loads(rsp.text)
  551. if jRoot.get('code')==0:
  552. jo = jRoot['data']
  553. title = jo['title'].replace("<em class=\"keyword\">", "").replace("</em>", "")
  554. pic = jo.get("user_cover")
  555. desc = jo.get('description')
  556. dire = self.get_live_userInfo(jo["uid"])
  557. typeName = jo.get("area_name")
  558. remark = '在线人数:'+str(jo['online']).strip()
  559. vod = {
  560. "vod_id": aid,
  561. "vod_name": '(' + dire + ")" + title,
  562. "vod_pic": pic,
  563. "type_name": typeName,
  564. "vod_area": self.vod_area,
  565. #"vod_area":"",
  566. "vod_remarks": remark,
  567. "vod_actor": "直播间id-"+aid,
  568. "vod_director": dire,
  569. "vod_content": desc + '\n主播:' + dire,
  570. 'vod_play_from':'B站',
  571. 'vod_play_url':'flv线路原画$platform=web&quality=4_'+aid+'#flv线路高清$platform=web&quality=3_'+aid+'#h5线路原画$platform=h5&quality=4_'+aid+'#h5线路高清$platform=h5&quality=3_'+aid
  572. # 'vod_play_url':aid
  573. }
  574. result = {
  575. 'list': [
  576. vod
  577. ]
  578. }
  579. else :
  580. self.box_video_type='其他'
  581. aid = arrays[0]
  582. url = "https://api.bilibili.com/x/web-interface/view?aid={0}".format(aid)
  583. rsp = self.fetch(url, headers=self.header)
  584. jRoot = json.loads(rsp.text)
  585. if jRoot['code'] == 0:
  586. jo = jRoot['data']
  587. title = jo['title'].replace("<em class=\"keyword\">", "").replace("</em>", "")
  588. pic = jo['pic']
  589. desc = jo['desc']
  590. timeStamp = jo['pubdate']
  591. timeArray = time.localtime(timeStamp)
  592. year = str(time.strftime("%Y", timeArray))
  593. dire = jo['owner']['name']
  594. typeName = jo['tname']
  595. remark = str(jo['duration']).strip()
  596. vod = {
  597. "vod_id": aid,
  598. "vod_name": '(' + dire + ")" + title,
  599. "vod_pic": pic,
  600. "type_name": typeName,
  601. "vod_year": year,
  602. "vod_area": self.vod_area,
  603. # "vod_area":"",
  604. "vod_remarks": remark,
  605. "vod_actor": '',
  606. "vod_director": dire,
  607. "vod_content": desc + '\nup主:' + dire
  608. }
  609. ja = jo['pages']
  610. playUrl = ''
  611. for tmpJo in ja:
  612. cid = tmpJo['cid']
  613. part = tmpJo['part'].replace("#", "-")
  614. playUrl = playUrl + '{0}${1}_{2}#'.format(part, aid, cid)
  615. vod['vod_play_from'] = 'B站'
  616. vod['vod_play_url'] = playUrl
  617. result = {
  618. 'list': [
  619. vod
  620. ]
  621. }
  622. return result
  623. def searchContent(self, key, quick):
  624. self.box_video_type = '搜索'
  625. header = {
  626. "Referer": "https://www.bilibili.com",
  627. "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
  628. }
  629. url = 'https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword={0}&page=1'.format(key)
  630. rsp = self.fetch(url, cookies=self.cookies, headers=header)
  631. content = rsp.text
  632. jo = json.loads(content)
  633. if jo['code'] != 0:
  634. rspRetry = self.fetch(url, cookies=self.cookies, headers=header)
  635. content = rspRetry.text
  636. jo = json.loads(content)
  637. videos = []
  638. vodList = jo['data']['result']
  639. for vod in vodList:
  640. aid = str(vod['aid']).strip()
  641. title = vod['title'].replace("<em class=\"keyword\">", "").replace("</em>", "").replace("&quot;", '"')
  642. img = 'https:' + vod['pic'].strip()
  643. remark = str(vod['duration']).strip()
  644. videos.append({
  645. "vod_id": aid+'&search',
  646. "vod_name": title,
  647. "vod_pic": img,
  648. "vod_remarks": remark
  649. })
  650. result = {
  651. 'list': videos
  652. }
  653. return result
  654. def playerContent(self, flag, id, vipFlags):
  655. result = {}
  656. if self.box_video_type == '影视':
  657. ids = id.split("_")
  658. header = {
  659. "Referer": "https://www.bilibili.com",
  660. "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
  661. }
  662. url = 'https://api.bilibili.com/pgc/player/web/playurl?qn=116&ep_id={0}&cid={1}'.format(ids[0], ids[1])
  663. if len(self.cookies) <= 0:
  664. self.getCookie()
  665. rsp = self.fetch(url, cookies=self.cookies, headers=header)
  666. jRoot = json.loads(rsp.text)
  667. if jRoot['message'] != 'success':
  668. print("需要大会员权限才能观看")
  669. return {}
  670. jo = jRoot['result']
  671. ja = jo['durl']
  672. maxSize = -1
  673. position = -1
  674. for i in range(len(ja)):
  675. tmpJo = ja[i]
  676. if maxSize < int(tmpJo['size']):
  677. maxSize = int(tmpJo['size'])
  678. position = i
  679. url = ''
  680. if len(ja) > 0:
  681. if position == -1:
  682. position = 0
  683. url = ja[position]['url']
  684. result["parse"] = 0
  685. result["playUrl"] = ''
  686. result["url"] = url
  687. result["header"] = {
  688. "Referer": "https://www.bilibili.com",
  689. "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
  690. }
  691. result["contentType"] = 'video/x-flv'
  692. self.box_video_type = '影视'
  693. elif self.box_video_type == '直播':
  694. ids = id.split("_")
  695. url = 'https://api.live.bilibili.com/room/v1/Room/playUrl?cid=%s&%s'%(ids[1],ids[0])
  696. #raise Exception(url)
  697. if len(self.cookies) <= 0:
  698. self.getCookie()
  699. rsp = self.fetch(url, cookies=self.cookies)
  700. jRoot = json.loads(rsp.text)
  701. if jRoot['code'] == 0:
  702. jo = jRoot['data']
  703. ja = jo['durl']
  704. url = ''
  705. if len(ja) > 0:
  706. url = ja[0]['url']
  707. result["parse"] = 0
  708. # result['type'] ="m3u8"
  709. result["playUrl"] = ''
  710. result["url"] = url
  711. result["header"] = {
  712. "Referer": "https://live.bilibili.com",
  713. "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
  714. }
  715. self.box_video_type = '直播'
  716. if ids[0]=="h5":
  717. result["contentType"] = ''
  718. else:
  719. result["contentType"] = 'video/x-flv'
  720. else:
  721. ids = id.split("_")
  722. url = 'https://api.bilibili.com:443/x/player/playurl?avid={0}&cid={1}&qn=116'.format(ids[0], ids[1])
  723. if len(self.cookies) <= 0:
  724. self.getCookie()
  725. rsp = self.fetch(url, cookies=self.cookies)
  726. jRoot = json.loads(rsp.text)
  727. jo = jRoot['data']
  728. ja = jo['durl']
  729. maxSize = -1
  730. position = -1
  731. for i in range(len(ja)):
  732. tmpJo = ja[i]
  733. if maxSize < int(tmpJo['size']):
  734. maxSize = int(tmpJo['size'])
  735. position = i
  736. url = ''
  737. if len(ja) > 0:
  738. if position == -1:
  739. position = 0
  740. url = ja[position]['url']
  741. result["parse"] = 0
  742. result["playUrl"] = ''
  743. result["url"] = url
  744. result["header"] = {
  745. "Referer": "https://www.bilibili.com",
  746. "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
  747. }
  748. result["contentType"] = 'video/x-flv'
  749. self.box_video_type = '其他'
  750. return result
  751. config = {
  752. "player": {},
  753. "filter": {
  754. "舞蹈": [{
  755. "key": "order",
  756. "name": "排序",
  757. "value": [
  758. {
  759. "n": "综合排序",
  760. "v": "totalrank"
  761. },
  762. {
  763. "n": "最新发布",
  764. "v": "pubdate"
  765. },
  766. {
  767. "n": "最多点击",
  768. "v": "click"
  769. },
  770. {
  771. "n": "最多收藏",
  772. "v": "stow"
  773. },
  774. {
  775. "n": "最多弹幕",
  776. "v": "dm"
  777. },
  778. ]
  779. },
  780. {
  781. "key": "duration",
  782. "name": "时长",
  783. "value": [{
  784. "n": "全部",
  785. "v": "0"
  786. },
  787. {
  788. "n": "60分钟以上",
  789. "v": "4"
  790. },
  791. {
  792. "n": "30~60分钟",
  793. "v": "3"
  794. },
  795. {
  796. "n": "5~30分钟",
  797. "v": "2"
  798. },
  799. {
  800. "n": "5分钟以下",
  801. "v": "1"
  802. }
  803. ]
  804. }],
  805. "少女": [{
  806. "key": "order",
  807. "name": "排序",
  808. "value": [
  809. {
  810. "n": "综合排序",
  811. "v": "totalrank"
  812. },
  813. {
  814. "n": "最新发布",
  815. "v": "pubdate"
  816. },
  817. {
  818. "n": "最多点击",
  819. "v": "click"
  820. },
  821. {
  822. "n": "最多收藏",
  823. "v": "stow"
  824. },
  825. {
  826. "n": "最多弹幕",
  827. "v": "dm"
  828. },
  829. ]
  830. },
  831. {
  832. "key": "duration",
  833. "name": "时长",
  834. "value": [{
  835. "n": "全部",
  836. "v": "0"
  837. },
  838. {
  839. "n": "60分钟以上",
  840. "v": "4"
  841. },
  842. {
  843. "n": "30~60分钟",
  844. "v": "3"
  845. },
  846. {
  847. "n": "5~30分钟",
  848. "v": "2"
  849. },
  850. {
  851. "n": "5分钟以下",
  852. "v": "1"
  853. }
  854. ]
  855. }],
  856. "mmd": [{
  857. "key": "order",
  858. "name": "排序",
  859. "value": [
  860. {
  861. "n": "综合排序",
  862. "v": "totalrank"
  863. },
  864. {
  865. "n": "最新发布",
  866. "v": "pubdate"
  867. },
  868. {
  869. "n": "最多点击",
  870. "v": "click"
  871. },
  872. {
  873. "n": "最多收藏",
  874. "v": "stow"
  875. },
  876. {
  877. "n": "最多弹幕",
  878. "v": "dm"
  879. },
  880. ]
  881. },
  882. {
  883. "key": "duration",
  884. "name": "时长",
  885. "value": [{
  886. "n": "全部",
  887. "v": "0"
  888. },
  889. {
  890. "n": "60分钟以上",
  891. "v": "4"
  892. },
  893. {
  894. "n": "30~60分钟",
  895. "v": "3"
  896. },
  897. {
  898. "n": "5~30分钟",
  899. "v": "2"
  900. },
  901. {
  902. "n": "5分钟以下",
  903. "v": "1"
  904. }
  905. ]
  906. }],
  907. "直播": [{
  908. "key": "parent_area_id",
  909. "name": "直播分区",
  910. "value": [
  911. {
  912. "n": "全部分区",
  913. "v": "0"
  914. },
  915. {
  916. "n": "娱乐",
  917. "v": "1"
  918. },
  919. {
  920. "n": "电台",
  921. "v": "5"
  922. },
  923. {
  924. "n": "网游",
  925. "v": "2"
  926. },
  927. {
  928. "n": "手游",
  929. "v": "3"
  930. },
  931. {
  932. "n": "单机游戏",
  933. "v": "6"
  934. },
  935. {
  936. "n": "虚拟主播",
  937. "v": "9"
  938. },{'n': '生活', 'v': 10},
  939. {'n': '知识', 'v': 11},
  940. {'n': '赛事', 'v': 13}
  941. ]
  942. },
  943. ],
  944. "音声": [{
  945. "key": "order",
  946. "name": "排序",
  947. "value": [
  948. {
  949. "n": "综合排序",
  950. "v": "totalrank"
  951. },
  952. {
  953. "n": "最新发布",
  954. "v": "pubdate"
  955. },
  956. {
  957. "n": "最多点击",
  958. "v": "click"
  959. },
  960. {
  961. "n": "最多收藏",
  962. "v": "stow"
  963. },
  964. {
  965. "n": "最多弹幕",
  966. "v": "dm"
  967. },
  968. ]
  969. },
  970. {
  971. "key": "duration",
  972. "name": "时长",
  973. "value": [{
  974. "n": "全部",
  975. "v": "0"
  976. },
  977. {
  978. "n": "60分钟以上",
  979. "v": "4"
  980. },
  981. {
  982. "n": "30~60分钟",
  983. "v": "3"
  984. },
  985. {
  986. "n": "5~30分钟",
  987. "v": "2"
  988. },
  989. {
  990. "n": "5分钟以下",
  991. "v": "1"
  992. }
  993. ]
  994. }],
  995. "收藏夹": [{
  996. "key": "order",
  997. "name": "排序",
  998. "value": [
  999. {
  1000. "n": "收藏时间",
  1001. "v": "mtime"
  1002. },
  1003. {
  1004. "n": "播放量",
  1005. "v": "view"
  1006. },
  1007. {
  1008. "n": "投稿时间",
  1009. "v": "pubtime"
  1010. }
  1011. ]
  1012. },
  1013. {
  1014. "key": "mlid",
  1015. "name": "收藏夹分区",
  1016. "value": [
  1017. ]
  1018. }],
  1019. "cosplay": [{
  1020. "key": "order",
  1021. "name": "排序",
  1022. "value": [
  1023. {
  1024. "n": "综合排序",
  1025. "v": "totalrank"
  1026. },
  1027. {
  1028. "n": "最新发布",
  1029. "v": "pubdate"
  1030. },
  1031. {
  1032. "n": "最多点击",
  1033. "v": "click"
  1034. },
  1035. {
  1036. "n": "最多收藏",
  1037. "v": "stow"
  1038. },
  1039. {
  1040. "n": "最多弹幕",
  1041. "v": "dm"
  1042. },
  1043. ]
  1044. },
  1045. {
  1046. "key": "duration",
  1047. "name": "时长",
  1048. "value": [{
  1049. "n": "全部",
  1050. "v": "0"
  1051. },
  1052. {
  1053. "n": "60分钟以上",
  1054. "v": "4"
  1055. },
  1056. {
  1057. "n": "30~60分钟",
  1058. "v": "3"
  1059. },
  1060. {
  1061. "n": "5~30分钟",
  1062. "v": "2"
  1063. },
  1064. {
  1065. "n": "5分钟以下",
  1066. "v": "1"
  1067. }
  1068. ]
  1069. }],
  1070. "频道": [{
  1071. "key": "order",
  1072. "name": "排序",
  1073. "value": [
  1074. {
  1075. "n": "综合排序",
  1076. "v": "totalrank"
  1077. },
  1078. {
  1079. "n": "最新发布",
  1080. "v": "pubdate"
  1081. },
  1082. {
  1083. "n": "最多点击",
  1084. "v": "click"
  1085. },
  1086. {
  1087. "n": "最多收藏",
  1088. "v": "stow"
  1089. },
  1090. {
  1091. "n": "最多弹幕",
  1092. "v": "dm"
  1093. },
  1094. ]
  1095. },
  1096. {
  1097. "key": "duration",
  1098. "name": "时长",
  1099. "value": [{
  1100. "n": "全部",
  1101. "v": "0"
  1102. },
  1103. {
  1104. "n": "60分钟以上",
  1105. "v": "4"
  1106. },
  1107. {
  1108. "n": "30~60分钟",
  1109. "v": "3"
  1110. },
  1111. {
  1112. "n": "5~30分钟",
  1113. "v": "2"
  1114. },
  1115. {
  1116. "n": "5分钟以下",
  1117. "v": "1"
  1118. }
  1119. ]
  1120. }, {"key": "cid", "name": "分类",
  1121. "value":[{'n': '搞笑', 'v': '搞笑'}, {'n': '美食', 'v': '美食'}, {'n': '鬼畜', 'v': '鬼畜'}, {'n': '美妆', 'v': '美妆'}, {'n': 'mmd', 'v': 'mmd'}, {'n': '科普', 'v': '科普'}, {'n': 'COSPLAY', 'v': 'COSPLAY'}, {'n': '漫展', 'v': '漫展'}, {'n': 'MAD', 'v': 'MAD'}, {'n': '手书', 'v': '手书'}, {'n': '穿搭', 'v': '穿搭'}, {'n': '发型', 'v': '发型'}, {'n': '化妆教程', 'v': '化妆教程'}, {'n': '电音', 'v': '电音'}, {'n': '欧美音乐', 'v': '欧美音乐'}, {'n': '中文翻唱', 'v': '中文翻唱'}, {'n': '洛天依', 'v': '洛天依'}, {'n': '翻唱', 'v': '翻唱'}, {'n': '日文翻唱', 'v': '日文翻唱'}, {'n': '科普', 'v': '科普'}, {'n': '技术宅', 'v': '技术宅'}, {'n': '历史', 'v': '历史'}, {'n': '科学', 'v': '科学'}, {'n': '人文', 'v': '人文'}, {'n': '科幻', 'v': '科幻'}, {'n': '手机', 'v': '手机'}, {'n': '手机评测', 'v': '手机评测'}, {'n': '电脑', 'v': '电脑'}, {'n': '摄影', 'v': '摄影'}, {'n': '笔记本', 'v': '笔记本'}, {'n': '装机', 'v': '装机'}, {'n': '课堂教育', 'v': '课堂教育'}, {'n': '公开课', 'v': '公开课'}, {'n': '演讲', 'v': '演讲'}, {'n': 'PS教程', 'v': 'PS教程'}, {'n': '编程', 'v': '编程'}, {'n': '英语学习', 'v': '英语学习'}, {'n': '喵星人', 'v': '喵星人'}, {'n': '萌宠', 'v': '萌宠'}, {'n': '汪星人', 'v': '汪星人'}, {'n': '大熊猫', 'v': '大熊猫'}, {'n': '柴犬', 'v': '柴犬'},{'n': '田园犬', 'v': '田园犬'}, {'n': '吱星人', 'v': '吱星人'}, {'n': '美食', 'v': '美食'}, {'n': '甜点', 'v': '甜点'}, {'n': '吃货', 'v': '吃货'}, {'n': '厨艺', 'v': '厨艺'}, {'n': '烘焙', 'v': '烘焙'}, {'n': '街头美食', 'v': '街头美食'}, {'n': 'A.I.Channel', 'v': 'A.I.Channel'}, {'n': '虚拟UP主', 'v': '虚拟UP主'}, {'n': '神楽めあ', 'v': '神楽めあ'}, {'n': '白上吹雪', 'v': '白上吹雪'}, {'n': '婺源', 'v': '婺源'}, {'n': 'hololive', 'v': 'hololive'}, {'n': 'EXO', 'v': 'EXO'}, {'n': '防弹少年团', 'v': '防弹少年团'}, {'n': '肖战', 'v': '肖战'}, {'n': '王一博', 'v': '王一博'}, {'n': '易烊千玺', 'v': '易烊千玺'}, {'n': '赵今麦', 'v': '赵今麦'}, {'n': '宅舞', 'v': '宅舞'}, {'n': '街舞', 'v': '街舞'}, {'n': '舞蹈教学', 'v': '舞蹈教学'}, {'n': '明星舞蹈', 'v': '明星舞蹈'}, {'n': '韩舞', 'v': '韩舞'}, {'n': '古典舞', 'v': '古典舞'}, {'n': '旅游', 'v': '旅游'}, {'n': '绘画', 'v': '绘画'}, {'n': '手工', 'v': '手工'}, {'n': 'vlog', 'v': 'vlog'}, {'n': 'DIY', 'v': 'DIY'}, {'n': '手绘', 'v': '手绘'}, {'n': '综艺', 'v': '综艺'}, {'n': '国家宝藏', 'v': '国家宝藏'}, {'n': '脱口秀', 'v': '脱口秀'}, {'n': '日本综艺', 'v': '日本综艺'}, {'n': '国内综艺', 'v': '国内综艺'}, {'n': '人类观察', 'v': '人类观察'}, {'n': '影评', 'v': '影评'}, {'n': '电影解说', 'v': '电影解说'}, {'n': '影视混剪', 'v': '影视混剪'}, {'n': '影视剪辑', 'v': '影视剪辑'}, {'n': '漫威', 'v': '漫威'}, {'n': '超级英雄', 'v': '超级英雄'}, {'n': '影视混剪', 'v': '影视混剪'}, {'n': '影视剪辑', 'v': '影视剪辑'},
  1122. {'n': '诸葛亮', 'v': '诸葛亮'}, {'n': '韩剧', 'v': '韩剧'}, {'n': '王司徒', 'v': '王司徒'}, {'n': '泰剧', 'v': '泰剧'},
  1123. {'n': '郭德纲', 'v': '郭德纲'}, {'n': '相声', 'v': '相声'}, {'n': '张云雷', 'v': '张云雷'}, {'n': '秦霄贤', 'v': '秦霄贤'}, {'n': '孟鹤堂', 'v': '孟鹤堂'}, {'n': '岳云鹏', 'v': '岳云鹏'}, {'n': '假面骑士', 'v': '假面骑士'}, {'n': '特摄', 'v': '特摄'}, {'n': '奥特曼', 'v': '奥特曼'}, {'n': '迪迦奥特曼', 'v': '迪迦奥特曼'}, {'n': '超级战队', 'v': '超级战队'}, {'n': '铠甲勇士', 'v': '铠甲勇士'}, {'n': '健身', 'v': '健身'}, {'n': '篮球', 'v': '篮球'}, {'n': '体育', 'v': '体育'}, {'n': '帕梅拉', 'v': '帕梅拉'}, {'n': '极限运动', 'v': '极限运动'}, {'n': '足球', 'v': '足球'}, {'n': '星海', 'v': '星海'}, {'n': '张召忠', 'v': '张召忠'}, {'n': '航母', 'v': '航母'}, {'n': '航天', 'v': '航天'}, {'n': '导弹', 'v': '导弹'}, {'n': '战斗机', 'v': '战斗机'}]
  1124. }
  1125. ],
  1126. }
  1127. }
  1128. header = {
  1129. "Referer": "https://www.bilibili.com",
  1130. "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
  1131. }
  1132. def localProxy(self, param):
  1133. return [200, "video/MP2T", action, ""]
  1134. if __name__ == '__main__':
  1135. a=Spider()
  1136. print(a.categoryContent('5','1',filter={},extend='1'))
  1137. #print(a.get_live(pg=1,parent_area_id='0'))
  1138. a.box_video_type='直播'
  1139. print(a.get_hot(pg=1))
  1140. print(a.detailContent(['43000&movie']))
  1141. print(a.playerContent('flag', 'flv线路$web_43000#h5线路$h5_43000', 'vipFlags'))
  1142. #print(a.get_fav(pg='1',order='mtime',extend={}))