# GetBilibiliVideo:一个用于下载B站视频的开源命令行工具
## 项目简介
GetBilibiliVideo是一款旨在帮助用户从Bilibili网站下载视频或收藏夹内容的开源命令行程序。本项目通过简洁的命令行接口,允许用户灵活指定下载选项,如选择浏览器、硬件加速、编码格式以及缓存设置等。
### 功能特性
1. **链接抓取**:提供必选参数 `--url` 或 `-i` 来指定要下载的单个视频链接或收藏夹地址。
2. **自定义输出路径**:通过可选参数 `--output` 或 `-o` 指定视频保存路径,默认为当前工作目录。
3. **浏览器支持**:在获取cookies时可以选择不同的浏览器(Edge, Chrome, Firefox),默认为Edge。
4. **缓存功能**:启用 cookies 缓存以供后续使用,只需指定 `--cache` 参数。
5. **分页缓存**:对合集视频提供分页缓存功能,可通过 `--page` 或 `-p` 参数指定缓存的页数,默认缓存全部页面。
6. **硬件加速**:查询并支持FFmpeg硬件加速功能,根据系统可用的硬件加速器进行选择,列出可用的加速硬件供用户参考,使用 `--hwaccels` 参数。
7. **编码转换**:为了适配Windows平台播放,添加了将视频编码转换为H.264的功能,通过 `--libx264` 或 `--windows` 参数启用此功能,默认关闭。
### 使用示例
```bash
python gbv.py --url "https://www.bilibili.com/video/BV1UA4m1572K" --output "D:/Videos" --browser chrome --cache --page 2 --hwaccels vaapi --libx264
```
### 参数详解
- `--url` / `-i`: 必须提供,用于指定要下载的B站视频链接。
- `--output` / `-o`: 可选,设置下载视频的保存路径,默认为当前目录。
- `--browser` / `-b`: 可选,指定获取cookies时使用的浏览器(edge, chrome, firefox)。
- `--cache`: 可选,开启cookies缓存功能。
- `--page` / `-p`: 可选,设置下载合集视频的缓存页数,默认下载所有页。
- `--hwaccels`: 可选,启用FFmpeg硬件加速,并从检测到的硬件列表中选择一种。
- `--libx264` / `--windows`: 可选,启用H.264编码转换,便于在Windows平台上播放。
### 注意事项
请确保安装了FFmpeg,并正确配置了所需的硬件加速驱动。对于不支持的硬件加速选项,程序会发出警告信息并保持软件解码。
---
以上就是GetBilibiliVideo项目的简要介绍和使用说明,欢迎参与贡献代码或提出宝贵建议,共同优化和完善此项目。
![firefly](images/firefly.jpg)
Raw data
{
"_id": null,
"home_page": "https://github.com/PYmili/gbv",
"name": "gbv",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "PYmili",
"author_email": "mc2005wj@163.com",
"download_url": "https://files.pythonhosted.org/packages/52/55/78eb8bcd4fddeaec52c16c59ed9e844ff2f9b7375a9e090b5748e3d00cfd/gbv-0.1.2.tar.gz",
"platform": null,
"description": "# GetBilibiliVideo\uff1a\u4e00\u4e2a\u7528\u4e8e\u4e0b\u8f7dB\u7ad9\u89c6\u9891\u7684\u5f00\u6e90\u547d\u4ee4\u884c\u5de5\u5177\r\n\r\n## \u9879\u76ee\u7b80\u4ecb\r\n\r\nGetBilibiliVideo\u662f\u4e00\u6b3e\u65e8\u5728\u5e2e\u52a9\u7528\u6237\u4eceBilibili\u7f51\u7ad9\u4e0b\u8f7d\u89c6\u9891\u6216\u6536\u85cf\u5939\u5185\u5bb9\u7684\u5f00\u6e90\u547d\u4ee4\u884c\u7a0b\u5e8f\u3002\u672c\u9879\u76ee\u901a\u8fc7\u7b80\u6d01\u7684\u547d\u4ee4\u884c\u63a5\u53e3\uff0c\u5141\u8bb8\u7528\u6237\u7075\u6d3b\u6307\u5b9a\u4e0b\u8f7d\u9009\u9879\uff0c\u5982\u9009\u62e9\u6d4f\u89c8\u5668\u3001\u786c\u4ef6\u52a0\u901f\u3001\u7f16\u7801\u683c\u5f0f\u4ee5\u53ca\u7f13\u5b58\u8bbe\u7f6e\u7b49\u3002\r\n\r\n### \u529f\u80fd\u7279\u6027\r\n\r\n1. **\u94fe\u63a5\u6293\u53d6**\uff1a\u63d0\u4f9b\u5fc5\u9009\u53c2\u6570 `--url` \u6216 `-i` \u6765\u6307\u5b9a\u8981\u4e0b\u8f7d\u7684\u5355\u4e2a\u89c6\u9891\u94fe\u63a5\u6216\u6536\u85cf\u5939\u5730\u5740\u3002\r\n\r\n2. **\u81ea\u5b9a\u4e49\u8f93\u51fa\u8def\u5f84**\uff1a\u901a\u8fc7\u53ef\u9009\u53c2\u6570 `--output` \u6216 `-o` \u6307\u5b9a\u89c6\u9891\u4fdd\u5b58\u8def\u5f84\uff0c\u9ed8\u8ba4\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u3002\r\n\r\n3. **\u6d4f\u89c8\u5668\u652f\u6301**\uff1a\u5728\u83b7\u53d6cookies\u65f6\u53ef\u4ee5\u9009\u62e9\u4e0d\u540c\u7684\u6d4f\u89c8\u5668\uff08Edge, Chrome, Firefox\uff09\uff0c\u9ed8\u8ba4\u4e3aEdge\u3002\r\n\r\n4. **\u7f13\u5b58\u529f\u80fd**\uff1a\u542f\u7528 cookies \u7f13\u5b58\u4ee5\u4f9b\u540e\u7eed\u4f7f\u7528\uff0c\u53ea\u9700\u6307\u5b9a `--cache` \u53c2\u6570\u3002\r\n\r\n5. **\u5206\u9875\u7f13\u5b58**\uff1a\u5bf9\u5408\u96c6\u89c6\u9891\u63d0\u4f9b\u5206\u9875\u7f13\u5b58\u529f\u80fd\uff0c\u53ef\u901a\u8fc7 `--page` \u6216 `-p` \u53c2\u6570\u6307\u5b9a\u7f13\u5b58\u7684\u9875\u6570\uff0c\u9ed8\u8ba4\u7f13\u5b58\u5168\u90e8\u9875\u9762\u3002\r\n\r\n6. **\u786c\u4ef6\u52a0\u901f**\uff1a\u67e5\u8be2\u5e76\u652f\u6301FFmpeg\u786c\u4ef6\u52a0\u901f\u529f\u80fd\uff0c\u6839\u636e\u7cfb\u7edf\u53ef\u7528\u7684\u786c\u4ef6\u52a0\u901f\u5668\u8fdb\u884c\u9009\u62e9\uff0c\u5217\u51fa\u53ef\u7528\u7684\u52a0\u901f\u786c\u4ef6\u4f9b\u7528\u6237\u53c2\u8003\uff0c\u4f7f\u7528 `--hwaccels` \u53c2\u6570\u3002\r\n\r\n7. **\u7f16\u7801\u8f6c\u6362**\uff1a\u4e3a\u4e86\u9002\u914dWindows\u5e73\u53f0\u64ad\u653e\uff0c\u6dfb\u52a0\u4e86\u5c06\u89c6\u9891\u7f16\u7801\u8f6c\u6362\u4e3aH.264\u7684\u529f\u80fd\uff0c\u901a\u8fc7 `--libx264` \u6216 `--windows` \u53c2\u6570\u542f\u7528\u6b64\u529f\u80fd\uff0c\u9ed8\u8ba4\u5173\u95ed\u3002\r\n\r\n### \u4f7f\u7528\u793a\u4f8b\r\n\r\n```bash\r\npython gbv.py --url \"https://www.bilibili.com/video/BV1UA4m1572K\" --output \"D:/Videos\" --browser chrome --cache --page 2 --hwaccels vaapi --libx264\r\n```\r\n\r\n### \u53c2\u6570\u8be6\u89e3\r\n\r\n- `--url` / `-i`: \u5fc5\u987b\u63d0\u4f9b\uff0c\u7528\u4e8e\u6307\u5b9a\u8981\u4e0b\u8f7d\u7684B\u7ad9\u89c6\u9891\u94fe\u63a5\u3002\r\n- `--output` / `-o`: \u53ef\u9009\uff0c\u8bbe\u7f6e\u4e0b\u8f7d\u89c6\u9891\u7684\u4fdd\u5b58\u8def\u5f84\uff0c\u9ed8\u8ba4\u4e3a\u5f53\u524d\u76ee\u5f55\u3002\r\n- `--browser` / `-b`: \u53ef\u9009\uff0c\u6307\u5b9a\u83b7\u53d6cookies\u65f6\u4f7f\u7528\u7684\u6d4f\u89c8\u5668\uff08edge, chrome, firefox\uff09\u3002\r\n- `--cache`: \u53ef\u9009\uff0c\u5f00\u542fcookies\u7f13\u5b58\u529f\u80fd\u3002\r\n- `--page` / `-p`: \u53ef\u9009\uff0c\u8bbe\u7f6e\u4e0b\u8f7d\u5408\u96c6\u89c6\u9891\u7684\u7f13\u5b58\u9875\u6570\uff0c\u9ed8\u8ba4\u4e0b\u8f7d\u6240\u6709\u9875\u3002\r\n- `--hwaccels`: \u53ef\u9009\uff0c\u542f\u7528FFmpeg\u786c\u4ef6\u52a0\u901f\uff0c\u5e76\u4ece\u68c0\u6d4b\u5230\u7684\u786c\u4ef6\u5217\u8868\u4e2d\u9009\u62e9\u4e00\u79cd\u3002\r\n- `--libx264` / `--windows`: \u53ef\u9009\uff0c\u542f\u7528H.264\u7f16\u7801\u8f6c\u6362\uff0c\u4fbf\u4e8e\u5728Windows\u5e73\u53f0\u4e0a\u64ad\u653e\u3002\r\n\r\n### \u6ce8\u610f\u4e8b\u9879\r\n\r\n\u8bf7\u786e\u4fdd\u5b89\u88c5\u4e86FFmpeg\uff0c\u5e76\u6b63\u786e\u914d\u7f6e\u4e86\u6240\u9700\u7684\u786c\u4ef6\u52a0\u901f\u9a71\u52a8\u3002\u5bf9\u4e8e\u4e0d\u652f\u6301\u7684\u786c\u4ef6\u52a0\u901f\u9009\u9879\uff0c\u7a0b\u5e8f\u4f1a\u53d1\u51fa\u8b66\u544a\u4fe1\u606f\u5e76\u4fdd\u6301\u8f6f\u4ef6\u89e3\u7801\u3002\r\n\r\n---\r\n\r\n\u4ee5\u4e0a\u5c31\u662fGetBilibiliVideo\u9879\u76ee\u7684\u7b80\u8981\u4ecb\u7ecd\u548c\u4f7f\u7528\u8bf4\u660e\uff0c\u6b22\u8fce\u53c2\u4e0e\u8d21\u732e\u4ee3\u7801\u6216\u63d0\u51fa\u5b9d\u8d35\u5efa\u8bae\uff0c\u5171\u540c\u4f18\u5316\u548c\u5b8c\u5584\u6b64\u9879\u76ee\u3002\r\n\r\n![firefly](images/firefly.jpg)\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A package to get videos from Bilibili",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/PYmili/gbv"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "713f8e10dc096d355f444fcd2772696ebfa4e66e644ffa3c64f5552aa5a431ff",
"md5": "3e43e5e95cfcc37360e0a2549e750b17",
"sha256": "5b1e6009daa11a13c0d1d4ab9848d43da46fa929da637d1474872ae58f2c2ef4"
},
"downloads": -1,
"filename": "gbv-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3e43e5e95cfcc37360e0a2549e750b17",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 14082,
"upload_time": "2024-08-04T00:25:59",
"upload_time_iso_8601": "2024-08-04T00:25:59.511694Z",
"url": "https://files.pythonhosted.org/packages/71/3f/8e10dc096d355f444fcd2772696ebfa4e66e644ffa3c64f5552aa5a431ff/gbv-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "525578eb8bcd4fddeaec52c16c59ed9e844ff2f9b7375a9e090b5748e3d00cfd",
"md5": "645cd6956f9a1689ca70d836afd5ff56",
"sha256": "2994593d0155e17e8ac3b0cb14a47164f02e7a1575d8b6d13f30582d1398d6c3"
},
"downloads": -1,
"filename": "gbv-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "645cd6956f9a1689ca70d836afd5ff56",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 12312,
"upload_time": "2024-08-04T00:26:01",
"upload_time_iso_8601": "2024-08-04T00:26:01.296891Z",
"url": "https://files.pythonhosted.org/packages/52/55/78eb8bcd4fddeaec52c16c59ed9e844ff2f9b7375a9e090b5748e3d00cfd/gbv-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-04 00:26:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "PYmili",
"github_project": "gbv",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "beautifulsoup4",
"specs": [
[
"==",
"4.12.3"
]
]
},
{
"name": "bs4",
"specs": [
[
"==",
"0.0.2"
]
]
},
{
"name": "certifi",
"specs": [
[
"==",
"2024.2.2"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"3.3.2"
]
]
},
{
"name": "colorama",
"specs": [
[
"==",
"0.4.6"
]
]
},
{
"name": "fileid",
"specs": [
[
"==",
"0.2.1"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.6"
]
]
},
{
"name": "loguru",
"specs": [
[
"==",
"0.7.2"
]
]
},
{
"name": "lxml",
"specs": [
[
"==",
"5.1.0"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.31.0"
]
]
},
{
"name": "rookiepy",
"specs": [
[
"==",
"0.5.2"
]
]
},
{
"name": "setuptools",
"specs": [
[
"==",
"72.1.0"
]
]
},
{
"name": "soupsieve",
"specs": [
[
"==",
"2.5"
]
]
},
{
"name": "tqdm",
"specs": [
[
"==",
"4.66.1"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"2.2.0"
]
]
},
{
"name": "uuid",
"specs": [
[
"==",
"1.30"
]
]
},
{
"name": "win32-setctime",
"specs": [
[
"==",
"1.1.0"
]
]
}
],
"lcname": "gbv"
}