Skip to content

Commit

Permalink
增加清晰度切换
Browse files Browse the repository at this point in the history
  • Loading branch information
OToNaShiAKi committed Jul 29, 2023
1 parent 5c0c46a commit 23d6224
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "material-douden-tool",
"version": "1.2.2",
"version": "1.2.3",
"private": true,
"author": "濯墨",
"scripts": {
Expand Down
10 changes: 9 additions & 1 deletion src/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
LoginStatistics,
PubShield,
SubShield,
ClickRedPocket
} from "./plugins/axios";
import { Stacks } from "./util/Stacks";
import { e, TranslateResult } from "./util/Translate";
Expand Down Expand Up @@ -214,7 +215,7 @@ ipcMain.handle("Translate", async (event, phrase, to = "zh") => {
return result;
});

ipcMain.handle("TrackLive", (event, roomid) => GetLiveInfo(roomid));
ipcMain.handle("TrackLive", (event, roomid, qn = 0) => GetLiveInfo(roomid, qn));

ipcMain.on("SaveFiles", async (event, Datas, name, encoding = "buffer") => {
const isArray = Array.isArray(Datas);
Expand Down Expand Up @@ -295,3 +296,10 @@ ipcMain.handle("GetFont", async (event) => {
ipcMain.on("PubShield", PubShield);

ipcMain.handle("SubShield", (event, use = true) => SubShield(use));

ipcMain.handle("ClickRedPocket", async (event, ...ids) => {
clearInterval(Stacks.timer);
const result = await ClickRedPocket(...ids);
Stacks.timer = setInterval(Stacks.interval, 1750);
return result;
});
7 changes: 1 addition & 6 deletions src/pages/index/views/Cookie.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ import HonourAvatar from "../../../components/HonourAvatar.vue";
export default {
name: "Cookie",
components: { Pack, HonourAvatar },
data: ({ $store: { state } }) => ({
cookie: state.cookie,
tab: "QQMusic",
code: "",
music: "",
}),
data: ({ $store: { state } }) => ({ cookie: state.cookie, code: "" }),
created() {
!this.cookie && this.Login();
ipcRenderer.on("Login", (event, result) => {
Expand Down
66 changes: 51 additions & 15 deletions src/pages/support/views/Video.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,31 @@
<v-container class="fix-input">
<video class="rounded-lg" controls id="tracing" />
<p class="d-flex justify-space-between caption align-center">
<span>
<span class="flex-grow-1">
开始时间:{{ new Date(timer * 1000) | FormatTime }}
<br />
开播后同传输入框中按下Alt+P即可记录时点
</span>
<v-btn icon color="primary" @click="() => Live(selected, true)">
<v-select
class="flex-grow-0 mr-3"
v-model="quality"
@change="(value) => Live(selected, value, true)"
solo
hide-details
dense
:items="qns"
:prepend-inner-icon="icon"
>
<template v-slot:item="{ item, on, attrs }">
<v-list-item v-on="on" v-bind="attrs">
<v-list-item-icon>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-title>{{ item.text }}</v-list-item-title>
</v-list-item>
</template>
</v-select>
<v-btn icon color="primary" @click="() => Live(selected, quality, true)">
<v-icon>mdi-refresh</v-icon>
</v-btn>
</p>
Expand Down Expand Up @@ -101,6 +120,8 @@ export default {
rooms: [],
images: Screenshot,
timer: null,
qns: [],
quality: 0,
}),
mounted() {
const select = (localStorage.getItem("select") || "").split(",");
Expand All @@ -113,31 +134,46 @@ export default {
this.Live(find);
}
},
computed: {
icon: ({ quality, qns }) => {
const find = qns.find(({ value }) => value === quality);
return find && find.icon;
},
},
methods: {
async Live({ value: roomid }, refresh = false) {
const live = await ipcRenderer.invoke("TrackLive", roomid);
async Live({ value: roomid }, qn = this.quality, refresh = false) {
const live = await ipcRenderer.invoke("TrackLive", roomid, qn);
const rooms = JSON.parse(localStorage.getItem("rooms"));
const select = (localStorage.getItem("select") || "").split(",");
this.rooms = rooms.filter(({ value }) => select.includes(value));
if (!this.rooms.find(({ value }) => value === this.selected.value)) {
this.selected = this.rooms[0] || "";
}
if (refresh) {
CreatePlayer.player.roomid = null;
live.live_status = 1;
live.live_time = -1
}
if (
refresh ||
(roomid == this.selected.value &&
live.live_status &&
mseLivePlayback &&
(!CreatePlayer.player || roomid != CreatePlayer.player.roomid))
roomid == this.selected.value &&
live.live_status &&
live.live_time &&
mseLivePlayback &&
(!CreatePlayer.player || roomid != CreatePlayer.player.roomid)
) {
const video = document.getElementById("tracing");
if (CreatePlayer.player) {
CreatePlayer.player.unload();
CreatePlayer.player.detachMediaElement();
CreatePlayer.player.destroy();
}
this.qns = live.accept_qn;
this.quality = live.current_qn;
CreatePlayer.player = CreatePlayer(live, video);
}
this.timer = live.live_time;
const rooms = JSON.parse(localStorage.getItem("rooms"));
const select = (localStorage.getItem("select") || "").split(",");
this.rooms = rooms.filter(({ value }) => select.includes(value));
if (!this.rooms.find(({ value }) => value === this.selected.value)) {
this.selected = this.rooms[0] || "";
}
},
Screenshot() {
if (!this.timer || this.timer <= 0) return;
Expand Down
48 changes: 43 additions & 5 deletions src/plugins/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ import { BrowserWindow } from "electron";
import { AllWindows } from "../background";
import axios from "axios";

const VideoIcons = Object.freeze({
30000: "mdi-dolby",
20000: "mdi-video-4k-box",
10000: "mdi-video-box",
400: "mdi-compare",
250: "mdi-quality-high",
150: "mdi-quality-medium",
80: "mdi-quality-low",
});

export const GetUserRoomInfo = async (room_id) => {
try {
const {
Expand Down Expand Up @@ -67,7 +77,7 @@ export const GetLoginInfo = async (oauthKey) => {
}
};

export const GetLiveInfo = async (roomid) => {
export const GetLiveInfo = async (roomid, qn = 0) => {
try {
const { live_time, live_status, uid, playurl_info } = await Bilibili.get(
"/xlive/web-room/v2/index/getRoomPlayInfo",
Expand All @@ -77,7 +87,7 @@ export const GetLiveInfo = async (roomid) => {
protocol: "0,1",
format: "0,1,2",
codec: "0,1",
qn: 0,
qn,
platform: "web",
ptype: 8,
dolby: 5,
Expand All @@ -86,7 +96,8 @@ export const GetLiveInfo = async (roomid) => {
);
const result = { live_time, live_status, roomid, uid };
if (playurl_info) {
const {
console.log(JSON.stringify(playurl_info))
const {
playurl: {
g_qn_desc,
stream: [
Expand All @@ -101,15 +112,21 @@ export const GetLiveInfo = async (roomid) => {
],
},
} = playurl_info;
result.g_qn_desc = g_qn_desc;
result.accept_qn = g_qn_desc
.filter(({ qn }) => accept_qn.includes(qn))
.map(({ qn, desc }) => ({
icon: VideoIcons[qn],
value: qn,
text: desc,
}));
result.base_url = base_url;
result.accept_qn = accept_qn;
result.current_qn = current_qn;
result.url_info = url_info;
result.format_name = format_name;
}
return result;
} catch (error) {
console.log(error);
return { roomid, live_status: 0, code: error.code };
}
};
Expand Down Expand Up @@ -558,3 +575,24 @@ export const SubShield = async (use = true) => {
return [];
}
};

export const ClickRedPocket = async (ruid, room_id, lot_id) => {
try {
return await Bilibili.post(
"/xlive/lottery-interface/v1/popularityRedPocket/RedPocketDraw",
QS.stringify({
ruid,
room_id,
lot_id,
spm_id: "444.8.red_envelope.extract",
jump_from: "",
session_id: "",
visit_id: "",
csrf: Bilibili.defaults.data.csrf,
csrf_token: Bilibili.defaults.data.csrf_token,
})
);
} catch (error) {
return false;
}
};

0 comments on commit 23d6224

Please sign in to comment.