提交 51972a35 编写于 作者: H hjdhnx

更新了几个bl规则

上级 67534033
此差异已折叠。
......@@ -44,7 +44,6 @@ class Spider(Spider):
"每周必看": "每周必看",
"入站必刷": "入站必刷",
"频道": "频道",
# ————————以下可自定义关键字,结果以搜索方式展示————————
}
classes = []
for k in cateManual:
......@@ -57,13 +56,14 @@ class Spider(Spider):
result['filters'] = self.config['filter']
return result
# 用户cookies
cookies = ''
userid = ''
csrf = ''
def getCookie(self):
import requests
import http.cookies
# --------↓↓↓↓↓↓↓------在下方双引号内填写-------↓↓↓↓↓↓↓--------
# ----↓↓↓↓↓↓↓----在下方raw_cookie_line后的双引号内填写----↓↓↓↓↓↓↓----
raw_cookie_line = ""
simple_cookie = http.cookies.SimpleCookie(raw_cookie_line)
cookie_jar = requests.cookies.RequestsCookieJar()
......@@ -75,6 +75,7 @@ class Spider(Spider):
if res["code"] == 0:
self.cookies = rsp.cookies
self.userid = res["data"].get('mid')
self.csrf = rsp.cookies['bili_jct']
return cookie_jar
def __init__(self):
......@@ -106,6 +107,10 @@ class Spider(Spider):
def manualVideoCheck(self):
pass
def post_history(self, aid, cid):
url = 'http://api.bilibili.com/x/v2/history/report?aid={0}&cid={1}&csrf={2}'.format(aid, cid, self.csrf)
requests.post(url=url, cookies=self.cookies)
# 将超过10000的数字换成成以万和亿为单位
def zh(self, num):
if int(num) >= 100000000:
......@@ -159,13 +164,12 @@ class Spider(Spider):
jo = json.loads(content)
if jo['code'] == 0:
videos = []
vodList = jo['data']['list']
vodList = jo['data']['list'][0:50]
for vod in vodList:
aid = str(vod['aid']).strip()
title = vod['title'].strip().replace("<em class=\"keyword\">", "").replace("</em>", "")
img = vod['pic'].strip()
# view = "▶" + self.zh(vod['stat']['view']) + ' 🕓' # 标签上加入播放量
remark = str(self.second_to_time(vod['duration'])).strip()
remark = "观看:" + self.zh(vod['stat']['view']) + "  " + str(self.second_to_time(vod['duration'])).strip()
videos.append({
"vod_id": aid,
"vod_name": title,
......@@ -218,18 +222,18 @@ class Spider(Spider):
def get_hot(self, pg):
result = {}
url = 'https://api.bilibili.com/x/web-interface/popular?ps=20&pn={0}'.format(pg)
url = 'https://api.bilibili.com/x/web-interface/popular?ps=10&pn={0}'.format(pg)
rsp = self.fetch(url, cookies=self.cookies)
content = rsp.text
jo = json.loads(content)
if jo['code'] == 0:
videos = []
vodList = jo['data']['list']
vodList = jo['data']['list'][0:50]
for vod in vodList:
aid = str(vod['aid']).strip()
title = vod['title'].strip().replace("<em class=\"keyword\">", "").replace("</em>", "")
img = vod['pic'].strip()
remark = str(self.second_to_time(vod['duration'])).strip()
remark = "观看:" + self.zh(vod['stat']['view']) + "  " + str(self.second_to_time(vod['duration'])).strip()
videos.append({
"vod_id": aid,
"vod_name": title,
......@@ -245,7 +249,7 @@ class Spider(Spider):
def get_rcmd(self, pg):
result = {}
url = 'https://api.bilibili.com/x/web-interface/index/top/feed/rcmd?y_num={0}&fresh_type=3&feed_version=SEO_VIDEO&fresh_idx_1h=1&fetch_row=1&fresh_idx=1&brush=0&homepage_ver=1&ps=20'.format(
url = 'https://api.bilibili.com/x/web-interface/index/top/feed/rcmd?y_num={0}&fresh_type=3&feed_version=SEO_VIDEO&fresh_idx_1h=1&fetch_row=1&fresh_idx=1&brush=0&homepage_ver=1&ps=10'.format(
pg)
rsp = self.fetch(url, cookies=self.cookies)
content = rsp.text
......@@ -258,7 +262,7 @@ class Spider(Spider):
aid = str(vod['id']).strip()
title = vod['title'].strip().replace("<em class=\"keyword\">", "").replace("</em>", "")
img = vod['pic'].strip()
remark = str(self.second_to_time(vod['duration'])).strip()
remark = "观看:" + self.zh(vod['stat']['view']) + "  " + str(self.second_to_time(vod['duration'])).strip()
videos.append({
"vod_id": aid,
"vod_name": title,
......@@ -280,12 +284,12 @@ class Spider(Spider):
jo = json.loads(content)
if jo['code'] == 0:
videos = []
vodList = jo['data']['list']
vodList = jo['data']['list'][0:50]
for vod in vodList:
aid = str(vod['aid']).strip()
title = vod['title'].strip().replace("<em class=\"keyword\">", "").replace("</em>", "")
img = vod['pic'].strip()
remark = str(self.second_to_time(vod['duration'])).strip()
remark = "观看:" + self.zh(vod['stat']['view']) + "  " + str(self.second_to_time(vod['duration'])).strip()
videos.append({
"vod_id": aid,
"vod_name": title,
......@@ -301,7 +305,7 @@ class Spider(Spider):
def get_history(self, pg):
result = {}
url = 'https://api.bilibili.com/x/v2/history?pn=%s' % pg
url = 'https://api.bilibili.com/x/v2/history?pn=%s&ps=10' % pg
rsp = self.fetch(url, cookies=self.cookies)
content = rsp.text
jo = json.loads(content) # 解析api接口,转化成json数据对象
......@@ -355,7 +359,7 @@ class Spider(Spider):
def get_fav_detail(self, pg, mlid, order):
result = {}
url = 'https://api.bilibili.com/x/v3/fav/resource/list?media_id=%s&order=%s&pn=%s&ps=20&platform=web&type=0' % (mlid, order, pg)
url = 'https://api.bilibili.com/x/v3/fav/resource/list?media_id=%s&order=%s&pn=%s&ps=10&platform=web&type=0' % (mlid, order, pg)
rsp = self.fetch(url, cookies=self.cookies)
content = rsp.text
jo = json.loads(content)
......@@ -371,7 +375,7 @@ class Spider(Spider):
title = vod['title'].replace("<em class=\"keyword\">", "").replace("</em>", "").replace("&quot;",
'"')
img = vod['cover'].strip()
remark = str(self.second_to_time(vod['duration'])).strip()
remark = "观看:" + self.zh(vod['cnt_info']['play']) + "  " + str(self.second_to_time(vod['duration'])).strip()
videos.append({
"vod_id": aid,
"vod_name": title,
......@@ -394,12 +398,12 @@ class Spider(Spider):
jo = json.loads(content)
if jo['code'] == 0:
videos = []
vodList = jo['data']['list']
vodList = jo['data']['list'][0:50]
for vod in vodList:
aid = str(vod['aid']).strip()
title = vod['title'].strip().replace("<em class=\"keyword\">", "").replace("</em>", "")
img = vod['pic'].strip()
remark = str(self.second_to_time(vod['duration'])).strip()
remark = "观看:" + self.zh(vod['stat']['view']) + "  " + str(self.second_to_time(vod['duration'])).strip()
videos.append({
"vod_id": aid,
"vod_name": title,
......@@ -431,7 +435,7 @@ class Spider(Spider):
aid = str(vod['aid']).strip()
title = vod['title'].strip()
img = vod['pic'].strip()
remark = str(self.second_to_time(vod['duration'])).strip()
remark = "观看:" + self.zh(vod['stat']['view']) + "  " + str(self.second_to_time(vod['duration'])).strip()
videos.append({
"vod_id": aid,
"vod_name": title,
......@@ -458,7 +462,7 @@ class Spider(Spider):
aid = str(vod['aid']).strip()
title = vod['title'].strip()
img = vod['pic'].strip()
remark = str(self.second_to_time(vod['duration'])).strip()
remark = "观看:" + self.zh(vod['stat']['view']) + "  " + str(self.second_to_time(vod['duration'])).strip()
videos.append({
"vod_id": aid,
"vod_name": title,
......@@ -512,7 +516,7 @@ class Spider(Spider):
def get_channel(self, pg, cid, extend, order, duration_diff):
result = {}
url = 'https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword={0}&page={1}&duration={2}&order={3}'.format(
url = 'https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword={0}&page={1}&duration={2}&order={3}&page_size=10'.format(
cid, pg, duration_diff, order)
rsp = self.fetch(url, cookies=self.cookies)
content = rsp.text
......@@ -524,7 +528,7 @@ class Spider(Spider):
aid = str(vod['aid']).strip()
title = vod['title'].replace("<em class=\"keyword\">", "").replace("</em>", "").replace("&quot;", '"')
img = 'https:' + vod['pic'].strip()
remark = str(self.second_to_time(self.str2sec(vod['duration']))).strip()
remark = "观看:" + self.zh(vod['play']) + "  " + str(self.second_to_time(self.str2sec(vod['duration']))).strip()
videos.append({
"vod_id": aid,
"vod_name": title,
......@@ -585,7 +589,7 @@ class Spider(Spider):
order = 'totalrank'
if 'order' in extend:
order = extend['order']
url = 'https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword={0}&page={1}&duration={2}&order={3}'.format(
url = 'https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword={0}&page={1}&duration={2}&order={3}&page_size=10'.format(
tid, pg, duration_diff, order)
rsp = self.fetch(url, cookies=self.cookies)
content = rsp.text
......@@ -599,7 +603,7 @@ class Spider(Spider):
'"')
img = 'https:' + vod['pic'].strip()
# remark = str(vod['duration']).strip()
remark = str(self.second_to_time(self.str2sec(vod['duration']))).strip()
remark = "观看:" + self.zh(vod['play']) + "  " + str(self.second_to_time(self.str2sec(vod['duration']))).strip()
videos.append({
"vod_id": aid,
"vod_name": title,
......@@ -634,7 +638,7 @@ class Spider(Spider):
remark = str(jo['duration']).strip()
vod = {
"vod_id": aid,
"vod_name": '[' + jo['owner']['name'] + "]" + title,
"vod_name": '[' + jo['owner']['name'] + "]" + title,
"vod_pic": pic,
"type_name": typeName,
"vod_year": date,
......@@ -676,7 +680,7 @@ class Spider(Spider):
vodList = jo['data']['result']
for vod in vodList:
aid = str(vod['aid']).strip()
title = '[' + key + ']' + vod['title'].replace("<em class=\"keyword\">", "").replace("</em>", "").replace("&quot;", '"')
title = vod['title'].replace("<em class=\"keyword\">", "").replace("</em>", "").replace("&quot;", '"') + '[' + key + ']'
img = 'https:' + vod['pic'].strip()
remark = str(self.second_to_time(self.str2sec(vod['duration']))).strip()
videos.append({
......@@ -698,6 +702,7 @@ class Spider(Spider):
url = 'https://api.bilibili.com:443/x/player/playurl?avid={0}&cid={1}&qn=116'.format(ids[0], ids[1])
if len(self.cookies) <= 0:
self.getCookie()
self.post_history(ids[0], ids[1]) # 回传播放历史记录
rsp = self.fetch(url, cookies=self.cookies)
jRoot = json.loads(rsp.text)
jo = jRoot['data']
......
......@@ -42,7 +42,8 @@ class Spider(Spider):
"猫咪": "喵星人",
"请自定义关键词": "美女",
# ————————以下可自定义UP主,冒号后须填写UID————————
"虫哥说电影": "29296192",
"徐云流浪中国": "697166795",
# "虫哥说电影": "29296192",
}
classes = []
......@@ -83,8 +84,8 @@ class Spider(Spider):
def get_up_videos(self, tid, pg):
result = {}
url = 'https://api.bilibili.com/x/space/arc/search?mid={0}&pn={1}&ps=20'.format(tid, pg)
rsp = self.fetch(url, cookies=self.cookies)
url = 'https://api.bilibili.com/x/space/arc/search?mid={0}&pn={1}&ps=10'.format(tid, pg)
rsp = self.fetch(url, headers=self.header, cookies=self.cookies)
content = rsp.text
jo = json.loads(content)
if jo['code'] == 0:
......@@ -94,7 +95,7 @@ class Spider(Spider):
aid = str(vod['aid']).strip()
title = vod['title'].strip().replace("<em class=\"keyword\">", "").replace("</em>", "")
img = vod['pic'].strip()
remark = str(vod['length']).strip()
remark = "观看:" + self.bilibili.zh(vod['play']) + "  " + str(vod['length']).strip()
videos.append({
"vod_id": aid,
"vod_name": title,
......@@ -176,7 +177,7 @@ class Spider(Spider):
if len(self.cookies) <= 0:
self.getCookie()
url = 'https://api.bilibili.com/x/web-interface/search/type?search_type=bili_user&keyword={0}'.format(key)
rsp = self.fetch(url, cookies=self.cookies)
rsp = self.fetch(url, headers=self.header, cookies=self.cookies)
content = rsp.text
jo = json.loads(content)
videos = []
......
......@@ -29,6 +29,7 @@ class Spider(Spider):
def manualVideoCheck(self):
pass
# 主页
def homeContent(self, filter):
result = {}
cateManual = {
......@@ -42,6 +43,9 @@ class Spider(Spider):
"追番": "追番",
"追剧": "追剧",
"时间表": "时间表",
# ————————以下可自定义关键字,结果以影视类搜索展示————————
# "喜羊羊": "喜羊羊"
}
classes = []
for k in cateManual:
......@@ -170,7 +174,7 @@ class Spider(Spider):
result = {}
if len(self.cookies) <= 0:
self.getCookie()
url = 'https://api.bilibili.com/pgc/season/index/result?order={2}&pagesize=20&type=1&season_type={0}&page={1}&season_status={3}'.format(tid, pg, order, season_status)
url = 'https://api.bilibili.com/pgc/season/index/result?order={2}&pagesize=10&type=1&season_type={0}&page={1}&season_status={3}'.format(tid, pg, order, season_status)
rsp = self.fetch(url, cookies=self.cookies)
content = rsp.text
jo = json.loads(content)
......@@ -246,7 +250,7 @@ class Spider(Spider):
elif tid in {"2", "3", "4", "5", "7"}:
return self.get_rank2(tid=tid)
elif tid == "全部":
tid = '1'
tid = '1' # 全部界面默认展示最多播放的番剧
order = '2'
season_status = '-1'
if 'tid' in extend:
......@@ -309,10 +313,10 @@ class Spider(Spider):
ja = jo['episodes']
playUrl = ''
for tmpJo in ja:
eid = tmpJo['id']
aid = tmpJo['aid']
cid = tmpJo['cid']
part = tmpJo['title'].replace("#", "-")
playUrl = playUrl + '{0}${1}_{2}#'.format(part, eid, cid)
playUrl = playUrl + '{0}${1}_{2}#'.format(part, aid, cid)
vod['vod_play_from'] = 'B站'
vod['vod_play_url'] = playUrl
......@@ -369,9 +373,10 @@ class Spider(Spider):
"Referer": "https://www.bilibili.com",
"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"
}
url = 'https://api.bilibili.com/pgc/player/web/playurl?qn=116&ep_id={0}&cid={1}'.format(ids[0], ids[1])
url = 'https://api.bilibili.com/pgc/player/web/playurl?qn=116&aid={0}&cid={1}'.format(ids[0], ids[1])
if len(self.cookies) <= 0:
self.getCookie()
self.bilibili.post_history(ids[0], ids[1]) # 回传播放历史记录
rsp = self.fetch(url, cookies=self.cookies, headers=header)
jRoot = json.loads(rsp.text)
if jRoot['message'] != 'success':
......
......@@ -18,6 +18,7 @@ class Spider(Spider):
def getName(self):
return "哔哩直播"
# 主页
def homeContent(self, filter):
result = {}
cateManual = {
......@@ -88,7 +89,7 @@ class Spider(Spider):
if jo['code'] == 0:
return jo['data']["info"]["uname"]
def homeVideoContent(self):
def homeVideoContent(self,):
return self.get_hot(1)
def get_recommend(self, pg):
......@@ -120,7 +121,7 @@ class Spider(Spider):
def get_hot(self, pg):
result = {}
url = 'https://api.live.bilibili.com/room/v1/room/get_user_recommend?page=%s' % pg
url = 'https://api.live.bilibili.com/room/v1/room/get_user_recommend?page=%s&page_size=20' % pg
rsp = self.fetch(url, cookies=self.cookies)
content = rsp.text
jo = json.loads(content)
......@@ -201,7 +202,7 @@ class Spider(Spider):
def get_history(self):
result = {}
url = 'https://api.bilibili.com/x/web-interface/history/cursor?ps=30&type=live'
url = 'https://api.bilibili.com/x/web-interface/history/cursor?ps=10&type=live'
rsp = self.fetch(url, cookies=self.cookies)
content = rsp.text
jo = json.loads(content)
......@@ -302,7 +303,7 @@ class Spider(Spider):
vodList = jo['data']['result']['live_room']
for vod in vodList:
aid = str(vod['roomid']).strip()
title = vod['title'].strip() + "⇦" + key
title = "直播间:" + vod['title'].strip().replace("<em class=\"keyword\">", "").replace("</em>", "") + "⇦" + key
img = 'https:' + vod['user_cover'].strip()
remark = vod['watched_show']['text_small'].strip() + " " + vod['uname'].strip()
videos1.append({
......@@ -316,7 +317,7 @@ class Spider(Spider):
vodList = jo['data']['result']['live_user']
for vod in vodList:
aid = str(vod['roomid']).strip()
title = vod['uname'].strip().replace("<em class=\"keyword\">", "").replace("</em>", "") + "⇦" + key
title = "直播间:" + vod['uname'].strip().replace("<em class=\"keyword\">", "").replace("</em>", "") + " ⇦" + key
img = 'https:' + vod['uface'].strip()
remark = str(vod['live_status']).replace("0", "未开播").replace("1", "") + " 关注:" + self.zh(vod['attentions'])
videos2.append({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册