{"id":24881833,"url":"https://github.com/404name/bilibili-terminal","last_synced_at":"2025-10-16T00:31:26.659Z","repository":{"id":122599826,"uuid":"583038090","full_name":"404name/bilibili-terminal","owner":"404name","description":"🅱️ 基于termui实现的命令行版b站 | 支持MAC\u0026WIN #正在开发中","archived":false,"fork":false,"pushed_at":"2023-03-20T13:04:07.000Z","size":33619,"stargazers_count":14,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T16:38:39.828Z","etag":null,"topics":["bilibili","golang","termui"],"latest_commit_sha":null,"homepage":"https://www.yuque.com/404name/blog/fcz1rtt67x2i1ci4","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/404name.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-28T15:23:51.000Z","updated_at":"2025-04-07T08:15:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"2879261b-06f9-497a-a734-ba5be98330ee","html_url":"https://github.com/404name/bilibili-terminal","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/404name/bilibili-terminal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/404name%2Fbilibili-terminal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/404name%2Fbilibili-terminal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/404name%2Fbilibili-terminal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/404name%2Fbilibili-terminal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/404name","download_url":"https://codeload.github.com/404name/bilibili-terminal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/404name%2Fbilibili-terminal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279132500,"owners_count":26110578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bilibili","golang","termui"],"created_at":"2025-02-01T12:13:50.338Z","updated_at":"2025-10-16T00:31:25.754Z","avatar_url":"https://github.com/404name.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BiliBili-Terminal\n\n\u003e **分支[0.1.x](https://github.com/404name/bilibili-terminal/tree/refact_bubbletea_v0.1.0)基于bubbletea全新UI进行重构**，已兼容全平台`windows 需要 chcp 65001编码+nerd+终端完美显示`\n\n![](https://user-images.githubusercontent.com/56631419/226333547-dfcc0d4e-c204-45d2-9a4c-c5383f601e25.png)\n\n\u003e 本项目长期维护~目前仅开发分支\n\u003e \n\u003e 等待V 1.x.x版本应该才是可以使用的\n\u003e\n\u003e 【食用技巧for win】确保开启了unicode字符集`chcp 65001` + 安装了[nerd字体](https://www.nerdfonts.com/#home) + 使用windows terminal终端打开项目(即可完美显示图标内容)\n\n\n![](./resource/doc/bilibili.gif)\n\n\n\n## ChangeLog\n\u003e **feat** 新功能、**fix** 修补 bug、**docs** 文档、**style** 格式、**refactor** 重构、**test** 增加测试、**chore** 构建过程、辅助工具、**perf** 提高性能\n\u003e\n\u003e - [v.0.0.5版本b站视频演示](https://www.bilibili.com/video/BV1844y1d7Eg/?spm_id_from=333.999.0.0)\n\n\u003e 后面预期【0.0.6 配置和日志】、【0.0.7 首页布局制作\u0026音频同步视频】、【0.0.8 封装视频组件】\n\n| Date      | Versiton | Describe |Changelog                                  |\n| --------- | -------- | -------- |------------------------------------------ |\n| 2023.03.20 | v0.1.0   | 基于bubbletea全新UI进行重构~ |  🚀 **[feat]** 【重构框架及UI】/【暂时只支持刷新推荐列表+跳转】\u003cbr/\u003e ☀️ **[perf]** 添加action脚本自动构建产物|\n| 2023.01.09 | v0.0.8   | 使用ctx取消任务，优雅退出视频~ |  🚀 **[feat]** 【支持取消下载iocopy任务】/【支持取消cmd指令】 |\n| 2023.01.04 | v0.0.7   | 支持页面跳转、首页视频推荐~ |  🚀 **[feat]** 【首页视频推荐】/【选择视频跳转详细页】/【多了一堆线程bug~】 |\n| 2023.01.01 | v0.0.6   | viper读取配置、封装页面组件~ |  🚀 **[feat]** 【viper读取配置】/【log日志输出到窗口组件】/【封装page组件更为优雅】 |\n| 2022.12.29 | v0.0.5   | 支持中文！修复部分bug~ |  🚀 **[fix]** 【修复中文显示】/【修复结束不能重新播放】 |\n| 2022.12.29 | v0.0.4   | 支持bv解析了~ |  🚀 **[feat]** 【bv解析播放！】/【加载进度条】 |\n| 2022.12.29 | v0.0.3   | 支持音频了~ |  ☀️ **[perf]** 优化播放逻辑 \u003cbr/\u003e💬 **[fix]** 修复线上问题及添加gitignore  \u003cbr/\u003e🚀 **[feat]** 【支持音频播放！】/【同步拉取图片及音频】/ 【初步实现音视频同步播放】   |\n| 2022.12.28 | v0.0.2   | 优化架构，优化播放  | 📺 **[refactor]** 重构项目框架\u003cbr/\u003e☀️ **[perf]** 优化播放逻辑 \u003cbr/\u003e📑 **[docs]** 更新README文档  \u003cbr/\u003e🚀 **[feat]** 【实现响应式布局】/【实现进度条】/ 【实现预加载播放】   |\n| 2022.12.27  | v0.0.1   | 页面布局、支持视频播放  |  📺 **[init]** 初始化界面\u003cbr/\u003e🚀 **[feat]** 完成页面布局 \u003cbr/\u003e🚀 **[feat]** 实现视频播放  |\n\n\n\n## Features`V0.0.6`\n\u003e **系统进度** `[==\u003e20%------------------------]` \n\u003e **设计进度** `[========\u003e35%------------------]` \n\n* [x] 命令行播放视频\n* [x] 音频播放\n* [x] 直接解析bv `go run main.go -b BV1xx411c79H` \n* [x] 完成组件构建\n* [x] viper读取本地配置\n* [ ] 日志收集器\n* [ ] 弹幕解析 \n* [ ] ...\n\n\n## Build\n\u003e 1. **运行环境需要【[ffmpeg](https://juejin.cn/post/6992181270960685086)】**：命令行输入ffmpeg有输出即可\n\u003e \n\u003e 2. **编译环境需要【golang】**：我的是go1.9.4，理论上都行\n\n(win推荐使用[choco](https://juejin.cn/post/7009855843260710948)，任何环境直接`choco install xxx`搞定，完全不需要自己动手下载和配置环境变量)\n```bash\n# mod load\n$ go mod tidy\n# r启动\n$ go run main.go\n# 打包\n$ go build main.go\n```\n## 架构逻辑\n\n```\n├───core          服务组件(viper、zap)\n├───ffmpeg        视频抽帧音频分离逻辑\n├───global        全局变量或者服务\n├───output        输出内容\n│   ├───audio         分割的音频\n│   ├───img           分割的图片\n│   └───video         处理的视频\n├───resource      资源目录\n│   ├───images        本地图片(封面，视频暂停ui等)\n│   └───doc           readme里面的图片\n├───utils         工具\n└───view          页面视图\n└───main.go       主程序\n└───config.yaml   配置文件\n\n```\n1. 主程序负责启动项目\n```\n// 初始化页面逻辑\nInit()\n\n// 开始渲染\nfor {\n  select {\n  // 判断事件，然后系统事件这里处理\n  case e := \u003c-ui.PollEvents():\n    //println(e.ID)\n    switch e.ID {\n    case \"q\", \"\u003cC-c\u003e\":\n      return\n    // 页面事件交给页面处理\n    case \"\u003cResize\u003e\":\n      view.NowPage.Refresh()\n    default:\n      view.NowPage.EventHander(e)\n  }\n}\n\n```\n\n2. 页面组件封装\n\u003e 抽象页面组件，不同的页面只要实现【刷新】【关闭】【事件处理器】就可以了，main程序会负责分发\n\n```\ntype Page interface {\n\tRefresh()\n\tClose()\n\tEventHander(e termui.Event)\n}\n```\n\n3. 视频page举例子\n\u003e 视频页面封装了 termui的组件和视频内容通用熟悉，以及b站视频相关\n\n```\ntype VideoPage struct {\n\tvideo.VideoDetail\n\tGauge      *widgets.Gauge\n\tList       *widgets.List\n\tTab        *widgets.TabPane\n\tTabView    []interface{}\n\tGrid       *ui.Grid\n\tCurTabView interface{}\n}\n```\n- VideoDetail包括Img组件和进度条组件，同时提供如下方法\n  - Init() : 初始化\n  - DownLoad(): 解析bv号拿到下载链接并下载或者在线预览\n  - Load()：根据currentPos当前进度获取preload设定的缓存秒数后面的内容\n- VideoPage会启动一个视频播放线程，同时自己本身会响应主线程发来的事件\n\n##  TODO\n\n**近期**\n1. 缓存视频再播放\n2. 自定义日志,日志可以输出到面板\n3. 对接音频\n4. 继续重构架构\n\n\n**后期**\n\n1. 对接b站api\n2. 对接弹幕\n\n**已完成**\n1. ffmpeg 获取视频长度，做个进度条 \n2. 让视频刷新更快\n3. 尝试先缓存视频到本地再播放\n4. 包装ffmpeg出来\n二期\n1. 记录播放上次时间\n2. 根据resize设置不同的布局 长宽比小于1 就是手机layout 大于1就是电脑布局\n## Bugs\n\u003e qwq\n\n\n* [ ] P0:暂不支持中文(win)\n* [ ] P1:音视频不同步\n* [ ] p1:视频结束没出现结束界面及重新播放失效\n* [ ] P2:音频转换卡顿\n* [ ] P3:go 线程管理不到位，小概率卡死\n* [ ] ...\n\n\n\n## Dependence\n\n\n- github.com/gizak/termui/v3 **Go命令行UI组件库**\n- github.com/hajimehoshi/go-mp3  **音频播放组件**\n- github.com/hajimehoshi/oto/v2 **音频播放组件**\n- go.uber.org/zap **高性能日志库zap**\n\n---\n- https://github.com/iawia002/lux 参考项目\n- https://www.zhaoyanbai.com/articles/BilibiliGolangDownloader Go哔哩哔哩下载器\n\n## 备注\n\n- 后期把resource里面被项目引用的图片都转成base64存放\n  - 目前策略是读取不到resource就读取默认本地base64\n  - resource文件夹不会被打包的exe携带，最好用base64存放icon\n\n## License\n\n* [MIT](https://github.com/404name/bilibili-terminal/blob/master/LICENSE)\n\n## Copyright\n\n* **Author:** [404name](https://github.com/404name)\n* **AboutMe:** [here](https://yuque.com/404name)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F404name%2Fbilibili-terminal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F404name%2Fbilibili-terminal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F404name%2Fbilibili-terminal/lists"}