Skip to content

Commit

Permalink
fix. 修复 & 优化
Browse files Browse the repository at this point in the history
  • Loading branch information
btjawa committed Mar 25, 2024
1 parent 97e7547 commit f0c560e
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 17 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- 支持 FLV 下载
- 音乐下载 - `AU`
- 音质最高支持:`320K + 无损SQ FLAC`
- 弹幕获取 - `实时弹幕 / 历史弹幕(Json)`
- 弹幕获取 - `XML+ASS: 实时弹幕 / 历史弹幕`
- 视频AI总结
- 三种登录方式 + 自动刷新登录状态
- 扫码登录
Expand All @@ -37,7 +37,7 @@

# 更多信息

可转至 [Blog](https://blog.btjawa.top/posts/bilitools)
可转至 [Blog](https://btjawa.top/bilitools)

# 感谢

Expand All @@ -47,4 +47,6 @@

[FFmpeg](https://github.com/FFmpeg/FFmpeg)

[aria2](https://github.com/aria2/aria2)
[aria2](https://github.com/aria2/aria2)

[DanmakuFactory](https://github.com/hihkm/DanmakuFactory)
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"jquery": "^3.7.1",
"jsencrypt": "^3.3.2",
"md5": "^2.3.0",
"pako": "^2.1.0",
"qrcode": "^1.5.3",
"sweetalert2": "^11.6.13"
},
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bilitools"
version = "1.0.3"
version = "1.1.1"
description = "BiliTools"
authors = ["btjawa"]
license = "MIT"
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ async fn init_dh(window: tWindow) -> Result<(), String> {
}).await.map_err(|e| e.to_string())?;
{
let mut complete_queue = COMPLETE_QUEUE.lock().await;
complete_queue.clear();
for info in result.map_err(|e| handle_err(window.clone(), e))? {
complete_queue.push_back(info);
}
Expand Down Expand Up @@ -1044,6 +1045,7 @@ async fn sms_login(window: tWindow,
insert_cookie(window.clone(), &cookie).map_err(|e| handle_err(window.clone(), e))?;
let parsed_cookie = parse_cookie_header(&cookie).map_err(|e| handle_err(window.clone(), e))?;
if parsed_cookie.name == "DedeUserID" {
log::info!("短信登录成功: {}", parsed_cookie.value);
window.emit("user-mid", parsed_cookie.value.to_string()).unwrap();
} else if parsed_cookie.name == "bili_jct" {
if let Some(refresh_token) = response_data["data"]["refresh_token"].as_str() {
Expand All @@ -1055,7 +1057,6 @@ async fn sms_login(window: tWindow,
}
}
}
log::info!("短信登录成功");
return Ok("短信登录成功".to_string());
} else {
log::error!("{}, {}", response_data["code"], response_data["message"]);
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"endpoints": [
"https://gh.con.sh/https://raw.githubusercontent.com/btjawa/BiliTools/master/install.json",
"https://mirror.ghproxy.com/https://raw.githubusercontent.com/btjawa/BiliTools/master/install.json",
"https://raw.fgit.cf/btjawa/BiliTools/master/install.json",
"https://cdn.jsdelivr.net/gh/btjawa/BiliTools/install.json",
"https://raw.githubusercontent.com/btjawa/BiliTools/master/install.json"
]
},
Expand Down
21 changes: 13 additions & 8 deletions src/scripts/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { shell, dialog, http, app, os, clipboard } from '@tauri-apps/api';
import $ from "jquery";
import iziToast from "izitoast";
import Swal from "sweetalert2";
import pako from "pako";

import * as tdata from "./data.ts";
import * as format from './format.ts';
Expand Down Expand Up @@ -144,7 +145,10 @@ async function getMediaInfo(rawId, type) {
basicUrl = `https://www.bilibili.com/audio/music-service-c/web/song/info?sid=${id.match(/\d+/)[0]}`;
}
loadingBox.addClass('active');
const basicResp = (await http.fetch(basicUrl, { headers: tdata.headers })).data;
const basicResp = type == "audio" ? JSON.parse((new TextDecoder()).decode(pako.inflate(new Uint8Array(
(await http.fetch(basicUrl, {
headers: tdata.headers, responseType: http.ResponseType.Binary
})).data)))) : (await http.fetch(basicUrl, { headers: tdata.headers })).data;
loadingBox.removeClass('active');
if (basicResp.code === 0) {
if (type == "video") {
Expand All @@ -155,8 +159,10 @@ async function getMediaInfo(rawId, type) {
tags = basicResp.result.styles;
} else if (type == "audio") {
info = basicResp.data;
tags = (await http.fetch(`https://www.bilibili.com/audio/music-service-c/web/tag/song?sid=${id.match(/\d+/)[0]}`,
{ headers: tdata.headers })).data.data.map(item => item.info);
tags = JSON.parse((new TextDecoder()).decode(pako.inflate(new Uint8Array(
(await http.fetch(`https://www.bilibili.com/audio/music-service-c/web/tag/song?sid=${id.match(/\d+/)[0]}`, {
headers: tdata.headers, responseType: http.ResponseType.Binary
})).data)))).data.map(item => item.info);
}
handleMediaList({ info, tags }, type);
return basicResp;
Expand Down Expand Up @@ -232,7 +238,7 @@ function matchDownUrl(details, quality, action, fileType) {
if (target.backup_url) downUrl[1].push(...target.backup_url);
}
}
return [isV, downUrl, quality, quality.ads_id=="flv" ? "only" : action]
return [isV, downUrl, quality, action=="music"||quality.ads_id=="flv" ? "only" : action]
}

function handleDown(isV, downUrl, quality, action, mediaData) {
Expand Down Expand Up @@ -287,7 +293,7 @@ async function bilibili(ts) {
const data = format.id(input);
if (data[1]) {
const path = data[1] == "bangumi" ? "bangumi/play" : data[1];
shell.open(`https://www.bilibili.com/${path}/${data[0]}/${ts?`?ts=${ts}`:''}`);
shell.open(`https://www.bilibili.com/${path}/${data[0]}/${ts?`?t=${ts}`:''}`);
return null;
}
} else iziError('请先点击搜索按钮或返回到搜索结果页面');
Expand Down Expand Up @@ -395,7 +401,7 @@ $(document).ready(function () {
$('.search-btn').on('click', dbc);
searchInput.on('keydown', (e) => {if (e.key == "Enter") dbc()});
$('.backward').on('click', () => backward());
$(".login, .settings, .down-page, .user-profile").append(`<button class="help link"t="https://blog.btjawa.top/posts/bilitools/#Q-A"><span>遇到问题?&nbsp;前往文档</span>&nbsp;<a class="fa-solid fa-arrow-up-right-from-square"></a></button>`);
$(".login, .settings, .down-page, .user-profile").append(`<button class="help link"t="https://btjawa.top/bilitools/#Q-A"><span>遇到问题?&nbsp;前往文档</span>&nbsp;<a class="fa-solid fa-arrow-up-right-from-square"></a></button>`);
$('.link').on('click', function() {shell.open($(this).attr("t"))});
$(document).on('keydown', async function(e) {
if (e.key == "F5" || (e.ctrlKey && e.key == "p") || (e.ctrlKey && e.key == "r")) e.preventDefault();
Expand Down Expand Up @@ -740,8 +746,7 @@ function appendMediaBlock(root, audio) { // 填充视频块
}
getCoverBtn.on('click', async () => {
const content = (await http.fetch(root.pic.replace(/http/g, 'https'), {
headers: tdata.headers,
responseType: http.ResponseType.Binary
headers: tdata.headers, responseType: http.ResponseType.Binary
})).data;
const sel = await saveFile({
filters: [{ name: 'JPG 文件', extensions: ['jpg'] }],
Expand Down

0 comments on commit f0c560e

Please sign in to comment.