Skip to content

Commit

Permalink
🔧: Update to V4.0.9 -> #481
Browse files Browse the repository at this point in the history
  • Loading branch information
Evil0ctal committed Sep 26, 2024
1 parent 4f32221 commit 7d467ee
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
4 changes: 2 additions & 2 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ API:
Redoc_URL: /redoc # API documentation URL | API文档URL

# API Information
Version: V4.0.8 # API version | API版本
Update_Time: 2024/09/16 # API update time | API更新时间
Version: V4.0.9 # API version | API版本
Update_Time: 2024/09/25 # API update time | API更新时间
Environment: Demo # API environment | API环境

# Download Configuration
Expand Down
55 changes: 45 additions & 10 deletions crawlers/bilibili/web/web_crawler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
# ==============================================================================
# Copyright (C) 2021 Evil0ctal
#
# This file is part of the Douyin_TikTok_Download_API project.
#
# This project is licensed under the Apache License 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#         __
#        />  フ
#       |  _  _ l
#       /` ミ_xノ
#      /      | Feed me Stars ⭐ ️
#     /  ヽ   ノ
#     │  | | |
#  / ̄|   | | |
#  | ( ̄ヽ__ヽ_)__)
#  \二つ
# ==============================================================================
#
# Contributor Link:
#
# - https://github.com/Koyomi781
#
# ==============================================================================

import asyncio # 异步I/O
import os # 系统操作
import time # 时间操作
Expand All @@ -11,7 +45,6 @@
# 数据请求模型
from crawlers.bilibili.web.models import UserPostVideos, UserProfile, ComPopular, UserDynamic, PlayUrl


# 配置文件路径
path = os.path.abspath(os.path.dirname(__file__))

Expand All @@ -27,17 +60,18 @@ async def get_bilibili_headers(self):
bili_config = config['TokenManager']['bilibili']
kwargs = {
"headers": {
"accept-language": bili_config["headers"]["accept-language"],
"origin": bili_config["headers"]["origin"],
"referer": bili_config["headers"]["referer"],
"user-agent": bili_config["headers"]["user-agent"],
"cookie": bili_config["headers"]["cookie"],
"accept-language": bili_config["headers"]["accept-language"],
"origin": bili_config["headers"]["origin"],
"referer": bili_config["headers"]["referer"],
"user-agent": bili_config["headers"]["user-agent"],
"cookie": bili_config["headers"]["cookie"],
},
"proxies": {"http://": bili_config["proxies"]["http"], "https://": bili_config["proxies"]["https"]},
}
return kwargs

"-------------------------------------------------------handler接口列表-------------------------------------------------------"

# 获取单个视频详情信息
async def fetch_one_video(self, bv_id: str) -> dict:
# 获取请求头信息
Expand Down Expand Up @@ -116,8 +150,8 @@ async def fetch_folder_videos(self, folder_id: str, pn: int) -> dict:
base_crawler = BaseCrawler(proxies=kwargs["proxies"], crawler_headers=kwargs["headers"])
# 发送请求,获取请求响应结果
async with base_crawler as crawler:
endpoint = f"{BilibiliAPIEndpoints.COLLECT_VIDEOS}?media_id={folder_id}&pn={pn}&ps=20&keyword=&order=mtime&type=0&tid=0&platform=web"
response = await crawler.fetch_get_json(endpoint)
endpoint = f"{BilibiliAPIEndpoints.COLLECT_VIDEOS}?media_id={folder_id}&pn={pn}&ps=20&keyword=&order=mtime&type=0&tid=0&platform=web"
response = await crawler.fetch_get_json(endpoint)
return response

# 获取指定用户的信息
Expand Down Expand Up @@ -256,6 +290,7 @@ async def fetch_live_streamers(self, area_id: str, pn: int):
return response

"-------------------------------------------------------utils接口列表-------------------------------------------------------"

# 通过bv号获得视频aid号
async def bv_to_aid(self, bv_id: str) -> int:
aid = await bv2av(bv_id=bv_id)
Expand Down Expand Up @@ -288,9 +323,10 @@ async def fetch_all_live_areas(self) -> dict:
return response

"-------------------------------------------------------main-------------------------------------------------------"

async def main(self):
"""-------------------------------------------------------handler接口列表-------------------------------------------------------"""

"-------------------------------------------------------handler接口列表-------------------------------------------------------"
# 获取单个作品数据
# bv_id = 'BV1M1421t7hT'
# result = await self.fetch_one_video(bv_id=bv_id)
Expand Down Expand Up @@ -385,7 +421,6 @@ async def main(self):
# print(result)



if __name__ == '__main__':
# 初始化
BilibiliWebCrawler = BilibiliWebCrawler()
Expand Down

0 comments on commit 7d467ee

Please sign in to comment.