main
leiurayer 2 months ago
parent 2c227d5d26
commit 7262904943

@ -1,238 +0,0 @@
# 更新日志
## `2023/12/10` v1.6.1
* [优化] 如果存在下载完成列表,弹出选择框是否再次下载。
* [修复] 更新wbi签名算法解决无法解析下载视频的问题。
## `2023/12/09` v1.6.0
* [优化] 下载列表弹出框。
* [优化] 添加任务栏图标。
* [优化] 视频流API、视频详细信息API。
* [修复] 文件名导致的闪退问题。
* [修复] 程序反复读取设置文件的问题。
* [修复] 修复扫码登录的问题。
* [修复] 在下载设置窗口界面取消或关闭窗口之后导致的DownKyi闪退问题 #907
## `2023/05/24` v1.5.9
* [新增] 下载完成系统提示。
* [修复] UP主个人空间访问。
## `2023/04/30` v1.5.8
* [新增] 视频详情页搜索功能。
* [优化] 确认下载路径之前检查盘符是否存在。
* [优化] 弹出框的UI。
* [优化] 音质描述【普通音质有3档质量但不是固定的320K或192K因此仅用高中低表述以免产生误解】。
* [修复] 下载管理在只下载音频的情况下点击打开文件夹无响应。
* [修复] 解决tabId溢出的问题。
## `2023/02/18` v1.5.7
* [新增] 自定义UserAgent。
* [新增] 程序检查更新。
* [优化] 下载前检测无效的下载目录。
* [优化] 更新依赖版本。
* [优化] 输出Aria2错误信息到UI。
* [修复] 默认编码为AVC但画质为杜比视界时不会自动选中HEVC编码的问题。
* [修复] 删除下载项时内建下载器崩溃的问题。
## `2023/01/06` v1.5.6
* [修复] 文件名包含非法字符。
* [修复] 多线程下载的bug。
* [修复] 弹幕无法下载的bug。
## `2022/11/06` v1.5.5
* [优化] 更新分区列表。
* [优化] 更新依赖包。
* [新增] 关注和粉丝页面。
* [修复] 命名格式无AV1编码的问题。
* [修复] 优先解析视频编码顺序为AV1、HEVC、AVC。
* [修复] 自定义aria服务器监听端口设置无效的问题。
## `2022/10/16` v1.5.4
* [新增] 支持AV1编码视频。
* [新增] 支持Hi-Res无损音频格式。
* [新增] 支持UP主用户空间的合集和列表。
* [新增] 支持自定义aria服务器。
* [新增] 音视频分离支持多选。
* [修复] 视频无杜比视界时支持杜比全景声。
## `2022/06/05` v1.5.3
* [优化] 封面命名。
* [新增] 启用https控制。
* [新增] 支持出行分区。
* [新增] 下载管理页面入口。
* [修复] 批量操作时偶尔崩溃的问题。
* [修复] 监听剪贴板失效的问题。
## `2022/05/09` v1.5.2
* [优化] 更新依赖版本。
* [新增] 内建下载器。
* [新增] 下载器切换设置。
* [修复] 问题 SSL/TLS handshake failure。
---
* `2022/05/09` v1.5.1
1. [优化] 当复制视频详情页的输入框中的字符时,不读取剪贴板内容。
2. [优化] Aria下载器添加header。
3. [新增] 向下载管理页面添加弹窗提示。
4. [新增] 文件命名模块中序号格式设置。
5. [新增] 支持WebP图像。
6. [修复] 未获取到杜比全景声却仍然显示出此选项的问题。
7. [修复] 运动分区无法显示的问题。
8. [修复] 文件名异常导致的下载失败。
9. [修复] 偶尔VideoSection重复的问题。
* `2022/04/04` v1.5.0
1. [优化] 跳过数据库中的不完整数据。
2. [优化] 文件命名格式设置支持拖拽。
3. [修复] 下载完成后的动作设置无效的问题。
4. [修复] 视频BV1rr4y1i74o无法加载的问题。
5. [修复] 下载内容设置偶尔不生效的问题。
* `2022/03/26` v1.5.0-alpha7
1. [优化] 批量下载时过滤UGC、其他季或花絮内容。
2. [优化] 保存下载视频内容到设置。
3. [优化] 更新ffmpeg为gpl版本。
4. [优化] 默认的aria的文件预分配改为NONE。
5. [新增] “解析后自动下载已解析视频”设置。
6. [修复] 只下载音频失败的问题。
7. [修复] Settings被占用无法读取的问题。
8. [修复] 因路径导致无法下载的问题。
9. [修复] 无法正确关闭数据库的问题。
* `2022/03/20` v1.5.0-alpha6
1. [修复] 一些已知问题。
* `2022/03/19` v1.5.0-alpha5
1. [优化] 文件命名格式中,时间格式可设置。
2. [修复] 数据库异常锁定的问题。
3. [修复] 视频标题和分P标题相同时找不到下载文件的问题。
4. [修复] 150%缩放下的窗口不超出屏幕。
5. [修复] 其他已知问题。
* `2022/03/13` v1.5.0-alpha4
1. [优化] 配置文件目录改为当前程序目录。
2. [修复] 部分UI显示。
3. [修复] 因数据库中的重复内容导致的闪退问题。
4. [修复] 其他已知问题。
* `2022/03/12` v1.5.0-alpha3
1. [修复] 当用户性别为保密时,程序闪退的问题。
2. [修复] 批量下载UP主视频时程序偶尔闪退的问题。
3. [修复] 其他已知问题。
* `2022/03/07` v1.5.0-alpha2
1. [优化] 重构程序架构,解决一些已知问题。
2. [优化] 界面UI的显示与操作。
3. [新增] 文件命名格式avid、bvid、cid、UP主信息、视频发布时间。
4. [修复] 视频音质列表导致的闪退问题。
5. [修复] 图片下载导致的闪退问题。
* `2022/03/05` v1.5.0-alpha1
1. [优化] 重构程序架构,解决一些已知问题。
2. [新增] 最高支持8K视频。
3. [新增] 支持杜比全景声和杜比视界。
4. [新增] 支持字幕下载。
5. [新增] 支持部分短链接(如 <https://b23.tv/BV17x411w7KC> )。
6. [新增] 下载内容可选,可根据需要选择下载视频、音频、弹幕、字幕、封面。
7. [新增] 下载文件命名模块,可自主设置文件名。
* `2021/06/12` v1.4.0
1. [修复] 视频无封面时崩溃的问题。
2. [优化] 视频分区代码与图标。
3. [优化] 屏蔽频道中的失效视频。
4. [优化] 二维码登录逻辑。
5. [新增] 弹幕下载(借鉴并重写于项目 [niconvert](https://github.com/muzuiget/niconvert))。
6. [新增] 弹幕样式设置。
7. [新增] 下载弹幕、下载封面的选项。
* `2021/04/27` v1.3.8
1. [修复] FLV视频只有1个分段时下载失败的问题。
2. [修复] UP主视频页面闪退的问题。
3. [修复] 电视剧图标丢失的问题。
4. [新增] UP主视频页面下载全部视频的按钮。
* `2021/03/28` v1.3.7
1. [修复] 播放数为空白的视频存在时,整页视频列表无法加载的问题。
2. [修复] 特殊字符(控制字符、末尾空格等)导致的下载失败。
3. [修复] 由于某些封面图片metadata损坏导致的程序崩溃。
4. [修复] 监听剪贴板数据异常报错的问题。
5. [优化] 部分界面显示。
6. [优化] 程序逻辑。
7. [新增] 监听剪贴板和自动解析的设置持久化。
8. [新增] 列表支持shift&ctrl多选。
9. [新增] 下载中列表重试按钮。
* `2021/03/04` v1.3.6
1. [修复] 下载FLV时失败的问题。
2. [修复] 主页的登录信息更新不及时的问题。
3. [优化] 主页下方按钮居中。
4. [优化] 首页搜索框添加搜索按钮,点击可进行搜索。
5. [新增] 监听剪贴板。
6. [新增] 已下载视频列表排序。
7. [新增] 下载管理页面增加全部暂停、全部开始、全部删除。
* `2021/02/21` v1.3.5
1. [修复] 分P标题相同时会下载失败的问题。
2. [修复] 个人空间中的头像可能显示不全的问题。
3. [优化] 订阅页面采用分页显示。
4. [优化] 增强程序健壮性。
5. [优化] 部分界面UI。
6. [优化] 视频详情页获取视频后不自动解析下载链接。
7. [新增] 视频详情页“自动解析”选项,“解析视频”按钮,列表右键菜单“解析”。
8. [新增] 视频详情页支持输入av号和BV号。
9. [新增] 视频详情页的UP主头像增加进入用户空间的入口。
10. [新增] 历史记录和稍后再看的up主头像增加进入用户空间的入口。
* `2021/02/10` v1.3.4
1. [修复] 修复在未登录时进入UP主用户空间程序崩溃的问题。
2. [优化] 更新视频分区。
3. [优化] 视频数为0的频道不显示。
4. [优化] 部分界面UI。
* `2021/01/30` v1.3.3
1. [修复] 输入avid和bvid可能无法解析的问题。
2. [优化] 程序的一些显示。
3. [优化] 程序核心代码结构。
4. [新增] 访问用户空间。
5. [新增] UP主投稿视频列表展示。
6. [新增] UP主频道列表展示。
7. [新增] 意见反馈入口将进入github的issue页。
* `2021/01/05` v1.3.2 beta
1. [修复] 向Aria添加下载时参数错误问题。
2. [修复] 分P标题为空时标题为总标题+数字。
3. [优化] 更新视频分区。
4. [优化] 文件夹、订阅、稍后再看的健壮性。
* `2021/01/01` v1.3.1 beta
1. [修复] Aria2c下载时出现503错误的问题。
2. [修复] 选择文件夹时,若取消选择仍然会添加到下载的问题。
3. [修复] 标题中含有转义字符时的问题。
4. [修复] 其他已知问题。
5. [优化] 启动时先杀死以开启的Aria2c进程。
6. [优化] 关于页面添加github链接。
* `2020/12/26` v1.3.0 beta
1. [新增] 使用Aria下载器。
2. [新增] 暂停、继续、删除下载项功能。
3. [新增] 下载时自动下载视频封面。
4. [新增] B站助手工具包括av与bv互转弹幕发送者查询。
5. [优化] 工具箱页面的按钮的样式。
6. [优化] 更新QRCoder版本到1.4.1。
7. [新增] 在视频详情页添加解析后自动下载所有选项。
8. [新增] 支持avid和bvid输入。
9. [修复] 在没有解析完网址的时候粘贴新的网址会出现闪退的问题。
10. [优化] 下载管理上方控制面板是否显示根据已下载视频数量动态变化。
11. [新增] 下载列表的历史记录,重启程序后恢复下载。
12. [新增] 视频详情页的封面增加右键菜单复制封面图片、复制封面url。

@ -1,75 +1 @@
# 哔哩下载姬
<p align="center">
<a href="https://github.com/leiurayer/downkyi/stargazers" style="text-decoration:none" >
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/leiurayer/downkyi">
</a>
<a href="https://github.com/leiurayer/downkyi/network" style="text-decoration:none" >
<img alt="GitHub forks" src="https://img.shields.io/github/forks/leiurayer/downkyi">
</a>
<a href="https://github.com/leiurayer/downkyi/issues" style="text-decoration:none">
<img alt="GitHub issues" src="https://img.shields.io/github/issues/leiurayer/downkyi">
</a>
<a href="https://github.com/leiurayer/downkyi/blob/main/LICENSE" style="text-decoration:none" >
<img alt="GitHub" src="https://img.shields.io/github/license/leiurayer/downkyi">
</a>
</p>
![index.png](https://s2.loli.net/2022/06/04/dOsqtfBXceRgrj2.png)
哔哩下载姬DownKyi是一个简单易用的哔哩哔哩视频下载工具具有简洁的界面流畅的操作逻辑。哔哩下载姬可以下载几乎所有的B站视频并输出mp4格式的文件采用Aria下载器多线程下载采用FFmpeg对视频进行混流、提取音视频等操作。
[更多详情](src/README.md)
## 下载
<p align="left">
<a href="https://github.com/leiurayer/downkyi/releases/latest" style="text-decoration:none">
<img alt="GitHub release (latest by date)" src="https://img.shields.io/github/v/release/leiurayer/downkyi">
</a>
<a href="https://github.com/leiurayer/downkyi/releases/latest" style="text-decoration:none">
<img alt="GitHub Release Date" src="https://img.shields.io/github/release-date/leiurayer/downkyi">
</a>
<a href="https://github.com/leiurayer/downkyi/releases" style="text-decoration:none">
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/leiurayer/downkyi/total">
</a>
</p>
[更新日志](CHANGELOG.md)
## 问题
- Aria下载失败检查aria2c.exe是否可以正常工作和是否允许通过防火墙或者尝试切换端口号。
- 内建下载器失败请提issue也欢迎pr。
- 下载时卡在“混流中”检查ffmpeg.exe是否可以正常工作。
- 去水印:宽/高为水印的尺寸X/Y为水印在图像中的位置以左上角为原点这四个数据可通过Photoshop获得。
## 赞助
如果这个项目对您有很大帮助,并且您希望支持该项目的开发和维护,请随时扫描一下二维码进行捐赠。非常感谢您的捐款,谢谢!
![Alipay.png](https://s2.loli.net/2022/06/04/6LpfinSa5FoZmNB.png)![WeChat.png](https://s2.loli.net/2022/06/04/2yotOSvwmahPdXU.png)
## 开发
### x86 & x64
发布的压缩包中aria2c.exe和ffmpeg.exe均为32位如果需要请用下面链接中的文件替换。
- [aria2-1.36.0-win-32bit](third_party/aria2-1.36.0-win-32bit-build1.zip)
- [aria2-1.36.0-win-64bit](third_party/aria2-1.36.0-win-64bit-build1.zip)
- [FFmpeg](https://github.com/leiurayer/FFmpeg-Builds/releases/tag/latest)
### 相关项目
- [哔哩哔哩-API收集整理](https://github.com/SocialSisterYi/bilibili-API-collect)B站API归档
- [Prism](https://github.com/PrismLibrary/Prism)MVVM框架
- [WebPSharp](https://github.com/leiurayer/WebPSharp)WebP格式图片支持[NuGet程序包](third_party/WebPSharp.0.5.1.nupkg)
## 免责申明
1. 本软件只提供视频解析,不提供任何资源上传、存储到服务器的功能。
2. 本软件仅解析来自B站的内容不会对解析到的音视频进行二次编码部分视频会进行有限的格式转换、拼接等操作。
3. 本软件解析得到的所有内容均来自B站UP主上传、分享其版权均归原作者所有。内容提供者、上传者UP主应对其提供、上传的内容承担全部责任。
4. **本软件提供的所有内容仅可用作学习交流使用未经原作者授权禁止用于其他用途。请在下载24小时内删除。为尊重作者版权请前往资源的原始发布网站观看支持原创谢谢。**
5. 因使用本软件产生的版权问题,软件作者概不负责。

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

63
src/.gitattributes vendored

@ -1,63 +0,0 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

363
src/.gitignore vendored

@ -1,363 +0,0 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

@ -1,140 +0,0 @@
using DownKyi.Core.Aria2cNet.Client;
using DownKyi.Core.Aria2cNet.Client.Entity;
using DownKyi.Core.Logging;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace DownKyi.Core.Aria2cNet
{
public class AriaManager
{
// gid对应项目的状态
public delegate void TellStatusHandler(long totalLength, long completedLength, long speed, string gid);
public event TellStatusHandler TellStatus;
protected virtual void OnTellStatus(long totalLength, long completedLength, long speed, string gid)
{
TellStatus?.Invoke(totalLength, completedLength, speed, gid);
}
// 下载结果回调
public delegate void DownloadFinishHandler(bool isSuccess, string downloadPath, string gid, string msg = null);
public event DownloadFinishHandler DownloadFinish;
protected virtual void OnDownloadFinish(bool isSuccess, string downloadPath, string gid, string msg = null)
{
DownloadFinish?.Invoke(isSuccess, downloadPath, gid, msg);
}
// 全局下载状态
public delegate void GetGlobalStatusHandler(long speed);
public event GetGlobalStatusHandler GlobalStatus;
protected virtual void OnGlobalStatus(long speed)
{
GlobalStatus?.Invoke(speed);
}
/// <summary>
/// 获取gid下载项的状态
///
/// TODO
/// 对于下载的不同状态的返回值的测试
/// </summary>
/// <param name="gid"></param>
/// <param name="action"></param>
/// <returns></returns>
public DownloadResult GetDownloadStatus(string gid, Action action = null)
{
string filePath = "";
while (true)
{
Task<AriaTellStatus> status = AriaClient.TellStatus(gid);
if (status == null || status.Result == null) { continue; }
if (status.Result.Result == null && status.Result.Error != null)
{
if (status.Result.Error.Message.Contains("is not found"))
{
OnDownloadFinish(false, null, gid, status.Result.Error.Message);
return DownloadResult.ABORT;
}
}
if (status.Result.Result.Files != null && status.Result.Result.Files.Count >= 1)
{
filePath = status.Result.Result.Files[0].Path;
}
long totalLength = long.Parse(status.Result.Result.TotalLength);
long completedLength = long.Parse(status.Result.Result.CompletedLength);
long speed = long.Parse(status.Result.Result.DownloadSpeed);
// 回调
OnTellStatus(totalLength, completedLength, speed, gid);
// 在外部执行
if (action != null)
{
action.Invoke();
}
if (status.Result.Result.Status == "complete")
{
break;
}
if (status.Result.Result.ErrorCode != null && status.Result.Result.ErrorCode != "0")
{
if (status.Result != null)
{
Utils.Debugging.Console.PrintLine("ErrorMessage: " + status.Result.Result.ErrorMessage);
LogManager.Error("AriaManager", status.Result.Result.ErrorMessage);
}
//// 如果返回状态码不是200则继续
//if (status.Result.Result.ErrorMessage.Contains("The response status is not successful"))
//{
// Thread.Sleep(1000);
// continue;
//}
// aira中删除记录
Task<AriaRemove> ariaRemove1 = AriaClient.RemoveDownloadResultAsync(gid);
Utils.Debugging.Console.PrintLine(ariaRemove1);
if (ariaRemove1.Result != null)
{
LogManager.Debug("AriaManager", ariaRemove1.Result.Result);
}
// 返回回调信息,退出函数
OnDownloadFinish(false, null, gid, status.Result.Result.ErrorMessage);
return DownloadResult.FAILED;
}
// 降低CPU占用
Thread.Sleep(100);
}
OnDownloadFinish(true, filePath, gid, null);
return DownloadResult.SUCCESS;
}
/// <summary>
/// 获取全局下载速度
/// </summary>
public async void GetGlobalStatus()
{
while (true)
{
// 查询全局status
AriaGetGlobalStat globalStatus = await AriaClient.GetGlobalStatAsync();
if (globalStatus == null || globalStatus.Result == null) { continue; }
long globalSpeed = long.Parse(globalStatus.Result.DownloadSpeed);
// 回调
OnGlobalStatus(globalSpeed);
// 降低CPU占用
Thread.Sleep(100);
}
}
}
}

File diff suppressed because it is too large Load Diff

@ -1,25 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaAddMetalink
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public string Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,25 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaAddTorrent
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public string Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,30 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
//{
//"id": "downkyi",
//"jsonrpc": "2.0",
//"result": "1aac102a4875c8cd"
//}
[JsonObject]
public class AriaAddUri
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public string Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,25 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaChangeOption
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public string Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,25 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaChangePosition
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public int Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,26 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaChangeUri
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public List<int> Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,23 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
//"error": {
// "code": 1,
// "message": "Unauthorized"
//}
[JsonObject]
public class AriaError
{
[JsonProperty("code")]
public int Code { get; set; }
[JsonProperty("message")]
public string Message { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,53 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaGetFiles
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public List<AriaUri> Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
[JsonObject]
public class AriaGetFilesResult
{
[JsonProperty("completedLength")]
public string CompletedLength { get; set; }
[JsonProperty("index")]
public string Index { get; set; }
[JsonProperty("length")]
public string Length { get; set; }
[JsonProperty("path")]
public string Path { get; set; }
[JsonProperty("selected")]
public string Selected { get; set; }
[JsonProperty("uris")]
public List<AriaUri> Uris { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,66 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
/*
{
"id": "qwer",
"jsonrpc": "2.0",
"result": {
"downloadSpeed": "0",
"numActive": "0",
"numStopped": "0",
"numStoppedTotal": "0",
"numWaiting": "0",
"uploadSpeed": "0"
}
}
*/
[JsonObject]
public class AriaGetGlobalStat
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public AriaGetGlobalStatResult Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
[JsonObject]
public class AriaGetGlobalStatResult
{
[JsonProperty("downloadSpeed")]
public string DownloadSpeed { get; set; }
[JsonProperty("numActive")]
public string NumActive { get; set; }
[JsonProperty("numStopped")]
public string NumStopped { get; set; }
[JsonProperty("numStoppedTotal")]
public string NumStoppedTotal { get; set; }
[JsonProperty("numWaiting")]
public string NumWaiting { get; set; }
[JsonProperty("uploadSpeed")]
public string UploadSpeed { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,25 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaGetOption
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public AriaOption Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,62 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaGetPeers
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public List<AriaPeer> Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
[JsonObject]
public class AriaPeer
{
[JsonProperty("amChoking")]
public string AmChoking { get; set; }
[JsonProperty("bitfield")]
public string Bitfield { get; set; }
[JsonProperty("downloadSpeed")]
public string DownloadSpeed { get; set; }
[JsonProperty("ip")]
public string Ip { get; set; }
[JsonProperty("peerChoking")]
public string PeerChoking { get; set; }
[JsonProperty("peerId")]
public string PeerId { get; set; }
[JsonProperty("port")]
public string Port { get; set; }
[JsonProperty("seeder")]
public string Seeder { get; set; }
[JsonProperty("uploadSpeed")]
public string UploadSpeed { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,59 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaGetServers
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public List<AriaGetServersResult> Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
[JsonObject]
public class AriaGetServersResult
{
[JsonProperty("index")]
public string Index { get; set; }
[JsonProperty("servers")]
public List<AriaResultServer> Servers { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
[JsonObject]
public class AriaResultServer
{
[JsonProperty("currentUri")]
public string CurrentUri { get; set; }
[JsonProperty("downloadSpeed")]
public string DownloadSpeed { get; set; }
[JsonProperty("uri")]
public string Uri { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,37 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaGetSessionInfo
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public AriaGetSessionInfoResult Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
[JsonObject]
public class AriaGetSessionInfoResult
{
[JsonProperty("sessionId")]
public string SessionId { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,26 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaGetUris
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public List<AriaUri> Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,244 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaOption
{
[JsonProperty("all-proxy")]
public string AllProxy { get; set; }
[JsonProperty("allow-overwrite")]
public string AllowOverwrite { get; set; }
[JsonProperty("allow-piece-length-change")]
public string AllowPieceLengthChange { get; set; }
[JsonProperty("always-resume")]
public string AlwaysResume { get; set; }
[JsonProperty("async-dns")]
public string AsyncDns { get; set; }
[JsonProperty("auto-file-renaming")]
public string AutoFileRenaming { get; set; }
[JsonProperty("bt-enable-hook-after-hash-check")]
public string BtEnableHookAfterHashCheck { get; set; }
[JsonProperty("bt-enable-lpd")]
public string BtEnableLpd { get; set; }
[JsonProperty("bt-force-encryption")]
public string BtForceEncryption { get; set; }
[JsonProperty("bt-hash-check-seed")]
public string BtHashCheckSeed { get; set; }
[JsonProperty("bt-load-saved-metadata")]
public string BtLoadSavedMetadata { get; set; }
[JsonProperty("bt-max-peers")]
public string BtMaxPeers { get; set; }
[JsonProperty("bt-metadata-only")]
public string BtMetadataOnly { get; set; }
[JsonProperty("bt-min-crypto-level")]
public string BtMinCryptoLevel { get; set; }
[JsonProperty("bt-remove-unselected-file")]
public string BtRemoveUnselectedFile { get; set; }
[JsonProperty("bt-request-peer-speed-limit")]
public string BtRequestPeerSpeedLimit { get; set; }
[JsonProperty("bt-require-crypto")]
public string BtRequireCrypto { get; set; }
[JsonProperty("bt-save-metadata")]
public string BtSaveMetadata { get; set; }
[JsonProperty("bt-seed-unverified")]
public string BtSeedUnverified { get; set; }
[JsonProperty("bt-stop-timeout")]
public string BtStopTimeout { get; set; }
[JsonProperty("bt-tracker-connect-timeout")]
public string BtTrackerConnectTimeout { get; set; }
[JsonProperty("bt-tracker-interval")]
public string BtTrackerInterval { get; set; }
[JsonProperty("bt-tracker-timeout")]
public string BtTrackerTimeout { get; set; }
[JsonProperty("check-integrity")]
public string CheckIntegrity { get; set; }
[JsonProperty("conditional-get")]
public string ConditionalGet { get; set; }
[JsonProperty("connect-timeout")]
public string ConnectTimeout { get; set; }
[JsonProperty("content-disposition-default-utf8")]
public string ContentDispositionDefaultUtf8 { get; set; }
[JsonProperty("continue")]
public string Continue { get; set; }
[JsonProperty("dir")]
public string Dir { get; set; }
[JsonProperty("dry-run")]
public string DryRun { get; set; }
[JsonProperty("enable-http-keep-alive")]
public string EnableHttpKeepAlive { get; set; }
[JsonProperty("enable-http-pipelining")]
public string EnableHttpPipelining { get; set; }
[JsonProperty("enable-mmap")]
public string EnableMmap { get; set; }
[JsonProperty("enable-peer-exchange")]
public string EnablePeerExchange { get; set; }
[JsonProperty("file-allocation")]
public string FileAllocation { get; set; }
[JsonProperty("follow-metalink")]
public string FollowMetalink { get; set; }
[JsonProperty("follow-torrent")]
public string FollowTorrent { get; set; }
[JsonProperty("force-save")]
public string ForceSave { get; set; }
[JsonProperty("ftp-pasv")]
public string FtpPasv { get; set; }
[JsonProperty("ftp-reuse-connection")]
public string FtpReuseConnection { get; set; }
[JsonProperty("ftp-type")]
public string FtpType { get; set; }
[JsonProperty("hash-check-only")]
public string HashCheckOnly { get; set; }
[JsonProperty("http-accept-gzip")]
public string HttpAcceptGzip { get; set; }
[JsonProperty("http-auth-challenge")]
public string HttpAuthChallenge { get; set; }
[JsonProperty("http-no-cache")]
public string HttpNoCache { get; set; }
[JsonProperty("lowest-speed-limit")]
public string LowestSpeedLimit { get; set; }
[JsonProperty("max-connection-per-server")]
public string MaxConnectionPerServer { get; set; }
[JsonProperty("max-download-limit")]
public string MaxDownloadLimit { get; set; }
[JsonProperty("max-file-not-found")]
public string MaxFileNotFound { get; set; }
[JsonProperty("max-mmap-limit")]
public string MaxMmapLimit { get; set; }
[JsonProperty("max-resume-failure-tries")]
public string MaxResumeFailureTries { get; set; }
[JsonProperty("max-tries")]
public string MaxTries { get; set; }
[JsonProperty("max-upload-limit")]
public string MaxUploadLimit { get; set; }
[JsonProperty("metalink-enable-unique-protocol")]
public string MetalinkEnableUniqueProtocol { get; set; }
[JsonProperty("metalink-preferred-protocol")]
public string MetalinkPreferredProtocol { get; set; }
[JsonProperty("min-split-size")]
public string MinSplitSize { get; set; }
[JsonProperty("no-file-allocation-limit")]
public string NoFileAllocationLimit { get; set; }
[JsonProperty("no-netrc")]
public string NoNetrc { get; set; }
[JsonProperty("out")]
public string Out { get; set; }
[JsonProperty("parameterized-uri")]
public string ParameterizedUri { get; set; }
[JsonProperty("pause-metadata")]
public string PauseMetadata { get; set; }
[JsonProperty("piece-length")]
public string PieceLength { get; set; }
[JsonProperty("proxy-method")]
public string ProxyMethod { get; set; }
[JsonProperty("realtime-chunk-checksum")]
public string RealtimeChunkChecksum { get; set; }
[JsonProperty("remote-time")]
public string RemoteTime { get; set; }
[JsonProperty("remove-control-file")]
public string RemoveControlFile { get; set; }
[JsonProperty("retry-wait")]
public string RetryWait { get; set; }
[JsonProperty("reuse-uri")]
public string ReuseUri { get; set; }
[JsonProperty("rpc-save-upload-metadata")]
public string RpcSaveUploadMetadata { get; set; }
[JsonProperty("save-not-found")]
public string SaveNotFound { get; set; }
[JsonProperty("seed-ratio")]
public string SeedRatio { get; set; }
[JsonProperty("split")]
public string Split { get; set; }
[JsonProperty("stream-piece-selector")]
public string StreamPieceSelector { get; set; }
[JsonProperty("timeout")]
public string Timeout { get; set; }
[JsonProperty("uri-selector")]
public string UriSelector { get; set; }
[JsonProperty("use-head")]
public string UseHead { get; set; }
[JsonProperty("user-agent")]
public string UserAgent { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,25 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaPause
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public string Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,25 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaRemove
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public string Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,25 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaSaveSession
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public string Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,53 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaSendData
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("method")]
public string Method { get; set; }
[JsonProperty("params")]
public List<object> Params { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
[JsonObject]
public class AriaSendOption
{
[JsonProperty("all-proxy")]
public string HttpProxy { get; set; }
[JsonProperty("out")]
public string Out { get; set; }
[JsonProperty("dir")]
public string Dir { get; set; }
//[JsonProperty("header")]
//public string Header { get; set; }
//[JsonProperty("use-head")]
//public string UseHead { get; set; }
[JsonProperty("user-agent")]
public string UserAgent { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,25 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaShutdown
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public string Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,128 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaTellStatus
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public AriaTellStatusResult Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
[JsonObject]
public class AriaTellStatusList
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public List<AriaTellStatusResult> Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
[JsonObject]
public class AriaTellStatusResult
{
[JsonProperty("bitfield")]
public string Bitfield { get; set; }
[JsonProperty("completedLength")]
public string CompletedLength { get; set; }
[JsonProperty("connections")]
public string Connections { get; set; }
[JsonProperty("dir")]
public string Dir { get; set; }
[JsonProperty("downloadSpeed")]
public string DownloadSpeed { get; set; }
[JsonProperty("errorCode")]
public string ErrorCode { get; set; }
[JsonProperty("errorMessage")]
public string ErrorMessage { get; set; }
[JsonProperty("files")]
public List<AriaTellStatusResultFile> Files { get; set; }
[JsonProperty("gid")]
public string Gid { get; set; }
[JsonProperty("numPieces")]
public string NumPieces { get; set; }
[JsonProperty("pieceLength")]
public string PieceLength { get; set; }
[JsonProperty("status")]
public string Status { get; set; }
[JsonProperty("totalLength")]
public string TotalLength { get; set; }
[JsonProperty("uploadLength")]
public string UploadLength { get; set; }
[JsonProperty("uploadSpeed")]
public string UploadSpeed { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
[JsonObject]
public class AriaTellStatusResultFile
{
[JsonProperty("completedLength")]
public string CompletedLength { get; set; }
[JsonProperty("index")]
public string Index { get; set; }
[JsonProperty("length")]
public string Length { get; set; }
[JsonProperty("path")]
public string Path { get; set; }
[JsonProperty("selected")]
public string Selected { get; set; }
[JsonProperty("uris")]
public List<AriaUri> Uris { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,19 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaUri
{
[JsonProperty("status")]
public string Status { get; set; }
[JsonProperty("uri")]
public string Uri { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,41 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class AriaVersion
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public AriaVersionResult Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
[JsonObject]
public class AriaVersionResult
{
[JsonProperty("enabledFeatures")]
public List<string> EnabledFeatures { get; set; }
[JsonProperty("version")]
public string Version { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,26 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class SystemListMethods
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public List<string> Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,26 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class SystemListNotifications
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public List<string> Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,25 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class SystemMulticall
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("result")]
public string Result { get; set; }
[JsonProperty("error")]
public AriaError Error { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

@ -1,15 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.Aria2cNet.Client.Entity
{
[JsonObject]
public class SystemMulticallMathod
{
[JsonProperty("method")]
public string Method { get; set; }
[JsonProperty("params")]
public List<object> Params { get; set; }
}
}

@ -1,12 +0,0 @@
namespace DownKyi.Core.Aria2cNet.Client
{
/// <summary>
/// changePosition函数的how参数
/// </summary>
public enum HowChangePosition
{
POS_SET = 1,
POS_CUR,
POS_END
}
}

@ -1,12 +0,0 @@
namespace DownKyi.Core.Aria2cNet
{
/// <summary>
/// 下载状态
/// </summary>
public enum DownloadResult
{
SUCCESS = 1,
FAILED,
ABORT
}
}

@ -1,27 +0,0 @@
using System.Collections.Generic;
namespace DownKyi.Core.Aria2cNet.Server
{
/// <summary>
/// Aria服务器的启动配置
/// </summary>
public class AriaConfig
{
public int ListenPort { get; set; } // 服务器端口号取值1024-65535
public string Token { get; set; } // 连接服务器的token
public AriaConfigLogLevel LogLevel { get; set; } // 日志等级debug info notice warn error
public int MaxConcurrentDownloads { get; set; } // 最大同时下载数(任务数)取值1-*
public int MaxConnectionPerServer { get; set; } // 同服务器连接数取值1-16
public int Split { get; set; } // 单文件最大线程数取值1-*
//public int MaxTries { get; set; } //当服务器返回503错误时尝试重连尝试重连次数0代表无限默认:5
public int MinSplitSize { get; set; } // 最小文件分片大小, 下载线程数上限取决于能分出多少片, 对于小文件重要单位MB
public long MaxOverallDownloadLimit { get; set; } // 下载速度限制取值1-*
public long MaxDownloadLimit { get; set; } // 下载单文件速度限制取值1-*
public long MaxOverallUploadLimit { get; set; } // 上传速度限制取值1-*
public long MaxUploadLimit { get; set; } // 上传单文件速度限制取值1-*
public bool ContinueDownload { get; set; } // 断点续传
public AriaConfigFileAllocation FileAllocation { get; set; } // 文件预分配, none prealloc
public List<string> Headers { get; set; }
}
}

@ -1,13 +0,0 @@
namespace DownKyi.Core.Aria2cNet.Server
{
/// <summary>
/// 文件预分配
/// </summary>
public enum AriaConfigFileAllocation
{
NOT_SET = 0,
NONE = 1, // 没有预分配
PREALLOC, // 预分配,默认
FALLOC // NTFS建议使用
}
}

@ -1,15 +0,0 @@
namespace DownKyi.Core.Aria2cNet.Server
{
/// <summary>
/// 日志等级
/// </summary>
public enum AriaConfigLogLevel
{
NOT_SET = 0,
DEBUG = 1,
INFO,
NOTICE,
WARN,
ERROR
}
}

@ -1,259 +0,0 @@
using DownKyi.Core.Aria2cNet.Client;
using DownKyi.Core.Logging;
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace DownKyi.Core.Aria2cNet.Server
{
public static class AriaServer
{
public static int ListenPort; // 服务器端口
private static Process Server;
/// <summary>
/// 启动aria2c服务器
/// </summary>
/// <param name="listenPort"></param>
/// <param name="output"></param>
/// <param name="window"></param>
/// <returns></returns>
public static async Task<bool> StartServerAsync(AriaConfig config, Action<string> action)
{
// aria端口
ListenPort = config.ListenPort;
// aria目录
string ariaDir = Environment.CurrentDirectory + "\\aria\\";
//string ariaDir = StorageManager.GetAriaDir();
// 会话文件
#if DEBUG
string sessionFile = Path.Combine(ariaDir, "aira.session");
#else
string sessionFile =Path.Combine(ariaDir, "aira.session.gz");
#endif
// 日志文件
string logFile = Path.Combine(ariaDir, "aira.log");
// 自动保存会话文件的时间间隔
int saveSessionInterval = 30;
// --enable-rpc --rpc-listen-all=true --rpc-allow-origin-all=true --continue=true
await Task.Run(() =>
{
// 创建目录和文件
if (!Directory.Exists(ariaDir))
{
Directory.CreateDirectory(ariaDir);
}
if (!File.Exists(sessionFile))
{
var stream = File.Create(sessionFile);
stream.Close();
}
if (!File.Exists(logFile))
{
var stream = File.Create(logFile);
stream.Close();
}
else
{
// 日志文件存在如果大于100M则删除
try
{
var stream = File.Open(logFile, FileMode.Open);
if (stream.Length >= 10 * 1024 * 1024L)
{
stream.SetLength(0);
}
stream.Close();
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("StartServerAsync()发生其他异常: {0}", e);
LogManager.Error("AriaServer", e);
}
}
// header 解析
string headers = string.Empty;
if (config.Headers != null)
{
foreach (var header in config.Headers)
{
headers += $"--header=\"{header}\" ";
}
}
ExcuteProcess("aria2c.exe",
$"--enable-rpc --rpc-listen-all=true --rpc-allow-origin-all=true " +
$"--check-certificate=false " + // 解决问题 SSL/TLS handshake failure
$"--rpc-listen-port={config.ListenPort} " +
$"--rpc-secret={config.Token} " +
$"--input-file=\"{sessionFile}\" --save-session=\"{sessionFile}\" " +
$"--save-session-interval={saveSessionInterval} " +
$"--log=\"{logFile}\" --log-level={config.LogLevel.ToString("G").ToLower()} " + // log-level: 'debug' 'info' 'notice' 'warn' 'error'
$"--max-concurrent-downloads={config.MaxConcurrentDownloads} " + // 最大同时下载数(任务数)
$"--max-connection-per-server={config.MaxConnectionPerServer} " + // 同服务器连接数
$"--split={config.Split} " + // 单文件最大线程数
//$"--max-tries={config.MaxTries} retry-wait=3 " + // 尝试重连次数
$"--min-split-size={config.MinSplitSize}M " + // 最小文件分片大小, 下载线程数上限取决于能分出多少片, 对于小文件重要
$"--max-overall-download-limit={config.MaxOverallDownloadLimit} " + // 下载速度限制
$"--max-download-limit={config.MaxDownloadLimit} " + // 下载单文件速度限制
$"--max-overall-upload-limit={config.MaxOverallUploadLimit} " + // 上传速度限制
$"--max-upload-limit={config.MaxUploadLimit} " + // 上传单文件速度限制
$"--continue={config.ContinueDownload.ToString().ToLower()} " + // 断点续传
$"--allow-overwrite=true " + // 允许复写文件
$"--auto-file-renaming=false " +
$"--file-allocation={config.FileAllocation.ToString("G").ToLower()} " + // 文件预分配, none prealloc
$"{headers}" + // header
"",
null, (s, e) =>
{
if (e.Data == null || e.Data == "" || e.Data.Replace(" ", "") == "") { return; }
Utils.Debugging.Console.PrintLine(e.Data);
LogManager.Debug("AriaServer", e.Data);
action.Invoke(e.Data);
});
});
return true;
}
/// <summary>
/// 关闭aria2c服务器异步方法
/// </summary>
/// <returns></returns>
public static async Task<bool> CloseServerAsync()
{
await AriaClient.ShutdownAsync();
// 等待进程结束
await Task.Run(() =>
{
Server.WaitForExit(30000);
try
{
Server.Kill();
}
catch (Exception)
{
}
});
return true;
}
/// <summary>
/// 强制关闭aria2c服务器异步方法
/// </summary>
/// <returns></returns>
public static async Task<bool> ForceCloseServerAsync()
{
//await Task.Run(() =>
//{
// if (Server == null) { return; }
// Server.Kill();
// Server = null; // 将Server指向null
//});
//return true;
await AriaClient.ForceShutdownAsync();
return true;
}
/// <summary>
/// 关闭aria2c服务器
/// </summary>
/// <returns></returns>
public static bool CloseServer()
{
var task = AriaClient.ShutdownAsync();
if (task.Result != null && task.Result.Result != null && task.Result.Result == "OK")
{
// 等待进程结束
Server.WaitForExit(30000);
try
{
Server.Kill();
}
catch (Exception)
{
}
return true;
}
return false;
}
/// <summary>
/// 强制关闭aria2c服务器
/// </summary>
/// <returns></returns>
public static bool ForceCloseServer()
{
var task = AriaClient.ForceShutdownAsync();
if (task.Result != null && task.Result.Result != null && task.Result.Result == "OK")
{ return true; }
return false;
}
/// <summary>
/// 杀死Aria进程
/// </summary>
/// <param name="processName"></param>
/// <returns></returns>
public static bool KillServer(string processName = "aria2c")
{
Process[] processes = Process.GetProcessesByName(processName);
foreach (var process in processes)
{
try
{
process.Kill();
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("KillServer()发生异常: {0}", e);
LogManager.Error("AriaServer", e);
}
}
return true;
}
private static void ExcuteProcess(string exe, string arg, string workingDirectory, DataReceivedEventHandler output)
{
var p = new Process();
Server = p;
p.StartInfo.FileName = exe;
p.StartInfo.Arguments = arg;
// 工作目录
if (workingDirectory != null)
{
p.StartInfo.WorkingDirectory = workingDirectory;
}
// 输出信息重定向
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
// 将 StandardErrorEncoding 改为 UTF-8 才不会出现中文乱码
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
p.StartInfo.StandardErrorEncoding = Encoding.UTF8;
p.OutputDataReceived += output;
p.ErrorDataReceived += output;
// 启动线程
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
}
}
}

@ -1,68 +0,0 @@
using DownKyi.Core.BiliApi.Bangumi.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
using System;
namespace DownKyi.Core.BiliApi.Bangumi
{
public static class BangumiInfo
{
/// <summary>
/// 剧集基本信息mediaId方式
/// </summary>
/// <param name="mediaId"></param>
/// <returns></returns>
public static BangumiMedia BangumiMediaInfo(long mediaId)
{
string url = $"https://api.bilibili.com/pgc/review/user?media_id={mediaId}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
try
{
var media = JsonConvert.DeserializeObject<BangumiMediaOrigin>(response);
if (media != null && media.Result != null) { return media.Result.Media; }
else { return null; }
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("BangumiMediaInfo()发生异常: {0}", e);
LogManager.Error("BangumiInfo", e);
return null;
}
}
/// <summary>
/// 获取剧集明细web端seasonId/episodeId方式
/// </summary>
/// <param name="seasonId"></param>
/// <param name="episodeId"></param>
/// <returns></returns>
public static BangumiSeason BangumiSeasonInfo(long seasonId = -1, long episodeId = -1)
{
string baseUrl = "https://api.bilibili.com/pgc/view/web/season";
string referer = "https://www.bilibili.com";
string url;
if (seasonId > -1) { url = $"{baseUrl}?season_id={seasonId}"; }
else if (episodeId > -1) { url = $"{baseUrl}?ep_id={episodeId}"; }
else { return null; }
string response = WebClient.RequestWeb(url, referer);
try
{
var bangumiSeason = JsonConvert.DeserializeObject<BangumiSeasonOrigin>(response);
if (bangumiSeason != null) { return bangumiSeason.Result; }
else { return null; }
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("BangumiSeasonInfo()发生异常: {0}", e);
LogManager.Error("BangumiInfo", e);
return null;
}
}
}
}

@ -1,36 +0,0 @@
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Bangumi
{
public static class BangumiType
{
public static Dictionary<int, string> Type = new Dictionary<int, string>()
{
{ 1, "Anime" },
{ 2, "Movie" },
{ 3, "Documentary" },
{ 4, "Guochuang" },
{ 5, "TV" },
{ 6, "Unknown" },
{ 7, "Entertainment" },
{ 8, "Unknown" },
{ 9, "Unknown" },
{ 10, "Unknown" }
};
public static Dictionary<int, int> TypeId = new Dictionary<int, int>()
{
{ 1, 13 },
{ 2, 23 },
{ 3, 177 },
{ 4, 167 },
{ 5, 11 },
{ 6, -1 },
{ 7, -1 },
{ 8, -1 },
{ 9, -1 },
{ 10, -1 }
};
}
}

@ -1,13 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Bangumi.Models
{
public class BangumiArea : BaseModel
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
}
}

@ -1,53 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Bangumi.Models
{
public class BangumiEpisode : BaseModel
{
[JsonProperty("aid")]
public long Aid { get; set; }
[JsonProperty("badge")]
public string Badge { get; set; }
// badge_info
// badge_type
[JsonProperty("bvid")]
public string Bvid { get; set; }
[JsonProperty("cid")]
public long Cid { get; set; }
[JsonProperty("cover")]
public string Cover { get; set; }
[JsonProperty("dimension")]
public Dimension Dimension { get; set; }
[JsonProperty("duration")]
public long Duration { get; set; }
[JsonProperty("from")]
public string From { get; set; }
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("link")]
public string Link { get; set; }
[JsonProperty("long_title")]
public string LongTitle { get; set; }
[JsonProperty("pub_time")]
public long PubTime { get; set; }
// pv
// release_date
// rights
[JsonProperty("share_copy")]
public string ShareCopy { get; set; }
[JsonProperty("share_url")]
public string ShareUrl { get; set; }
[JsonProperty("short_link")]
public string ShortLink { get; set; }
// stat
[JsonProperty("status")]
public int Status { get; set; }
[JsonProperty("subtitle")]
public string Subtitle { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("vid")]
public string Vid { get; set; }
}
}

@ -1,46 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Bangumi.Models
{
// https://api.bilibili.com/pgc/review/user
public class BangumiMediaOrigin : BaseModel
{
//[JsonProperty("code")]
//public int Code { get; set; }
//[JsonProperty("message")]
//public string Message { get; set; }
//[JsonProperty("ttl")]
//public int Ttl { get; set; }
[JsonProperty("result")]
public BangumiMediaData Result { get; set; }
}
public class BangumiMediaData : BaseModel
{
[JsonProperty("media")]
public BangumiMedia Media { get; set; }
}
public class BangumiMedia : BaseModel
{
[JsonProperty("areas")]
public List<BangumiArea> Areas { get; set; }
[JsonProperty("cover")]
public string Cover { get; set; }
[JsonProperty("media_id")]
public long MediaId { get; set; }
// new_ep
// rating
[JsonProperty("season_id")]
public long SeasonId { get; set; }
[JsonProperty("share_url")]
public string ShareUrl { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("type_name")]
public string TypeName { get; set; }
}
}

@ -1,13 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Bangumi.Models
{
public class BangumiPositive : BaseModel
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
}
}

@ -1,79 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Bangumi.Models
{
// https://api.bilibili.com/pgc/view/web/season
public class BangumiSeasonOrigin : BaseModel
{
//[JsonProperty("code")]
//public int Code { get; set; }
//[JsonProperty("message")]
//public string Message { get; set; }
//[JsonProperty("ttl")]
//public int Ttl { get; set; }
[JsonProperty("result")]
public BangumiSeason Result { get; set; }
}
public class BangumiSeason : BaseModel
{
// activity
// alias
[JsonProperty("areas")]
public List<BangumiArea> Areas { get; set; }
[JsonProperty("bkg_cover")]
public string BkgCover { get; set; }
[JsonProperty("cover")]
public string Cover { get; set; }
[JsonProperty("episodes")]
public List<BangumiEpisode> Episodes { get; set; }
[JsonProperty("evaluate")]
public string Evaluate { get; set; }
// freya
// jp_title
[JsonProperty("link")]
public string Link { get; set; }
[JsonProperty("media_id")]
public long MediaId { get; set; }
// mode
// new_ep
// payment
[JsonProperty("positive")]
public BangumiPositive Positive { get; set; }
// publish
// rating
// record
// rights
[JsonProperty("season_id")]
public long SeasonId { get; set; }
[JsonProperty("season_title")]
public string SeasonTitle { get; set; }
[JsonProperty("seasons")]
public List<BangumiSeasonInfo> Seasons { get; set; }
[JsonProperty("section")]
public List<BangumiSection> Section { get; set; }
// series
// share_copy
// share_sub_title
// share_url
// show
[JsonProperty("square_cover")]
public string SquareCover { get; set; }
[JsonProperty("stat")]
public BangumiStat Stat { get; set; }
// status
[JsonProperty("subtitle")]
public string Subtitle { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("total")]
public int Total { get; set; }
[JsonProperty("type")]
public int Type { get; set; }
[JsonProperty("up_info")]
public BangumiUpInfo UpInfo { get; set; }
}
}

@ -1,25 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Bangumi.Models
{
public class BangumiSeasonInfo : BaseModel
{
[JsonProperty("badge")]
public string Badge { get; set; }
// badge_info
// badge_type
[JsonProperty("cover")]
public string Cover { get; set; }
[JsonProperty("media_id")]
public long MediaId { get; set; }
// new_ep
[JsonProperty("season_id")]
public long SeasonId { get; set; }
[JsonProperty("season_title")]
public string SeasonTitle { get; set; }
[JsonProperty("season_type")]
public int SeasonType { get; set; }
// stat
}
}

@ -1,20 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Bangumi.Models
{
public class BangumiSection : BaseModel
{
[JsonProperty("episode_id")]
public long EpisodeId { get; set; }
[JsonProperty("episodes")]
public List<BangumiEpisode> Episodes { get; set; }
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("type")]
public int Type { get; set; }
}
}

@ -1,25 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Bangumi.Models
{
public class BangumiStat : BaseModel
{
[JsonProperty("coins")]
public long Coins { get; set; }
[JsonProperty("danmakus")]
public long Danmakus { get; set; }
[JsonProperty("favorite")]
public long Favorite { get; set; }
[JsonProperty("favorites")]
public long Favorites { get; set; }
[JsonProperty("likes")]
public long Likes { get; set; }
[JsonProperty("reply")]
public long Reply { get; set; }
[JsonProperty("share")]
public long Share { get; set; }
[JsonProperty("views")]
public long Views { get; set; }
}
}

@ -1,22 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Bangumi.Models
{
public class BangumiUpInfo : BaseModel
{
[JsonProperty("avatar")]
public string Avatar { get; set; }
// follower
// is_follow
[JsonProperty("mid")]
public long Mid { get; set; }
// pendant
// theme_type
[JsonProperty("uname")]
public string Name { get; set; }
// verify_type
// vip_status
// vip_type
}
}

@ -1,63 +0,0 @@
using System;
namespace DownKyi.Core.BiliApi.BiliUtils
{
public static class BvId
{
private const string tableStr = "fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF"; //码表
private static readonly char[] table = tableStr.ToCharArray();
private static readonly char[] tr = new char[124]; //反查码表
private const ulong Xor = 177451812; //固定异或值
private const ulong add = 8728348608; //固定加法值
private static readonly int[] s = { 11, 10, 3, 8, 4, 6 }; //位置编码表
static BvId()
{
Tr_init();
}
//初始化反查码表
private static void Tr_init()
{
for (int i = 0; i < 58; i++)
tr[table[i]] = (char)i;
}
/// <summary>
/// bvid转avid
/// </summary>
/// <param name="bvid"></param>
/// <returns></returns>
public static ulong Bv2Av(string bvid)
{
char[] bv = bvid.ToCharArray();
ulong r = 0;
ulong av;
for (int i = 0; i < 6; i++)
r += tr[bv[s[i]]] * (ulong)Math.Pow(58, i);
av = (r - add) ^ Xor;
return av;
}
/// <summary>
/// avid转bvid
/// </summary>
/// <param name="av"></param>
/// <returns></returns>
public static string Av2Bv(ulong av)
{
//编码结果
string res = "BV1 4 1 7 ";
char[] result = res.ToCharArray();
av = (av ^ Xor) + add;
for (int i = 0; i < 6; i++)
result[s[i]] = table[av / (ulong)Math.Pow(58, i) % 58];
string bv = new string(result);
return bv;
}
}
}

@ -1,78 +0,0 @@
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.BiliUtils
{
public static class Constant
{
private static readonly List<Quality> resolutions = new List<Quality>
{
new Quality { Name = "360P 流畅", Id = 16 },
new Quality { Name = "480P 清晰", Id = 32 },
new Quality { Name = "720P 高清", Id = 64 },
new Quality { Name = "720P 60帧", Id = 74 },
new Quality { Name = "1080P 高清", Id = 80 },
new Quality { Name = "1080P 高码率", Id = 112 },
new Quality { Name = "1080P 60帧", Id = 116 },
new Quality { Name = "4K 超清", Id = 120 },
new Quality { Name = "HDR 真彩", Id = 125 },
new Quality { Name = "杜比视界", Id = 126 },
new Quality { Name = "超高清 8K", Id = 127 },
};
private static readonly List<Quality> codecIds = new List<Quality>
{
new Quality { Name = "H.264/AVC", Id = 7 },
new Quality { Name = "H.265/HEVC", Id = 12 },
new Quality { Name = "AV1", Id = 13 },
};
private static readonly List<Quality> qualities = new List<Quality>
{
//new Quality { Name = "64K", Id = 30216 },
//new Quality { Name = "132K", Id = 30232 },
//new Quality { Name = "192K", Id = 30280 },
new Quality { Name = "低质量", Id = 30216 },
new Quality { Name = "中质量", Id = 30232 },
new Quality { Name = "高质量", Id = 30280 },
new Quality { Name = "Dolby Atmos", Id = 30250 },
new Quality { Name = "Hi-Res无损", Id = 30251 },
};
/// <summary>
/// 获取支持的视频画质
/// </summary>
/// <returns></returns>
public static List<Quality> GetResolutions()
{
// 使用深复制,
// 保证外部修改list后
// 不会影响其他调用处
return new List<Quality>(resolutions);
}
/// <summary>
/// 获取视频编码代码
/// </summary>
/// <returns></returns>
public static List<Quality> GetCodecIds()
{
// 使用深复制,
// 保证外部修改list后
// 不会影响其他调用处
return new List<Quality>(codecIds);
}
/// <summary>
/// 获取支持的视频音质
/// </summary>
/// <returns></returns>
public static List<Quality> GetAudioQualities()
{
// 使用深复制,
// 保证外部修改list后
// 不会影响其他调用处
return new List<Quality>(qualities);
}
}
}

@ -1,154 +0,0 @@
using System;
namespace DownKyi.Core.BiliApi.BiliUtils
{
public static class DanmakuSender
{
private const uint CRCPOLYNOMIAL = 0xEDB88320;
private static readonly uint[] crctable = new uint[256];
static DanmakuSender()
{
CreateTable();
}
private static void CreateTable()
{
for (int i = 0; i < 256; i++)
{
uint crcreg = (uint)i;
for (int j = 0; j < 8; j++)
{
if ((crcreg & 1) != 0)
{
crcreg = CRCPOLYNOMIAL ^ (crcreg >> 1);
}
else
{
crcreg >>= 1;
}
}
crctable[i] = crcreg;
}
}
private static uint Crc32(string userId)
{
uint crcstart = 0xFFFFFFFF;
for (int i = 0; i < userId.Length; i++)
{
uint index = (uint)(crcstart ^ (int)userId[i]) & 255;
crcstart = (crcstart >> 8) ^ crctable[index];
}
return crcstart;
}
private static uint Crc32LastIndex(string userId)
{
uint index = 0;
uint crcstart = 0xFFFFFFFF;
for (int i = 0; i < userId.Length; i++)
{
index = (uint)((crcstart ^ (int)userId[i]) & 255);
crcstart = (crcstart >> 8) ^ crctable[index];
}
return index;
}
private static int GetCrcIndex(long t)
{
for (int i = 0; i < 256; i++)
{
if ((crctable[i] >> 24) == t)
{
return i;
}
}
return -1;
}
private static object[] DeepCheck(int i, int[] index)
{
object[] resultArray = new object[2];
string result = "";
uint tc;// = 0x00;
var hashcode = Crc32(i.ToString());
tc = (uint)(hashcode & 0xff ^ index[2]);
if (!(tc <= 57 && tc >= 48))
{
resultArray[0] = 0;
return resultArray;
}
result += (tc - 48).ToString();
hashcode = crctable[index[2]] ^ (hashcode >> 8);
tc = (uint)(hashcode & 0xff ^ index[1]);
if (!(tc <= 57 && tc >= 48))
{
resultArray[0] = 0;
return resultArray;
}
result += (tc - 48).ToString();
hashcode = crctable[index[1]] ^ (hashcode >> 8);
tc = (uint)(hashcode & 0xff ^ index[0]);
if (!(tc <= 57 && tc >= 48))
{
resultArray[0] = 0;
return resultArray;
}
result += (tc - 48).ToString();
//hashcode = crctable[index[0]] ^ (hashcode >> 8);
resultArray[0] = 1;
resultArray[1] = result;
return resultArray;
}
/// <summary>
/// 查询弹幕发送者
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public static string FindDanmakuSender(string userId)
{
object[] deepCheckData = new object[2];
int[] index = new int[4];
uint ht = (uint)Convert.ToInt32($"0x{userId}", 16);
ht ^= 0xffffffff;
int i;
for (i = 3; i > -1; i--)
{
index[3 - i] = GetCrcIndex(ht >> (i * 8));
uint snum = crctable[index[3 - i]];
ht ^= snum >> ((3 - i) * 8);
}
for (i = 0; i < 100000000; i++)
{
uint lastindex = Crc32LastIndex(i.ToString());
if (lastindex == index[3])
{
deepCheckData = DeepCheck(i, index);
if ((int)deepCheckData[0] != 0)
{
break;
}
}
}
if (i == 100000000)
{
return "-1";
}
return $"{i}{deepCheckData[1]}";
}
}
}

@ -1,557 +0,0 @@
using DownKyi.Core.Utils.Validator;
using System.Text.RegularExpressions;
namespace DownKyi.Core.BiliApi.BiliUtils
{
/// <summary>
/// 解析输入的字符串<para/>
/// 支持的格式有:<para/>
/// av号av170001, AV170001, https://www.bilibili.com/video/av170001 <para/>
/// BV号BV17x411w7KC, https://www.bilibili.com/video/BV17x411w7KC, https://b23.tv/BV17x411w7KC <para/>
/// 番剧电影、电视剧ss号ss32982, SS32982, https://www.bilibili.com/bangumi/play/ss32982 <para/>
/// 番剧电影、电视剧ep号ep317925, EP317925, https://www.bilibili.com/bangumi/play/ep317925 <para/>
/// 番剧电影、电视剧md号md28228367, MD28228367, https://www.bilibili.com/bangumi/media/md28228367 <para/>
/// 课程ss号https://www.bilibili.com/cheese/play/ss205 <para/>
/// 课程ep号https://www.bilibili.com/cheese/play/ep3489 <para/>
/// 收藏夹ml1329019876, ML1329019876, https://www.bilibili.com/medialist/detail/ml1329019876, https://www.bilibili.com/medialist/play/ml1329019876/ <para/>
/// 用户空间uid928123, UID928123, uid:928123, UID:928123, https://space.bilibili.com/928123
/// </summary>
public static class ParseEntrance
{
public static readonly string WwwUrl = "https://www.bilibili.com";
public static readonly string ShareWwwUrl = "https://www.bilibili.com/s";
public static readonly string ShortUrl = "https://b23.tv/";
public static readonly string MobileUrl = "https://m.bilibili.com";
public static readonly string SpaceUrl = "https://space.bilibili.com";
public static readonly string VideoUrl = $"{WwwUrl}/video/";
public static readonly string BangumiUrl = $"{WwwUrl}/bangumi/play/";
public static readonly string BangumiMediaUrl = $"{WwwUrl}/bangumi/media/";
public static readonly string CheeseUrl = $"{WwwUrl}/cheese/play/";
public static readonly string FavoritesUrl1 = $"{WwwUrl}/medialist/detail/";
public static readonly string FavoritesUrl2 = $"{WwwUrl}/medialist/play/";
#region 视频
/// <summary>
/// 是否为av id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsAvId(string input)
{
return IsIntId(input, "av");
}
/// <summary>
/// 是否为av url
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsAvUrl(string input)
{
string id = GetVideoId(input);
return IsAvId(id);
}
/// <summary>
/// 获取av id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static long GetAvId(string input)
{
if (IsAvId(input))
{
return Number.GetInt(input.Remove(0, 2));
}
else if (IsAvUrl(input))
{
return Number.GetInt(GetVideoId(input).Remove(0, 2));
}
else
{
return -1;
}
}
/// <summary>
/// 是否为bv id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsBvId(string input)
{
return input.StartsWith("BV") && input.Length == 12;
}
/// <summary>
/// 是否为bv url
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsBvUrl(string input)
{
string id = GetVideoId(input);
return IsBvId(id);
}
/// <summary>
/// 获取bv id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static string GetBvId(string input)
{
if (IsBvId(input))
{
return input;
}
else if (IsBvUrl(input))
{
return GetVideoId(input);
}
else
{
return "";
}
}
#endregion
#region 番剧(电影、电视剧)
/// <summary>
/// 是否为番剧season id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsBangumiSeasonId(string input)
{
return IsIntId(input, "ss");
}
/// <summary>
/// 是否为番剧season url
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsBangumiSeasonUrl(string input)
{
string id = GetBangumiId(input);
return IsBangumiSeasonId(id);
}
/// <summary>
/// 获取番剧season id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static long GetBangumiSeasonId(string input)
{
if (IsBangumiSeasonId(input))
{
return Number.GetInt(input.Remove(0, 2));
}
else if (IsBangumiSeasonUrl(input))
{
return Number.GetInt(GetBangumiId(input).Remove(0, 2));
}
else
{
return -1;
}
}
/// <summary>
/// 是否为番剧episode id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsBangumiEpisodeId(string input)
{
return IsIntId(input, "ep");
}
/// <summary>
/// 是否为番剧episode url
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsBangumiEpisodeUrl(string input)
{
string id = GetBangumiId(input);
return IsBangumiEpisodeId(id);
}
/// <summary>
/// 获取番剧episode id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static long GetBangumiEpisodeId(string input)
{
if (IsBangumiEpisodeId(input))
{
return Number.GetInt(input.Remove(0, 2));
}
else if (IsBangumiEpisodeUrl(input))
{
return Number.GetInt(GetBangumiId(input).Remove(0, 2));
}
else
{
return -1;
}
}
/// <summary>
/// 是否为番剧media id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsBangumiMediaId(string input)
{
return IsIntId(input, "md");
}
/// <summary>
/// 是否为番剧media url
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsBangumiMediaUrl(string input)
{
string id = GetBangumiId(input);
return IsBangumiMediaId(id);
}
/// <summary>
/// 获取番剧media id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static long GetBangumiMediaId(string input)
{
if (IsBangumiMediaId(input))
{
return Number.GetInt(input.Remove(0, 2));
}
else if (IsBangumiMediaUrl(input))
{
return Number.GetInt(GetBangumiId(input).Remove(0, 2));
}
else
{
return -1;
}
}
#endregion
#region 课程
/// <summary>
/// 是否为课程season url
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsCheeseSeasonUrl(string input)
{
string id = GetCheeseId(input);
return IsIntId(id, "ss");
}
/// <summary>
/// 获取课程season id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static long GetCheeseSeasonId(string input)
{
return IsCheeseSeasonUrl(input) ? Number.GetInt(GetCheeseId(input).Remove(0, 2)) : -1;
}
/// <summary>
/// 是否为课程episode url
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsCheeseEpisodeUrl(string input)
{
string id = GetCheeseId(input);
return IsIntId(id, "ep");
}
/// <summary>
/// 获取课程episode id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static long GetCheeseEpisodeId(string input)
{
return IsCheeseEpisodeUrl(input) ? Number.GetInt(GetCheeseId(input).Remove(0, 2)) : -1;
}
#endregion
#region 收藏夹
/// <summary>
/// 是否为收藏夹id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsFavoritesId(string input)
{
return IsIntId(input, "ml");
}
/// <summary>
/// 是否为收藏夹url
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsFavoritesUrl(string input)
{
return IsFavoritesUrl1(input) || IsFavoritesUrl2(input);
}
/// <summary>
/// 是否为收藏夹url1
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private static bool IsFavoritesUrl1(string input)
{
string favoritesId = GetId(input, FavoritesUrl1);
return IsFavoritesId(favoritesId);
}
/// <summary>
/// 是否为收藏夹ur2
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private static bool IsFavoritesUrl2(string input)
{
string favoritesId = GetId(input, FavoritesUrl2);
return IsFavoritesId(favoritesId.Split('/')[0]);
}
/// <summary>
/// 获取收藏夹id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static long GetFavoritesId(string input)
{
if (IsFavoritesId(input))
{
return Number.GetInt(input.Remove(0, 2));
}
else if (IsFavoritesUrl1(input))
{
return Number.GetInt(GetId(input, FavoritesUrl1).Remove(0, 2));
}
else if (IsFavoritesUrl2(input))
{
return Number.GetInt(GetId(input, FavoritesUrl2).Remove(0, 2).Split('/')[0]);
}
else
{
return -1;
}
}
#endregion
#region 用户空间
/// <summary>
/// 是否为用户id
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsUserId(string input)
{
if (input.ToLower().StartsWith("uid:"))
{
return Regex.IsMatch(input.Remove(0, 4), @"^\d+$");
}
else if (input.ToLower().StartsWith("uid"))
{
return Regex.IsMatch(input.Remove(0, 3), @"^\d+$");
}
else { return false; }
}
/// <summary>
/// 是否为用户空间url
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsUserUrl(string input)
{
if (!IsUrl(input)) { return false; }
if (input.Contains("space.bilibili.com"))
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 获取用户mid
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static long GetUserId(string input)
{
if (input.ToLower().StartsWith("uid:"))
{
return Number.GetInt(input.Remove(0, 4));
}
else if (input.ToLower().StartsWith("uid"))
{
return Number.GetInt(input.Remove(0, 3));
}
else if (IsUserUrl(input))
{
string url = EnableHttps(input);
url = DeleteUrlParam(url);
var match = Regex.Match(url, @"\d+");
if (match.Success)
{
return long.Parse(match.Value);
}
else
{
return -1;
}
}
else
{
return -1;
}
}
#endregion
/// <summary>
/// 是否为网址
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private static bool IsUrl(string input)
{
return input.StartsWith("http://") || input.StartsWith("https://");
}
/// <summary>
/// 将http转为https
/// </summary>
/// <returns></returns>
private static string EnableHttps(string url)
{
if (!IsUrl(url)) { return null; }
return url.Replace("http://", "https://");
}
/// <summary>
/// 去除url中的参数
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
private static string DeleteUrlParam(string url)
{
string[] strList = url.Split('?');
return strList[0].EndsWith("/") ? strList[0].TrimEnd('/') : strList[0];
}
/// <summary>
/// 从url中获取视频idavid/bvid
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private static string GetVideoId(string input)
{
return GetId(input, VideoUrl);
}
/// <summary>
/// 从url中获取番剧idss/ep/md
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private static string GetBangumiId(string input)
{
string id = GetId(input, BangumiUrl);
if (id != "") { return id; }
return GetId(input, BangumiMediaUrl);
}
/// <summary>
/// 从url中获取课程idss/ep
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private static string GetCheeseId(string input)
{
return GetId(input, CheeseUrl);
}
/// <summary>
/// 是否为数字型id
/// </summary>
/// <param name="input"></param>
/// <param name="prefix"></param>
/// <returns></returns>
private static bool IsIntId(string input, string prefix)
{
if (input.ToLower().StartsWith(prefix))
{
return Regex.IsMatch(input.Remove(0, 2), @"^\d+$");
}
return false;
}
/// <summary>
/// 从url中获取id
/// </summary>
/// <param name="input"></param>
/// <param name="baseUrl"></param>
/// <returns></returns>
private static string GetId(string input, string baseUrl)
{
if (!IsUrl(input)) { return ""; }
string url = EnableHttps(input);
url = DeleteUrlParam(url);
url = url.Replace(ShareWwwUrl, WwwUrl);
url = url.Replace(MobileUrl, WwwUrl);
if (url.Contains("b23.tv/ss") || url.Contains("b23.tv/ep"))
{
url = url.Replace(ShortUrl, BangumiUrl);
}
else
{
url = url.Replace(ShortUrl, VideoUrl);
}
if (!url.StartsWith(baseUrl)) { return ""; }
return url.Replace(baseUrl, "");
}
}
}

@ -1,11 +0,0 @@
using System;
namespace DownKyi.Core.BiliApi.BiliUtils
{
[Serializable]
public class Quality
{
public string Name { get; set; }
public int Id { get; set; }
}
}

File diff suppressed because one or more lines are too long

@ -1,70 +0,0 @@
using DownKyi.Core.BiliApi.Cheese.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
using System;
namespace DownKyi.Core.BiliApi.Cheese
{
public static class CheeseInfo
{
/// <summary>
/// 获取课程基本信息
/// </summary>
/// <param name="seasonId"></param>
/// <param name="episodeId"></param>
/// <returns></returns>
public static CheeseView CheeseViewInfo(long seasonId = -1, long episodeId = -1)
{
string baseUrl = "https://api.bilibili.com/pugv/view/web/season";
string referer = "https://www.bilibili.com";
string url;
if (seasonId > -1) { url = $"{baseUrl}?season_id={seasonId}"; }
else if (episodeId > -1) { url = $"{baseUrl}?ep_id={episodeId}"; }
else { return null; }
string response = WebClient.RequestWeb(url, referer);
try
{
CheeseViewOrigin cheese = JsonConvert.DeserializeObject<CheeseViewOrigin>(response);
if (cheese != null) { return cheese.Data; }
else { return null; }
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("CheeseViewInfo()发生异常: {0}", e);
LogManager.Error("CheeseInfo", e);
return null;
}
}
/// <summary>
/// 获取课程分集列表
/// </summary>
/// <param name="seasonId"></param>
/// <param name="ps"></param>
/// <param name="pn"></param>
/// <returns></returns>
public static CheeseEpisodeList CheeseEpisodeList(long seasonId, int ps = 50, int pn = 1)
{
string url = $"https://api.bilibili.com/pugv/view/web/ep/list?season_id={seasonId}&pn={pn}&ps={ps}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
try
{
CheeseEpisodeListOrigin cheese = JsonConvert.DeserializeObject<CheeseEpisodeListOrigin>(response);
if (cheese != null) { return cheese.Data; }
else { return null; }
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("CheeseEpisodeList()发生异常: {0}", e);
LogManager.Error("CheeseInfo", e);
return null;
}
}
}
}

@ -1,17 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Cheese.Models
{
public class CheeseBrief : BaseModel
{
// content
[JsonProperty("img")]
public List<CheeseImg> Img { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("type")]
public int Type { get; set; }
}
}

@ -1,43 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Cheese.Models
{
public class CheeseEpisode : BaseModel
{
[JsonProperty("aid")]
public long Aid { get; set; }
[JsonProperty("catalogue_index")]
public int CatalogueIndex { get; set; }
[JsonProperty("cid")]
public long Cid { get; set; }
[JsonProperty("cover")]
public string Cover { get; set; }
[JsonProperty("duration")]
public long Duration { get; set; }
[JsonProperty("from")]
public string From { get; set; }
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("index")]
public int Index { get; set; }
[JsonProperty("page")]
public int Page { get; set; }
[JsonProperty("play")]
public long Play { get; set; }
[JsonProperty("play_way")]
public int PlayWay { get; set; }
[JsonProperty("play_way_format")]
public string PlayWayFormat { get; set; }
[JsonProperty("release_date")]
public long ReleaseDate { get; set; }
[JsonProperty("status")]
public int Status { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("watched")]
public bool Watched { get; set; }
[JsonProperty("watchedHistory")]
public int WatchedHistory { get; set; }
}
}

@ -1,26 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Cheese.Models
{
// https://api.bilibili.com/pugv/view/web/ep/list
public class CheeseEpisodeListOrigin : BaseModel
{
//[JsonProperty("code")]
//public int Code { get; set; }
//[JsonProperty("message")]
//public string Message { get; set; }
[JsonProperty("data")]
public CheeseEpisodeList Data { get; set; }
}
public class CheeseEpisodeList : BaseModel
{
[JsonProperty("items")]
public List<CheeseEpisode> Items { get; set; }
[JsonProperty("page")]
public CheeseEpisodePage Page { get; set; }
}
}

@ -1,17 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Cheese.Models
{
public class CheeseEpisodePage : BaseModel
{
[JsonProperty("next")]
public bool Next { get; set; }
[JsonProperty("num")]
public int Num { get; set; }
[JsonProperty("size")]
public int Size { get; set; }
[JsonProperty("total")]
public int Total { get; set; }
}
}

@ -1,13 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Cheese.Models
{
public class CheeseImg : BaseModel
{
[JsonProperty("aspect_ratio")]
public double AspectRatio { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
}
}

@ -1,13 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Cheese.Models
{
public class CheeseStat : BaseModel
{
[JsonProperty("play")]
public long Play { get; set; }
[JsonProperty("play_desc")]
public string PlayDesc { get; set; }
}
}

@ -1,23 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Cheese.Models
{
public class CheeseUpInfo : BaseModel
{
[JsonProperty("avatar")]
public string Avatar { get; set; }
[JsonProperty("brief")]
public string Brief { get; set; }
[JsonProperty("follower")]
public long Follower { get; set; }
[JsonProperty("is_follow")]
public int IsFollow { get; set; }
[JsonProperty("link")]
public string Link { get; set; }
[JsonProperty("mid")]
public long Mid { get; set; }
[JsonProperty("uname")]
public string Name { get; set; }
}
}

@ -1,69 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Cheese.Models
{
// https://api.bilibili.com/pugv/view/web/season
public class CheeseViewOrigin : BaseModel
{
//[JsonProperty("code")]
//public int Code { get; set; }
//[JsonProperty("message")]
//public string Message { get; set; }
[JsonProperty("data")]
public CheeseView Data { get; set; }
}
public class CheeseView : BaseModel
{
// active_market
// activity_list
[JsonProperty("brief")]
public CheeseBrief Brief { get; set; }
// cooperation
// coupon
// course_content
// courses
[JsonProperty("cover")]
public string Cover { get; set; }
// ep_catalogue
// ep_count
// episode_page
// episode_sort
// episode_tag
[JsonProperty("episodes")]
public List<CheeseEpisode> Episodes { get; set; }
// faq
// faq1
// live_ep_count
// opened_ep_count
// payment
// previewed_purchase_note
// purchase_format_note
// purchase_note
// purchase_protocol
// recommend_seasons 推荐课程
// release_bottom_info
// release_info
// release_info2
// release_status
[JsonProperty("season_id")]
public long SeasonId { get; set; }
[JsonProperty("share_url")]
public string ShareUrl { get; set; }
// short_link
[JsonProperty("stat")]
public CheeseStat Stat { get; set; }
// status
[JsonProperty("subtitle")]
public string Subtitle { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("up_info")]
public CheeseUpInfo UpInfo { get; set; }
// update_status
// user_status
}
}

@ -1,104 +0,0 @@
using Bilibili.Community.Service.Dm.V1;
using DownKyi.Core.BiliApi.Danmaku.Models;
using System;
using System.Collections.Generic;
using System.IO;
namespace DownKyi.Core.BiliApi.Danmaku
{
public static class DanmakuProtobuf
{
/// <summary>
/// 下载6分钟内的弹幕返回弹幕列表
/// </summary>
/// <param name="avid">稿件avID</param>
/// <param name="cid">视频CID</param>
/// <param name="segmentIndex">分包每6分钟一包</param>
/// <returns></returns>
public static List<BiliDanmaku> GetDanmakuProto(long avid, long cid, int segmentIndex)
{
string url = $"https://api.bilibili.com/x/v2/dm/web/seg.so?type=1&oid={cid}&pid={avid}&segment_index={segmentIndex}";
//string referer = "https://www.bilibili.com";
string directory = Path.Combine(Storage.StorageManager.GetDanmaku(), $"{cid}");
string filePath = Path.Combine(directory, $"{segmentIndex}.proto");
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
try
{
System.Net.WebClient mywebclient = new System.Net.WebClient();
mywebclient.DownloadFile(url, filePath);
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetDanmakuProto()发生异常: {0}", e);
//Logging.LogManager.Error(e);
}
var danmakuList = new List<BiliDanmaku>();
try
{
using (var input = File.OpenRead(filePath))
{
DmSegMobileReply danmakus = DmSegMobileReply.Parser.ParseFrom(input);
if (danmakus == null || danmakus.Elems == null)
{
return danmakuList;
}
foreach (var dm in danmakus.Elems)
{
var danmaku = new BiliDanmaku
{
Id = dm.Id,
Progress = dm.Progress,
Mode = dm.Mode,
Fontsize = dm.Fontsize,
Color = dm.Color,
MidHash = dm.MidHash,
Content = dm.Content,
Ctime = dm.Ctime,
Weight = dm.Weight,
//Action = dm.Action,
Pool = dm.Pool
};
danmakuList.Add(danmaku);
}
}
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetDanmakuProto()发生异常: {0}", e);
//Logging.LogManager.Error(e);
return null;
}
return danmakuList;
}
/// <summary>
/// 下载所有弹幕,返回弹幕列表
/// </summary>
/// <param name="avid">稿件avID</param>
/// <param name="cid">视频CID</param>
/// <returns></returns>
public static List<BiliDanmaku> GetAllDanmakuProto(long avid, long cid)
{
var danmakuList = new List<BiliDanmaku>();
int segmentIndex = 0;
while (true)
{
segmentIndex += 1;
var danmakus = GetDanmakuProto(avid, cid, segmentIndex);
if (danmakus == null) { break; }
danmakuList.AddRange(danmakus);
}
return danmakuList;
}
}
}

@ -1,33 +0,0 @@
namespace DownKyi.Core.BiliApi.Danmaku.Models
{
public class BiliDanmaku
{
public long Id { get; set; } //弹幕dmID
public int Progress { get; set; } //出现时间
public int Mode { get; set; } //弹幕类型
public int Fontsize { get; set; } //文字大小
public uint Color { get; set; } //弹幕颜色
public string MidHash { get; set; } //发送者UID的HASH
public string Content { get; set; } //弹幕内容
public long Ctime { get; set; } //发送时间
public int Weight { get; set; } //权重
//public string Action { get; set; } //动作?
public int Pool { get; set; } //弹幕池
public override string ToString()
{
string separator = "\n";
return $"id: {Id}{separator}" +
$"progress: {Progress}{separator}" +
$"mode: {Mode}{separator}" +
$"fontsize: {Fontsize}{separator}" +
$"color: {Color}{separator}" +
$"midHash: {MidHash}{separator}" +
$"content: {Content}{separator}" +
$"ctime: {Ctime}{separator}" +
$"weight: {Weight}{separator}" +
//$"action: {Action}{separator}" +
$"pool: {Pool}";
}
}
}

@ -1,142 +0,0 @@
using DownKyi.Core.BiliApi.Favorites.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Favorites
{
public static class FavoritesInfo
{
/// <summary>
/// 获取收藏夹元数据
/// </summary>
/// <param name="mediaId"></param>
public static FavoritesMetaInfo GetFavoritesInfo(long mediaId)
{
string url = $"https://api.bilibili.com/x/v3/fav/folder/info?media_id={mediaId}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
try
{
var info = JsonConvert.DeserializeObject<FavoritesMetaInfoOrigin>(response);
if (info != null) { return info.Data; }
else { return null; }
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetFavoritesInfo()发生异常: {0}", e);
LogManager.Error("FavoritesInfo", e);
return null;
}
}
/// <summary>
/// 查询用户创建的视频收藏夹
/// </summary>
/// <param name="mid">目标用户UID</param>
/// <param name="pn">页码</param>
/// <param name="ps">每页项数</param>
/// <returns></returns>
public static List<FavoritesMetaInfo> GetCreatedFavorites(long mid, int pn, int ps)
{
string url = $"https://api.bilibili.com/x/v3/fav/folder/created/list?up_mid={mid}&pn={pn}&ps={ps}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
try
{
var favorites = JsonConvert.DeserializeObject<FavoritesListOrigin>(response);
if (favorites == null || favorites.Data == null || favorites.Data.List == null)
{ return null; }
return favorites.Data.List;
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetCreatedFavorites()发生异常: {0}", e);
LogManager.Error("FavoritesInfo", e);
return null;
}
}
/// <summary>
/// 查询所有的用户创建的视频收藏夹
/// </summary>
/// <param name="mid">目标用户UID</param>
/// <returns></returns>
public static List<FavoritesMetaInfo> GetAllCreatedFavorites(long mid)
{
List<FavoritesMetaInfo> result = new List<FavoritesMetaInfo>();
int i = 0;
while (true)
{
i++;
int ps = 50;
var data = GetCreatedFavorites(mid, i, ps);
if (data == null || data.Count == 0)
{ break; }
result.AddRange(data);
}
return result;
}
/// <summary>
/// 查询用户收藏的视频收藏夹
/// </summary>
/// <param name="mid">目标用户UID</param>
/// <param name="pn">页码</param>
/// <param name="ps">每页项数</param>
/// <returns></returns>
public static List<FavoritesMetaInfo> GetCollectedFavorites(long mid, int pn, int ps)
{
string url = $"https://api.bilibili.com/x/v3/fav/folder/collected/list?up_mid={mid}&pn={pn}&ps={ps}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
try
{
var favorites = JsonConvert.DeserializeObject<FavoritesListOrigin>(response);
if (favorites == null || favorites.Data == null || favorites.Data.List == null)
{ return null; }
return favorites.Data.List;
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetCollectedFavorites()发生异常: {0}", e);
LogManager.Error("FavoritesInfo", e);
return null;
}
}
/// <summary>
/// 查询所有的用户收藏的视频收藏夹
/// </summary>
/// <param name="mid">目标用户UID</param>
/// <returns></returns>
public static List<FavoritesMetaInfo> GetAllCollectedFavorites(long mid)
{
List<FavoritesMetaInfo> result = new List<FavoritesMetaInfo>();
int i = 0;
while (true)
{
i++;
int ps = 50;
var data = GetCollectedFavorites(mid, i, ps);
if (data == null || data.Count == 0)
{ break; }
result.AddRange(data);
}
return result;
}
}
}

@ -1,91 +0,0 @@
using DownKyi.Core.BiliApi.Favorites.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Favorites
{
public static class FavoritesResource
{
/// <summary>
/// 获取收藏夹内容明细列表
/// </summary>
/// <param name="mediaId">收藏夹ID</param>
/// <param name="pn">页码</param>
/// <param name="ps">每页项数</param>
/// <returns></returns>
public static List<FavoritesMedia> GetFavoritesMedia(long mediaId, int pn, int ps)
{
string url = $"https://api.bilibili.com/x/v3/fav/resource/list?media_id={mediaId}&pn={pn}&ps={ps}&platform=web";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
try
{
var resource = JsonConvert.DeserializeObject<FavoritesMediaResourceOrigin>(response);
if (resource == null || resource.Data == null || resource.Data.Medias == null)
{ return null; }
return resource.Data.Medias;
}
catch (Exception e)
{
Console.WriteLine("GetFavoritesMedia()发生异常: {0}", e);
LogManager.Error("FavoritesResource", e);
return null;
}
}
/// <summary>
/// 获取收藏夹内容明细列表(全部)
/// </summary>
/// <param name="mediaId">收藏夹ID</param>
/// <returns></returns>
public static List<FavoritesMedia> GetAllFavoritesMedia(long mediaId)
{
List<FavoritesMedia> result = new List<FavoritesMedia>();
int i = 0;
while (true)
{
i++;
int ps = 20;
var data = GetFavoritesMedia(mediaId, i, ps);
if (data == null || data.Count == 0)
{ break; }
result.AddRange(data);
}
return result;
}
/// <summary>
/// 获取收藏夹全部内容id
/// </summary>
/// <param name="mediaId"></param>
/// <returns></returns>
public static List<FavoritesMediaId> GetFavoritesMediaId(long mediaId)
{
string url = $"https://api.bilibili.com/x/v3/fav/resource/ids?media_id={mediaId}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
try
{
var media = JsonConvert.DeserializeObject<FavoritesMediaIdOrigin>(response);
if (media == null || media.Data == null)
{ return null; }
return media.Data;
}
catch (Exception e)
{
Console.WriteLine("GetFavoritesMediaId()发生异常: {0}", e);
LogManager.Error("FavoritesResource", e);
return null;
}
}
}
}

@ -1,17 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Favorites.Models
{
public class FavStatus : BaseModel
{
[JsonProperty("collect")]
public long Collect { get; set; }
[JsonProperty("play")]
public long Play { get; set; }
[JsonProperty("thumb_up")]
public long ThumbUp { get; set; }
[JsonProperty("share")]
public long Share { get; set; }
}
}

@ -1,19 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Favorites.Models
{
public class FavUpper : BaseModel
{
[JsonProperty("mid")]
public long Mid { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("face")]
public string Face { get; set; }
[JsonProperty("followed")]
public bool Followed { get; set; }
// vip_type
// vip_statue
}
}

@ -1,30 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Favorites.Models
{
// https://api.bilibili.com/x/v3/fav/folder/collected/list
public class FavoritesListOrigin : BaseModel
{
//[JsonProperty("code")]
//public int Code { get; set; }
//[JsonProperty("message")]
//public string Message { get; set; }
//[JsonProperty("ttl")]
//public int Ttl { get; set; }
[JsonProperty("data")]
public FavoritesList Data { get; set; }
}
public class FavoritesList : BaseModel
{
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("list")]
public List<FavoritesMetaInfo> List { get; set; }
//[JsonProperty("has_more")]
//public bool HasMore { get; set; }
}
}

@ -1,43 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Favorites.Models
{
public class FavoritesMedia : BaseModel
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("type")]
public int Type { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("cover")]
public string Cover { get; set; }
[JsonProperty("intro")]
public string Intro { get; set; }
[JsonProperty("page")]
public int Page { get; set; }
[JsonProperty("duration")]
public long Duration { get; set; }
[JsonProperty("upper")]
public FavUpper Upper { get; set; }
// attr
[JsonProperty("cnt_info")]
public MediaStatus CntInfo { get; set; }
[JsonProperty("link")]
public string Link { get; set; }
[JsonProperty("ctime")]
public long Ctime { get; set; }
[JsonProperty("pubtime")]
public long Pubtime { get; set; }
[JsonProperty("fav_time")]
public long FavTime { get; set; }
[JsonProperty("bv_id")]
public string BvId { get; set; }
[JsonProperty("bvid")]
public string Bvid { get; set; }
// season
// ogv
// ugc
}
}

@ -1,32 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Favorites.Models
{
// https://api.bilibili.com/x/v3/fav/resource/ids
public class FavoritesMediaIdOrigin : BaseModel
{
//[JsonProperty("code")]
//public int Code { get; set; }
//[JsonProperty("message")]
//public string Message { get; set; }
//[JsonProperty("ttl")]
//public int Ttl { get; set; }
[JsonProperty("data")]
public List<FavoritesMediaId> Data { get; set; }
}
public class FavoritesMediaId : BaseModel
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("type")]
public int Type { get; set; }
[JsonProperty("bv_id")]
public string BvId { get; set; }
[JsonProperty("bvid")]
public string Bvid { get; set; }
}
}

@ -1,30 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Favorites.Models
{
// https://api.bilibili.com/x/v3/fav/resource/list
public class FavoritesMediaResourceOrigin : BaseModel
{
//[JsonProperty("code")]
//public int Code { get; set; }
//[JsonProperty("message")]
//public string Message { get; set; }
//[JsonProperty("ttl")]
//public int Ttl { get; set; }
[JsonProperty("data")]
public FavoritesMediaResource Data { get; set; }
}
public class FavoritesMediaResource : BaseModel
{
[JsonProperty("info")]
public FavoritesMetaInfo Info { get; set; }
[JsonProperty("medias")]
public List<FavoritesMedia> Medias { get; set; }
[JsonProperty("has_more")]
public bool HasMore { get; set; }
}
}

@ -1,53 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Favorites.Models
{
// https://api.bilibili.com/x/v3/fav/folder/info
public class FavoritesMetaInfoOrigin : BaseModel
{
//[JsonProperty("code")]
//public int Code { get; set; }
//[JsonProperty("message")]
//public string Message { get; set; }
//[JsonProperty("ttl")]
//public int Ttl { get; set; }
[JsonProperty("data")]
public FavoritesMetaInfo Data { get; set; }
}
public class FavoritesMetaInfo : BaseModel
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("fid")]
public long Fid { get; set; }
[JsonProperty("mid")]
public long Mid { get; set; }
// attr
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("cover")]
public string Cover { get; set; }
[JsonProperty("upper")]
public FavUpper Upper { get; set; }
// cover_type
[JsonProperty("cnt_info")]
public FavStatus CntInfo { get; set; }
// type
[JsonProperty("intro")]
public string Intro { get; set; }
[JsonProperty("ctime")]
public long Ctime { get; set; }
[JsonProperty("mtime")]
public long Mtime { get; set; }
// state
[JsonProperty("fav_state")]
public int FavState { get; set; }
[JsonProperty("like_state")]
public int LikeState { get; set; }
[JsonProperty("media_count")]
public int MediaCount { get; set; }
}
}

@ -1,15 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Favorites.Models
{
public class MediaStatus : BaseModel
{
[JsonProperty("collect")]
public long Collect { get; set; }
[JsonProperty("play")]
public long Play { get; set; }
[JsonProperty("danmaku")]
public long Danmaku { get; set; }
}
}

@ -1,63 +0,0 @@
using DownKyi.Core.BiliApi.History.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
using System;
namespace DownKyi.Core.BiliApi.History
{
/// <summary>
/// 历史记录
/// </summary>
public static class History
{
/// <summary>
/// 获取历史记录列表(视频、直播、专栏)
/// startId和startTime必须同时使用才有效分别对应结果中的max和view_at默认为0
/// </summary>
/// <param name="startId">历史记录开始目标ID</param>
/// <param name="startTime">历史记录开始时间</param>
/// <param name="ps">每页项数</param>
/// <param name="business">历史记录ID类型</param>
/// <returns></returns>
public static HistoryData GetHistory(long startId, long startTime, int ps = 30, HistoryBusiness business = HistoryBusiness.ARCHIVE)
{
string businessStr = string.Empty;
switch (business)
{
case HistoryBusiness.ARCHIVE:
businessStr = "archive";
break;
case HistoryBusiness.PGC:
businessStr = "pgc";
break;
case HistoryBusiness.LIVE:
businessStr = "live";
break;
case HistoryBusiness.ARTICLE_LIST:
businessStr = "article-list";
break;
case HistoryBusiness.ARTICLE:
businessStr = "article";
break;
}
string url = $"https://api.bilibili.com/x/web-interface/history/cursor?max={startId}&view_at={startTime}&ps={ps}&business={businessStr}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
try
{
var history = JsonConvert.DeserializeObject<HistoryOrigin>(response);
if (history == null || history.Data == null) { return null; }
return history.Data;
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetHistory()发生异常: {0}", e);
LogManager.Error("History", e);
return null;
}
}
}
}

@ -1,11 +0,0 @@
namespace DownKyi.Core.BiliApi.History.Models
{
public enum HistoryBusiness
{
ARCHIVE = 1, // 稿件
PGC, // 番剧(影视)
LIVE, // 直播
ARTICLE_LIST, // 文集
ARTICLE, // 文章
}
}

@ -1,17 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.History.Models
{
public class HistoryCursor : BaseModel
{
[JsonProperty("max")]
public long Max { get; set; }
[JsonProperty("view_at")]
public long ViewAt { get; set; }
[JsonProperty("business")]
public string Business { get; set; }
[JsonProperty("ps")]
public int Ps { get; set; }
}
}

@ -1,28 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.History.Models
{
// https://api.bilibili.com/x/web-interface/history/cursor?max={startId}&view_at={startTime}&ps={ps}&business={businessStr}
public class HistoryOrigin : BaseModel
{
//[JsonProperty("code")]
//public int Code { get; set; }
//[JsonProperty("message")]
//public string Message { get; set; }
//[JsonProperty("ttl")]
//public int Ttl { get; set; }
[JsonProperty("data")]
public HistoryData Data { get; set; }
}
public class HistoryData : BaseModel
{
[JsonProperty("cursor")]
public HistoryCursor Cursor { get; set; }
//public List<HistoryDataTab> tab { get; set; }
[JsonProperty("list")]
public List<HistoryList> List { get; set; }
}
}

@ -1,46 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.History.Models
{
public class HistoryList : BaseModel
{
[JsonProperty("title")]
public string Title { get; set; }
// long_title
[JsonProperty("cover")]
public string Cover { get; set; }
// covers
[JsonProperty("uri")]
public string Uri { get; set; }
[JsonProperty("history")]
public HistoryListHistory History { get; set; }
[JsonProperty("videos")]
public int Videos { get; set; }
[JsonProperty("author_name")]
public string AuthorName { get; set; }
[JsonProperty("author_face")]
public string AuthorFace { get; set; }
[JsonProperty("author_mid")]
public long AuthorMid { get; set; }
[JsonProperty("view_at")]
public long ViewAt { get; set; }
[JsonProperty("progress")]
public long Progress { get; set; }
// badge
[JsonProperty("show_title")]
public string ShowTitle { get; set; }
[JsonProperty("duration")]
public long Duration { get; set; }
// current
// total
[JsonProperty("new_desc")]
public string NewDesc { get; set; }
// is_finish
// is_fav
// kid
[JsonProperty("tag_name")]
public string TagName { get; set; }
// live_status
}
}

@ -1,25 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.History.Models
{
public class HistoryListHistory : BaseModel
{
[JsonProperty("oid")]
public long Oid { get; set; }
[JsonProperty("epid")]
public long Epid { get; set; }
[JsonProperty("bvid")]
public string Bvid { get; set; }
[JsonProperty("page")]
public int Page { get; set; }
[JsonProperty("cid")]
public long Cid { get; set; }
[JsonProperty("part")]
public string Part { get; set; }
[JsonProperty("business")]
public string Business { get; set; }
[JsonProperty("dt")]
public int Dt { get; set; }
}
}

@ -1,27 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.History.Models
{
// https://api.bilibili.com/x/v2/history/toview
public class ToViewOrigin : BaseModel
{
//[JsonProperty("code")]
//public int Code { get; set; }
//[JsonProperty("message")]
//public string Message { get; set; }
//[JsonProperty("ttl")]
//public int Ttl { get; set; }
[JsonProperty("data")]
public ToViewData Data { get; set; }
}
public class ToViewData : BaseModel
{
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("list")]
public List<ToViewList> List { get; set; }
}
}

@ -1,43 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.History.Models
{
public class ToViewList : BaseModel
{
[JsonProperty("aid")]
public long Aid { get; set; }
// videos
// tid
// tname
// copyright
[JsonProperty("pic")]
public string Pic { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
// pubdate
// ctime
// desc
// state
// duration
// rights
[JsonProperty("owner")]
public VideoOwner Owner { get; set; }
// stat
// dynamic
// dimension
// short_link_v2
// first_frame
// page
// count
[JsonProperty("cid")]
public long Cid { get; set; }
// progress
[JsonProperty("add_at")]
public long AddAt { get; set; }
[JsonProperty("bvid")]
public string Bvid { get; set; }
// uri
// viewed
}
}

@ -1,38 +0,0 @@
using DownKyi.Core.BiliApi.History.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.History
{
/// <summary>
/// 稍后再看
/// </summary>
public static class ToView
{
/// <summary>
/// 获取稍后再看视频列表
/// </summary>
/// <returns></returns>
public static List<ToViewList> GetToView()
{
string url = "https://api.bilibili.com/x/v2/history/toview";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
try
{
var toView = JsonConvert.DeserializeObject<ToViewOrigin>(response);
if (toView == null || toView.Data == null) { return null; }
return toView.Data.List;
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetToView()发生异常: {0}", e);
LogManager.Error("ToView", e);
return null;
}
}
}
}

@ -1,147 +0,0 @@
using DownKyi.Core.Settings;
using DownKyi.Core.Settings.Models;
using DownKyi.Core.Utils;
using DownKyi.Core.Utils.Encryptor;
using System;
using System.IO;
using System.Net;
namespace DownKyi.Core.BiliApi.Login
{
public static class LoginHelper
{
// 本地位置
private static readonly string LOCAL_LOGIN_INFO = Storage.StorageManager.GetLogin();
// 16位密码ps:密码位数没有限制,可任意设置
private static readonly string SecretKey = "EsOat*^y1QR!&0J6";
/// <summary>
/// 保存登录的cookies到文件
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static bool SaveLoginInfoCookies(string url)
{
string tempFile = LOCAL_LOGIN_INFO + "-" + Guid.NewGuid().ToString("N");
CookieContainer cookieContainer = ObjectHelper.ParseCookie(url);
bool isSucceed = ObjectHelper.WriteCookiesToDisk(tempFile, cookieContainer);
if (isSucceed)
{
// 加密密钥,增加机器码
string password = SecretKey + MachineCode.GetMachineCodeString();
try
{
Encryptor.EncryptFile(tempFile, LOCAL_LOGIN_INFO, password);
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("SaveLoginInfoCookies()发生异常: {0}", e);
Logging.LogManager.Error(e);
return false;
}
}
if (File.Exists(tempFile))
{
File.Delete(tempFile);
}
return isSucceed;
}
/// <summary>
/// 获得登录的cookies
/// </summary>
/// <returns></returns>
public static CookieContainer GetLoginInfoCookies()
{
string tempFile = LOCAL_LOGIN_INFO + "-" + Guid.NewGuid().ToString("N");
if (File.Exists(LOCAL_LOGIN_INFO))
{
try
{
// 加密密钥,增加机器码
string password = SecretKey + MachineCode.GetMachineCodeString();
Encryptor.DecryptFile(LOCAL_LOGIN_INFO, tempFile, password);
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetLoginInfoCookies()发生异常: {0}", e);
Logging.LogManager.Error(e);
if (File.Exists(tempFile))
{
File.Delete(tempFile);
}
return null;
}
}
else { return null; }
CookieContainer cookies = ObjectHelper.ReadCookiesFromDisk(tempFile);
if (File.Exists(tempFile))
{
File.Delete(tempFile);
}
return cookies;
}
/// <summary>
/// 返回登录信息的cookies的字符串
/// </summary>
/// <returns></returns>
public static string GetLoginInfoCookiesString()
{
var cookieContainer = GetLoginInfoCookies();
if (cookieContainer == null)
{
return "";
}
var cookies = ObjectHelper.GetAllCookies(cookieContainer);
string cookie = string.Empty;
foreach (var item in cookies)
{
cookie += item.ToString() + ";";
}
return cookie.TrimEnd(';');
}
/// <summary>
/// 注销登录
/// </summary>
/// <returns></returns>
public static bool Logout()
{
if (File.Exists(LOCAL_LOGIN_INFO))
{
try
{
File.Delete(LOCAL_LOGIN_INFO);
SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings
{
Mid = -1,
Name = "",
IsLogin = false,
IsVip = false
});
return true;
}
catch (IOException e)
{
Utils.Debugging.Console.PrintLine("Logout()发生异常: {0}", e);
Logging.LogManager.Error(e);
return false;
}
}
return false;
}
}
}

@ -1,138 +0,0 @@
using DownKyi.Core.BiliApi.Login.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Media.Imaging;
namespace DownKyi.Core.BiliApi.Login
{
/// <summary>
/// 二维码登录
/// </summary>
public static class LoginQR
{
/// <summary>
/// 申请二维码URL及扫码密钥web端
/// </summary>
/// <returns></returns>
public static LoginUrlOrigin GetLoginUrl()
{
string getLoginUrl = "https://passport.bilibili.com/qrcode/getLoginUrl";
string referer = "https://passport.bilibili.com/login";
string response = WebClient.RequestWeb(getLoginUrl, referer);
try
{
var loginUrl = JsonConvert.DeserializeObject<LoginUrlOrigin>(response);
return loginUrl;
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetLoginUrl()发生异常: {0}", e);
LogManager.Error("LoginQR", e);
return null;
}
}
/// <summary>
/// 使用扫码登录web端
/// </summary>
/// <param name="oauthKey"></param>
/// <param name="goUrl"></param>
/// <returns></returns>
public static LoginStatus GetLoginStatus(string oauthKey, string goUrl = "https://www.bilibili.com")
{
string url = "https://passport.bilibili.com/qrcode/getLoginInfo";
string referer = "https://passport.bilibili.com/login";
Dictionary<string, string> parameters = new Dictionary<string, string>
{
{ "oauthKey", oauthKey },
{ "gourl", goUrl }
};
string response = WebClient.RequestWeb(url, referer, "POST", parameters);
var loginInfo = new LoginStatus();
try
{
if (response.Contains("\"code\":0") || response.Contains("\"code\": 0"))
{
var ready = JsonConvert.DeserializeObject<LoginStatusReady>(response);
if (ready == null)
{ return null; }
loginInfo.Code = ready.Code;
loginInfo.Status = ready.Status;
loginInfo.Message = "登录成功";
loginInfo.Url = ready.Data.Url;
}
else
{
var scanning = JsonConvert.DeserializeObject<LoginStatusScanning>(response);
if (scanning == null)
{ return null; }
loginInfo.Code = scanning.Data;
loginInfo.Status = scanning.Status;
loginInfo.Message = scanning.Message;
loginInfo.Url = "";
}
return loginInfo;
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetLoginInfo()发生异常: {0}", e);
LogManager.Error("LoginQR", e);
return null;
}
}
/// <summary>
/// 获得登录二维码
/// </summary>
/// <returns></returns>
public static BitmapImage GetLoginQRCode()
{
try
{
string loginUrl = GetLoginUrl().Data.Url;
return GetLoginQRCode(loginUrl);
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetLoginQRCode()发生异常: {0}", e);
LogManager.Error("LoginQR", e);
return null;
}
}
/// <summary>
/// 根据输入url生成二维码
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static BitmapImage GetLoginQRCode(string url)
{
// 设置的参数影响app能否成功扫码
Bitmap qrCode = Utils.QRCode.EncodeQRCode(url, 12, 10, null, 0, 0, false);
MemoryStream ms = new MemoryStream();
qrCode.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
byte[] bytes = ms.GetBuffer();
ms.Close();
BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = new MemoryStream(bytes);
image.EndInit();
return image;
}
}
}

@ -1,49 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Login.Models
{
// https://passport.bilibili.com/qrcode/getLoginInfo
[JsonObject]
public class LoginStatus : BaseModel
{
[JsonProperty("code")]
public int Code { get; set; }
[JsonProperty("status")]
public bool Status { get; set; }
[JsonProperty("message")]
public string Message { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
}
[JsonObject]
public class LoginStatusScanning : BaseModel
{
[JsonProperty("status")]
public bool Status { get; set; }
[JsonProperty("data")]
public int Data { get; set; }
[JsonProperty("message")]
public string Message { get; set; }
}
[JsonObject]
public class LoginStatusReady : BaseModel
{
[JsonProperty("code")]
public int Code { get; set; }
[JsonProperty("status")]
public bool Status { get; set; }
//public long ts { get; set; }
[JsonProperty("data")]
public LoginStatusData Data { get; set; }
}
[JsonObject]
public class LoginStatusData : BaseModel
{
[JsonProperty("url")]
public string Url { get; set; }
}
}

@ -1,26 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Login.Models
{
// https://passport.bilibili.com/qrcode/getLoginUrl
[JsonObject]
public class LoginUrlOrigin : BaseModel
{
//public int code { get; set; }
[JsonProperty("data")]
public LoginUrl Data { get; set; }
[JsonProperty("status")]
public bool Status { get; set; }
//public long ts { get; set; }
}
[JsonObject]
public class LoginUrl : BaseModel
{
[JsonProperty("oauthKey")]
public string OauthKey { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
}
}

@ -1,100 +0,0 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Media.Imaging;
using DownKyi.Core.BiliApi.LoginNew.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.LoginNew
{
public static class LoginQR
{
/// <summary>
/// 申请二维码URL及扫码密钥web端
/// </summary>
/// <returns></returns>
public static LoginUrlOrigin GetLoginUrl()
{
string getLoginUrl = "https://passport.bilibili.com/x/passport-login/web/qrcode/generate";
string response = WebClient.RequestWeb(getLoginUrl);
Console.Out.WriteLine(response);
try
{
return JsonConvert.DeserializeObject<LoginUrlOrigin>(response);
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetLoginUrl()发生异常: {0}", e);
LogManager.Error("LoginQR", e);
return null;
}
}
/// <summary>
/// 使用扫码登录web端
/// </summary>
/// <param name="qrcodeKey"></param>
/// <param name="goUrl"></param>
/// <returns></returns>
public static LoginStatus GetLoginStatus(string qrcodeKey, string goUrl = "https://www.bilibili.com")
{
string url = "https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=" + qrcodeKey;
string response = WebClient.RequestWeb(url);
try
{
return JsonConvert.DeserializeObject<LoginStatus>(response);
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetLoginInfo()发生异常: {0}", e);
LogManager.Error("LoginQR", e);
return null;
}
}
/// <summary>
/// 获得登录二维码
/// </summary>
/// <returns></returns>
public static BitmapImage GetLoginQRCode()
{
try
{
string loginUrl = GetLoginUrl().Data.Url;
return GetLoginQRCode(loginUrl);
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetLoginQRCode()发生异常: {0}", e);
LogManager.Error("LoginQR", e);
return null;
}
}
/// <summary>
/// 根据输入url生成二维码
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static BitmapImage GetLoginQRCode(string url)
{
// 设置的参数影响app能否成功扫码
Bitmap qrCode = Utils.QRCode.EncodeQRCode(url, 12, 10, null, 0, 0, false);
MemoryStream ms = new MemoryStream();
qrCode.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
byte[] bytes = ms.GetBuffer();
ms.Close();
BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = new MemoryStream(bytes);
image.EndInit();
return image;
}
}
}

@ -1,23 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.LoginNew.Models
{
[JsonObject]
public class LoginStatus : BaseModel
{
[JsonProperty("code")] public int Code { get; set; }
[JsonProperty("message")] public string Message { get; set; }
[JsonProperty("data")] public LoginStatusData Data { get; set; }
}
[JsonObject]
public class LoginStatusData : BaseModel
{
[JsonProperty("url")] public string Url { get; set; }
[JsonProperty("refresh_token")] public string RefreshToken { get; set; }
[JsonProperty("code")] public int Code { get; set; }
[JsonProperty("message")] public string Message { get; set; }
}
}

@ -1,26 +0,0 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.LoginNew.Models
{
// https://passport.bilibili.com/qrcode/getLoginUrl
[JsonObject]
public class LoginUrlOrigin : BaseModel
{
//public int code { get; set; }
[JsonProperty("data")]
public LoginUrl Data { get; set; }
[JsonProperty("code")]
public int Code { get; set; }
//public long ts { get; set; }
}
[JsonObject]
public class LoginUrl : BaseModel
{
[JsonProperty("qrcode_key")]
public string QrcodeKey { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
}
}

@ -1,30 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Models
{
public abstract class BaseModel
{
public string ToString(string format = "")
{
// 设置为去掉null
var jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
switch (format)
{
case "":
return JsonConvert.SerializeObject(this);
case "F":
// 整理json格式
return JsonConvert.SerializeObject(this, Formatting.Indented);
case "N":
// 去掉null后转换为json字符串
return JsonConvert.SerializeObject(this, Formatting.None, jsonSetting);
case "FN":
case "NF":
return JsonConvert.SerializeObject(this, Formatting.Indented, jsonSetting);
default:
return ToString();
}
}
}
}

@ -1,14 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Models
{
public class Dimension : BaseModel
{
[JsonProperty("width")]
public int Width { get; set; }
[JsonProperty("height")]
public int Height { get; set; }
[JsonProperty("rotate")]
public int Rotate { get; set; }
}
}

@ -1,14 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Models.Json
{
public class SubRipText : BaseModel
{
[JsonProperty("lan")]
public string Lan { get; set; }
[JsonProperty("lan_doc")]
public string LanDoc { get; set; }
[JsonProperty("srtString")]
public string SrtString { get; set; }
}
}

@ -1,16 +0,0 @@
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Models.Json
{
public class Subtitle : BaseModel
{
[JsonProperty("from")]
public float From { get; set; }
[JsonProperty("to")]
public float To { get; set; }
[JsonProperty("location")]
public int Location { get; set; }
[JsonProperty("content")]
public string Content { get; set; }
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save