{"id":14958885,"url":"https://github.com/the-earth/bilibili-rate","last_synced_at":"2026-02-17T07:36:53.328Z","repository":{"id":164470131,"uuid":"157200594","full_name":"The-Earth/Bilibili-rate","owner":"The-Earth","description":"Artificial Idiot","archived":false,"fork":false,"pushed_at":"2018-12-27T08:36:01.000Z","size":58,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-07T16:32:59.974Z","etag":null,"topics":["bilibili","neural-network","tensorflow","tensorflow-experiments"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/The-Earth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-11-12T11:05:34.000Z","updated_at":"2020-04-11T10:51:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"f5eb4a6f-e6f4-4ad8-a1c3-c96f25a9dba5","html_url":"https://github.com/The-Earth/Bilibili-rate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/The-Earth/Bilibili-rate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-Earth%2FBilibili-rate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-Earth%2FBilibili-rate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-Earth%2FBilibili-rate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-Earth%2FBilibili-rate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/The-Earth","download_url":"https://codeload.github.com/The-Earth/Bilibili-rate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-Earth%2FBilibili-rate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018576,"owners_count":26086579,"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-14T02:00:06.444Z","response_time":60,"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","neural-network","tensorflow","tensorflow-experiments"],"created_at":"2024-09-24T13:18:27.024Z","updated_at":"2025-10-14T12:50:46.433Z","avatar_url":"https://github.com/The-Earth.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bilibili-rate\n\n使用神经网络对视频网站 [bilibili](https://www.bilibili.com) 的视频进行大致范围为 0-5 的评分，评分越高则越推荐用户观看。\n\n## 依赖\n\n```\ntensorflow==1.12.0\nmatplotlib==3.0.2\nrequets==2.21.0\n```\n\n调试时使用 Python：3.6.7\n\n## 使用\n\n建议在命令行中使用，主要的脚本是 `train.py` 和 `Main_Data.py` 。不论是进行训练还是进行预测，首先要确保要用到的视频数据存在于数据库中。使用 `Main_Data.py` ，可建立、读取、添加数据库内容，按提示操作。此后训练与预测分数均直接使用数据库中的信息。使用 `train.py` 进行神经网络的训练与预测。可使用指定范围的视频数据进行训练；选择指定范围的视频，输出预测的误差，查看某个视频的预测值。关于视频编号：若一个视频的链接为 `https://www.bilibili.com/video/av37786737` 则其视频编号为 `37786737`。\n\n## vid.py\n\n`getinfo(aid)` 的 aid 接收 Bilibili 视频编号，函数返回一个字典，包含所需的视频信息。字典中的 key 参见 datastructure.txt 的示例。若 aid 对应的视频不存在，则会返回一个整数 404，使用中应注意检查返回值是否为 404。\n\n可以遍历一段视频编号，循环中调用 `getinfo(aid)` 批量获取数据。在同目录下在其他 `.py` 文件中调用示例：\n\n```python\nimport vid\n\ndata = []\nfor aid in range(36020000, 36020100):\n    data.append(vid.getinfo(aid))\n# rest of code\n```\n\n上面的示例中，`data` 中以 `list` 形式存储了一个个包含视频数据的字典。\n\n感谢：[Bilibili-data](https://github.com/FQrabbit/bilibili-data)\n\n## bilibilisupport.py\n\n存储 Bilibili api 信息，在 `vid.py` 中使用。\n\n## DataProcess.py\n\n数据存储核心脚本，调用 `vid.py` 实现抓取，并存入数据库文件，读取数据库也通过这个脚本。`Builtdatabase()` 是在同级目录下建立数据库文件；`InsertData(aid)` 根据视频编号aid，爬取视频特征数据，并存入数据库；`ExportData(aid)` 根据视频编号aid,在数据库中查找目标数据并按列表返回。\n\n使用 SQLite 数据库，字段包括视频编号、评论数、分区、播放数、收藏数、上传者、硬币数等信息以及评分。**说明**：这里使用了非线性的公式计算得出分数（大量视频一个个看太辛苦了），基本上符合我们的偏好。因此神经网络在这里的作用相当于复现这个非线性模型。\n\n## Main_Data.py\n\n数据库接口，帮助人工操作数据库文件。\n\n## train.py\n\n`train()` 读取指定编号范围内数据库内容并训练网络。若检测到现存模型，则先读取模型后训练。输入层 `invec` 接收训练数据，传递给 `hl1` 、`hl2` 最后到 `prediction` 层，与 `out` 数据比对得到误差 `loss` 。`fig` 参数控制是否绘制误差变化图（若选择输出，则保存在 `loss_process.png`，范围内最后一个视频须存在，否则输出图里不会有内容）。训练 100 次，可选择是否输出误差变化图。模型存于 `./tf/` 目录下，tensorboard 数据流图存于 `./graph/`。\n\n`lossdis()` 用模型计算指定编号范围内视频的分数，并与目标值对比得到误差，输出散点图 `loss_dis.png`（横坐标视频编号，纵坐标误差值）。\n\n`predict()` 读取已训练模型，输出指定视频的评分。\n\n视频数据通过调用 `DataProcess.py` 读取数据库获得。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-earth%2Fbilibili-rate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthe-earth%2Fbilibili-rate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-earth%2Fbilibili-rate/lists"}