Skip to content

Commit

Permalink
加密AES Key 增加Header访问,增加版本升级提醒
Browse files Browse the repository at this point in the history
  • Loading branch information
HeiSir committed Jun 21, 2020
1 parent bd7f3aa commit 6150710
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 112 deletions.
7 changes: 6 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ html{
border-color: #47b3f7;
box-sizing: border-box;
}
.heisir .main .addTask input[type=text]{

.heisir .main .addTask .urls{
line-height: 32px;
border: 1px solid;
border-color: #47b3f7;
box-sizing: border-box;
width: 60%;
padding: 0 10px;
border-right: 0;
Expand Down
28 changes: 23 additions & 5 deletions ffmpegTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,29 @@ const got = require('got');


(async () => {
const { body } = await got('http://v.ytsjk.cn/38df87dc4b70456aa2eadde6e713fa38/6a2a090b523d4c9491277a41bb6a2567-dcb98c29eb2d3f032c85e7a6cf2c5b83-sd.m3u8',{headers:{
'Origin':'http://www.ytsjk.cn',
'Referer':'http://www.ytsjk.cn',
}});
console.log(body);
const { headers } = await got("https://www.aoxx69.com/video/video-play?id=MIAA-203&type=1&autoplay=0&poster=");
console.log(headers);
let cookies = '';
if(headers['set-cookie'])
{
headers['set-cookie'].forEach(cookie => {
let mes = cookie.match(/^(.*?)=(.*?);/i)
mes && (cookies += mes[0]);
});
console.log(cookies);
}
const h = {
'Origin':'https://www.aoxx69.com',
'Referer':'https://www.aoxx69.com',
'cookie':cookies,
};
const { body } = await got('https://ssa.aoxx69.com/MIAA-203/MIAA-203.m3u8',{ headers : h });

//console.log(body);

//const r = await got('https://ssa.aoxx69.com/MIAA-203/ts/MIAA-203-2.ts',{ headers:h});

//console.log(r);
})();


Expand Down
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>HLS Downloader</title>
<title>M3U8-Downloader</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body class="heisir">
<div class="header"><span class="title">M3U8-Downloader v1.0.6</span>
<div class="header"><span class="title">M3U8-Downloader v1.0.7</span>
<div class="space"></div>
<a class="home" href="https://tools.heisir.cn/HLSDownload/" target="_blank">官网</a>
<a class="qqgroup" href="https://jq.qq.com/?_wv=1027&k=nhFrZBS0">点击加群</a>
Expand All @@ -17,7 +17,7 @@
<div class="main">
<div class="addTask">
<input class=httpHeader type="button" value="自定义头">
<input type="text" placeholder="请输入m3u8地址">
<input class=urls placeholder="请输入m3u8地址" />
<input class=download type="button" value="下载">
<label><input class="setting_isdelts" type="checkbox" onclick="setting_isdelts()" checked />删除TS文件</label>

Expand Down
72 changes: 56 additions & 16 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
};
var _this = this;
exports.__esModule = true;
var _a = require('electron'), app = _a.app, BrowserWindow = _a.BrowserWindow, Tray = _a.Tray, ipcMain = _a.ipcMain, shell = _a.shell, Menu = _a.Menu;
var _a = require('electron'), app = _a.app, BrowserWindow = _a.BrowserWindow, Tray = _a.Tray, ipcMain = _a.ipcMain, shell = _a.shell, Menu = _a.Menu, dialog = _a.dialog;
var spawn = require('child_process').spawn;
var path = require('path');
var Parser = require('m3u8-parser').Parser;
Expand All @@ -61,6 +61,7 @@ var crypto = require('crypto');
var got = require('got');
var Readable = require('stream').Readable;
var ffmpeg = require('fluent-ffmpeg');
var package_self = require('./package.json');
var isdelts = true;
var mainWindow = null;
var playerWindow = null;
Expand Down Expand Up @@ -124,6 +125,33 @@ function createPlayerWindow(src) {
// 加载index.html文件
playerWindow.loadFile(path.join(__dirname, 'player.html'), { search: "src=" + src });
}
function checkUpdate() {
return __awaiter(this, void 0, void 0, function () {
var body, _package;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, got("https://tools.heisir.cn/HLSDownload/package.json")["catch"](console.log)];
case 1:
body = (_a.sent()).body;
if (body != '') {
try {
_package = JSON.parse(body);
if (_package.version != package_self.version) {
if (dialog.showMessageBoxSync(mainWindow, { type: 'question', buttons: ["Yes", "No"], message: "\u68C0\u6D4B\u5230\u65B0\u7248\u672C(" + _package.version + ")\uFF0C\u662F\u5426\u8981\u6253\u5F00\u5347\u7EA7\u9875\u9762\uFF0C\u4E0B\u8F7D\u6700\u65B0\u7248" }) == 0) {
shell.openExternal("https://tools.heisir.cn/HLSDownload/");
return [2 /*return*/];
}
}
}
catch (error) {
console.log(error);
}
}
return [2 /*return*/];
}
});
});
}
app.on('ready', function () {
createWindow();
tray = new Tray(path.join(__dirname, 'icon/logo.png'));
Expand Down Expand Up @@ -160,6 +188,8 @@ app.on('ready', function () {
switch (_a.label) {
case 0:
_a.trys.push([0, 4, , 5]);
checkUpdate();
setInterval(checkUpdate, 600000);
HMACCOUNT = '';
if (fs.existsSync('tongji.ini')) {
HMACCOUNT = fs.readFileSync('tongji.ini', { encoding: "utf-8", flag: "r" });
Expand Down Expand Up @@ -307,10 +337,11 @@ var QueueObject = /** @class */ (function () {
}
QueueObject.prototype.callback = function (_callback) {
return __awaiter(this, void 0, void 0, function () {
var partent_uri, segment, uri_ts, mes, filename, filpath, filpath_dl, index, that, stat, aes_path, key_uri, key_, iv_, cipher, inputData, outputData;
var partent_uri, segment, uri_ts, mes, filename, filpath, filpath_dl_1, index, that, stat, aes_path, key_uri, key_, iv_, cipher, inputData, outputData, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 11, 12, 13]);
if (!globalCond[this.id]) {
_callback();
return [2 /*return*/];
Expand All @@ -335,7 +366,7 @@ var QueueObject = /** @class */ (function () {
}
filename = ((this.idx + 1) + '').padStart(6, '0') + ".ts";
filpath = path.join(this.dir, filename);
filpath_dl = path.join(this.dir, filename + ".dl");
filpath_dl_1 = path.join(this.dir, filename + ".dl");
console.log("2 " + segment.uri, "" + filename);
index = 0;
_a.label = 1;
Expand All @@ -345,13 +376,13 @@ var QueueObject = /** @class */ (function () {
that = this;
return [4 /*yield*/, download(uri_ts, that.dir, { filename: filename + ".dl", timeout: 30000, headers: that.headers })["catch"](function (err) {
console.log(err);
if (fs.existsSync(filpath_dl))
fs.unlinkSync(filpath_dl);
if (fs.existsSync(filpath_dl_1))
fs.unlinkSync(filpath_dl_1);
})];
case 2:
_a.sent();
if (!fs.existsSync(filpath_dl)) return [3 /*break*/, 8];
stat = fs.statSync(filpath_dl);
if (!fs.existsSync(filpath_dl_1)) return [3 /*break*/, 8];
stat = fs.statSync(filpath_dl_1);
if (!(stat.size > 0)) return [3 /*break*/, 7];
if (!(segment.key != null && segment.key.method != null)) return [3 /*break*/, 5];
aes_path = path.join(this.dir, "aes.key");
Expand All @@ -360,7 +391,7 @@ var QueueObject = /** @class */ (function () {
if (!/^http.*/.test(segment.key.uri)) {
key_uri = partent_uri + segment.key.uri;
}
return [4 /*yield*/, download(key_uri, that.dir, { filename: "aes.key" })["catch"](console.error)];
return [4 /*yield*/, download(key_uri, that.dir, { filename: "aes.key", headers: that.headers })["catch"](console.error)];
case 3:
_a.sent();
_a.label = 4;
Expand All @@ -372,26 +403,28 @@ var QueueObject = /** @class */ (function () {
: Buffer.from(that.idx.toString(16).padStart(32, '0'), 'hex');
cipher = crypto.createDecipheriv((segment.key.method + "-cbc").toLowerCase(), key_, iv_);
cipher.on('error', console.error);
inputData = fs.readFileSync(filpath_dl);
inputData = fs.readFileSync(filpath_dl_1);
outputData = Buffer.concat([cipher.update(inputData), cipher.final()]);
fs.writeFileSync(filpath, outputData);
fs.unlinkSync(filpath_dl);
fs.unlinkSync(filpath_dl_1);
that.then && that.then();
_callback();
return [2 /*return*/];
}
catch (error) {
console.error(error);
fs.unlinkSync(filpath_dl);
fs.unlinkSync(filpath_dl_1);
}
finally {
_callback();
return [2 /*return*/];
}
}
return [3 /*break*/, 6];
case 5:
fs.renameSync(filpath_dl, filpath);
fs.renameSync(filpath_dl_1, filpath);
_a.label = 6;
case 6: return [3 /*break*/, 8];
case 7:
fs.unlinkSync(filpath_dl);
fs.unlinkSync(filpath_dl_1);
_a.label = 8;
case 8:
if (fs.existsSync(filpath)) {
Expand All @@ -408,8 +441,15 @@ var QueueObject = /** @class */ (function () {
else {
this["catch"] && this["catch"]();
}
return [3 /*break*/, 13];
case 11:
e_1 = _a.sent();
console.log(e_1);
return [3 /*break*/, 13];
case 12:
_callback();
return [2 /*return*/];
return [7 /*endfinally*/];
case 13: return [2 /*return*/];
}
});
});
Expand Down
Loading

0 comments on commit 6150710

Please sign in to comment.