Skip to content

Commit

Permalink
v1.18.1 - 支持在设置中自定义下载的视频的最高分辨率
Browse files Browse the repository at this point in the history
  • Loading branch information
Xmader committed Oct 8, 2018
1 parent b2cc0e8 commit f3cd211
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 19 deletions.
21 changes: 16 additions & 5 deletions biliTwin.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// @match *://www.bilibili.com/bangumi/media/md*
// @match *://www.biligame.com/detail/*
// @match *://www.bilibili.com/watchlater/
// @version 1.18.0
// @version 1.18.1
// @author qli5
// @copyright qli5, 2014+, 田生, grepmusic, zheng qian, ryiwamoto, xmader
// @license Mozilla Public License 2.0; http://www.mozilla.org/MPL/2.0/
Expand Down Expand Up @@ -1796,7 +1796,7 @@ class BiliMonkey {
if (this.flvs)
return this.video_format;

const qn = this.option.videoMaxResolution || "116";
const qn = (this.option.enableVideoMaxResolution && this.option.videoMaxResolution) || "116";
const api_url = `https://api.bilibili.com/x/player/playurl?avid=${aid}&cid=${cid}&otype=json&qn=${qn}`;

let re = await fetch(api_url, { credentials: 'include' });
Expand Down Expand Up @@ -2145,7 +2145,7 @@ class BiliMonkey {
['高清 1080P','80'],
['高清 720P','64'],
['清晰 480P','32'],
['流畅 360P','15'],
['流畅 360P','16'],
]
}

Expand All @@ -2168,6 +2168,7 @@ class BiliMonkey {
resolutionX: 560,
resolutionY: 420,
videoMaxResolution: "116",
enableVideoMaxResolution: false,
}
}

Expand Down Expand Up @@ -8435,15 +8436,25 @@ class UI {
table.append((() => {
const tr1 = document.createElement('tr');
const label = document.createElement('label');
label.append('\u81EA\u5B9A\u4E49\u4E0B\u8F7D\u7684\u89C6\u9891');
const input = document.createElement('input');
input.type = 'checkbox';
input.checked = twin.option["enableVideoMaxResolution"];

input.onchange = e => {
twin.option["enableVideoMaxResolution"] = e.target.checked;
twin.saveOption(twin.option);
};

label.append(input);
label.append('\u81EA\u5B9A\u4E49\u4E0B\u8F7D\u7684\u89C6\u9891\u7684');
const b1 = document.createElement('b');
b1.textContent = '\u6700\u9AD8';
label.append(b1);
label.append('\u5206\u8FA8\u7387\uFF1A');
const select = document.createElement('select');

select.onchange = e => {
twin.option["videoMaxResolution"] = +e.target.value;
twin.option["videoMaxResolution"] = e.target.value;
twin.saveOption(twin.option);
};

Expand Down
25 changes: 18 additions & 7 deletions biliTwinBabelCompiled.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// @match *://www.bilibili.com/bangumi/media/md*
// @match *://www.biligame.com/detail/*
// @match *://www.bilibili.com/watchlater/
// @version 1.18.0
// @version 1.18.1
// @author qli5
// @copyright qli5, 2014+, 田生, grepmusic, zheng qian, ryiwamoto, xmader
// @license Mozilla Public License 2.0; http://www.mozilla.org/MPL/2.0/
Expand Down Expand Up @@ -178,7 +178,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
// @match *://www.bilibili.com/bangumi/media/md*
// @match *://www.biligame.com/detail/*
// @match *://www.bilibili.com/watchlater/
// @version 1.18.0
// @version 1.18.1
// @author qli5
// @copyright qli5, 2014+, 田生, grepmusic, zheng qian, ryiwamoto, xmader
// @license Mozilla Public License 2.0; http://www.mozilla.org/MPL/2.0/
Expand Down Expand Up @@ -3098,7 +3098,7 @@ var BiliMonkey = function () {
return _context30.abrupt('return', _this16.video_format);

case 5:
qn = _this16.option.videoMaxResolution || "116";
qn = _this16.option.enableVideoMaxResolution && _this16.option.videoMaxResolution || "116";
api_url = 'https://api.bilibili.com/x/player/playurl?avid=' + aid + '&cid=' + cid + '&otype=json&qn=' + qn;
_context30.next = 9;
return fetch(api_url, { credentials: 'include' });
Expand Down Expand Up @@ -4139,7 +4139,7 @@ var BiliMonkey = function () {
}, {
key: 'resolutionPreferenceOptions',
get: function get() {
return [['高清 1080P60 (大会员)', '116'], ['高清 1080P+ (大会员)', '112'], ['高清 720P60 (大会员)', '74'], ['高清 1080P', '80'], ['高清 720P', '64'], ['清晰 480P', '32'], ['流畅 360P', '15']];
return [['高清 1080P60 (大会员)', '116'], ['高清 1080P+ (大会员)', '112'], ['高清 720P60 (大会员)', '74'], ['高清 1080P', '80'], ['高清 720P', '64'], ['清晰 480P', '32'], ['流畅 360P', '16']];
}
}, {
key: 'optionDefaults',
Expand All @@ -4161,7 +4161,8 @@ var BiliMonkey = function () {
resolution: false,
resolutionX: 560,
resolutionY: 420,
videoMaxResolution: "116"
videoMaxResolution: "116",
enableVideoMaxResolution: false
};
}
}]);
Expand Down Expand Up @@ -7840,15 +7841,25 @@ var UI = function () {
table.append(function () {
var tr1 = document.createElement('tr');
var label = document.createElement('label');
label.append('\u81EA\u5B9A\u4E49\u4E0B\u8F7D\u7684\u89C6\u9891');
var input = document.createElement('input');
input.type = 'checkbox';
input.checked = twin.option["enableVideoMaxResolution"];

input.onchange = function (e) {
twin.option["enableVideoMaxResolution"] = e.target.checked;
twin.saveOption(twin.option);
};

label.append(input);
label.append('\u81EA\u5B9A\u4E49\u4E0B\u8F7D\u7684\u89C6\u9891\u7684');
var b1 = document.createElement('b');
b1.textContent = '\u6700\u9AD8';
label.append(b1);
label.append('\u5206\u8FA8\u7387\uFF1A');
var select = document.createElement('select');

select.onchange = function (e) {
twin.option["videoMaxResolution"] = +e.target.value;
twin.option["videoMaxResolution"] = e.target.value;
twin.saveOption(twin.option);
};

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bilitwin",
"version": "1.18.0",
"version": "1.18.1",
"description": "bilibili/哔哩哔哩:超清FLV下载,FLV合并,原生MP4下载,弹幕ASS下载,MKV打包,播放体验增强,原生appsecret,不借助其他网站",
"main": "bilitwin.user.js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion src/bilitwin.meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// @match *://www.bilibili.com/bangumi/media/md*
// @match *://www.biligame.com/detail/*
// @match *://www.bilibili.com/watchlater/
// @version 1.18.0
// @version 1.18.1
// @author qli5
// @copyright qli5, 2014+, 田生, grepmusic, zheng qian, ryiwamoto, xmader
// @license Mozilla Public License 2.0; http://www.mozilla.org/MPL/2.0/
Expand Down
5 changes: 3 additions & 2 deletions src/biliuserjs/bilimonkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class BiliMonkey {
if (this.flvs)
return this.video_format;

const qn = this.option.videoMaxResolution || "116"
const qn = (this.option.enableVideoMaxResolution && this.option.videoMaxResolution) || "116"
const api_url = `https://api.bilibili.com/x/player/playurl?avid=${aid}&cid=${cid}&otype=json&qn=${qn}`

let re = await fetch(api_url, { credentials: 'include' })
Expand Down Expand Up @@ -557,7 +557,7 @@ class BiliMonkey {
['高清 1080P','80'],
['高清 720P','64'],
['清晰 480P','32'],
['流畅 360P','15'],
['流畅 360P','16'],
]
}

Expand All @@ -580,6 +580,7 @@ class BiliMonkey {
resolutionX: 560,
resolutionY: 420,
videoMaxResolution: "116",
enableVideoMaxResolution: false,
}
}

Expand Down
11 changes: 9 additions & 2 deletions src/ui/ui.entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,16 @@ class UI {

table.append(<tr>
<label>
自定义下载的视频<b>最高</b>分辨率:
<input
type="checkbox"
checked={twin.option["enableVideoMaxResolution"]}
onchange={e => {
twin.option["enableVideoMaxResolution"] = e.target.checked;
twin.saveOption(twin.option);
}} />
自定义下载的视频的<b>最高</b>分辨率:
<select onchange={e => {
twin.option["videoMaxResolution"] = +e.target.value;
twin.option["videoMaxResolution"] = e.target.value;
twin.saveOption(twin.option);
}}>
{...BiliMonkey.resolutionPreferenceOptions.map(
Expand Down

0 comments on commit f3cd211

Please sign in to comment.