Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit fcaf2e6

Browse files
committed
Updated for future ability to choose downloader
1 parent 4f32a83 commit fcaf2e6

File tree

3 files changed

+68
-55
lines changed

3 files changed

+68
-55
lines changed

app/index.html

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,31 +100,33 @@ <h4></h4>
100100
<input type="text" id="playerpath" placeholder="Full path to a player" style="width: 100%;" onBlur="saveSettings()"><br>
101101
<small>You <b>MUST</b> also add <i>%url%</i> to the command to denote where to place the URL to the replay. (Ex: mpv %url%)</small>
102102
</li>
103+
</ul>
104+
</div>
105+
<div class="section">
106+
<ul>
103107
<li style="padding-bottom: 5px;"><h4>Downloads</h4></li>
104-
<li style="padding-bottom: 20px;">
108+
<li>
105109
<ul style="margin: 16px 0 0; padding: 0;">
106-
<li>
107-
LiveMe Pro Tools now uses JDownloader2 for all downloading. You will need to add and enable <a href="#" onClick="openURL('https://github.com/nemec/JDHttpAPI')">this</a> plugin in JDownloader2 for downloading to work now.<br>
108-
</li>
109-
<li style="margin: 8px 0;">
110-
IP of jDownloader Computer:
111-
<input type="text" id="jdownloader-ip" placeholder="localhost" value="127.0.0.1" disabled style="width: 90px; float: right; text-align: right;">
110+
<li style="line-height: 16px;">
111+
Select the download handler you would like to use:
112+
<div class="select" style="display: inline-block; margin-left: 8px; vertical-align: middle;">
113+
<select id="download-handler" onChange="saveSettings()">
114+
<option selected value="1">jDownloader2</option>
115+
</select>
116+
</div>
112117
</li>
113-
<li style="margin: 8px 0;">
114-
Port Number:
115-
<input type="text" id="jdownloader-ip" placeholder="8729" value="8729" disabled style="width: 50px; float: right; text-align: right;">
116-
</li>
117-
<li style="margin: 8px 0;">
118-
Password:
119-
<input type="text" id="jdownloader-ip" placeholder="blank" value="" disabled style="width: 90px; float: right; text-align: right;">
120-
</li>
121-
<li>
122-
<small>LiveMe Pro Tools uses the defaults of the plugin running on the local computer.</small>
118+
<li style="padding: 20px 0; font-size: 9pt;">
119+
You will need to add and enable the <a href="#" onClick="openURL('https://github.com/nemec/JDHttpAPI')">JDHttpAPI plugin</a> in jDownloader2
120+
for downloading to work. This program uses the default configuration of that plugin.<br>
123121
</li>
124122
</ul>
125123
</li>
124+
</ul>
125+
</div>
126+
<div class="section">
127+
<ul>
126128
<li style="padding-bottom: 5px;"><h4>Fans and Followings</h4></li>
127-
<li style="padding-bottom: 20px;">
129+
<li style="line-height: 24px;">
128130
<input type="checkbox" id="viewmode-followings"> Hide followings with no replays.<br>
129131
<input type="checkbox" id="viewmode-followers"> Hide followers with no replays.<br>
130132
</li>

app/js/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ function _checkBookmark(i) {
426426
DataManager.updateBookmark(b);
427427

428428
if (b.counts.replays > 0) {
429-
LiveMe.getUserReplays(user.user_id.uid, 1, 2).then(replays => {
429+
LiveMe.getUserReplays(tempvar.list[i].uid, 1, 2).then(replays => {
430430

431431
if (replays == undefined) return;
432432
if (replays.length < 1) return;
@@ -804,18 +804,19 @@ function initSettingsPanel() {
804804
$('#viewmode-followings').prop('checked', appSettings.get('general.hide_zeroreplay_followings'));
805805

806806
$('#playerpath').val(appSettings.get('general.playerpath'));
807-
808-
807+
$('#download-handler').val(appSettings.get('downloads.handler'));
809808

810809
var v = remote.app.getVersion().split('.')[2];
811810
$('#settings h6#version').html('Version ' + v);
812811
}
813812

814-
function saveSettings() {
813+
function saveSettings() {
814+
815815
appSettings.set('general.hide_zeroreplay_fans', ($('#viewmode-followers').is(':checked') ? true : false) )
816816
appSettings.set('general.hide_zeroreplay_followings', ($('#viewmode-followings').is(':checked') ? true : false) )
817817

818818
appSettings.set('general.playerpath', $('#playerpath').val());
819+
appSettings.set('downloads.handler', $('#download-handler').val());
819820
}
820821

821822
function resetSettings() {

index.js

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
const appName = 'LiveMe Pro Tools';
66

77
const { app, BrowserWindow, ipcMain, Menu, shell, dialog } = require('electron'),
8-
{ exec } = require('child_process');
8+
{ exec, execFile } = require('child_process');
99
os = require('os'),
1010
fs = require('fs'),
1111
path = require('path'),
@@ -48,9 +48,17 @@ function createWindow() {
4848
playerWindow: [ 370, 680 ],
4949
bookmarksWindow: [ 400, 720 ]
5050
});
51-
51+
appSettings.set('downloads', {
52+
handler: 1
53+
});
5254
}
5355

56+
if (!appSettings.get('downloads.handler')) {
57+
appSettings.set('downloads', {
58+
handler: 1
59+
});
60+
}
61+
5462
var test = appSettings.get('position');
5563
if (test.mainWindow[1] == undefined) {
5664
appSettings.set('position', {
@@ -220,38 +228,40 @@ function downloadFile() {
220228

221229
if (download_list.length == 0) return;
222230

223-
LiveMe.getVideoInfo(download_list[0])
224-
.then(video => {
231+
var handler = appSettings.get('downloads.handler');
232+
233+
LiveMe.getVideoInfo(download_list[0]).then(video => {
234+
let isLive = video.hlsvideosource.endsWith('flv') || video.hlsvideosource.indexOf('liveplay') > 0 ? true : false;
235+
if (isLive) {
236+
mainWindow.webContents.send('popup-message', {
237+
text: 'Video is live and cannot be downloaded.'
238+
});
239+
} else {
240+
request({
241+
url: 'http://localhost:8297/addLink',
242+
method: 'post',
243+
json: true,
244+
timeout: 3000,
245+
body: {
246+
url: video.hlsvideosource,
247+
packageName: video.vid,
248+
forcePackageName: false
249+
}
250+
}, function(err,httpResponse,body) {
251+
if (err) {
252+
mainWindow.webContents.send('popup-message', {
253+
text: 'No response from jDownloader, trying again...'
254+
});
255+
setTimeout(function(){ downloadFile(); }, 2000);
256+
} else if (httpResponse.statusCode == 200) {
257+
DataManager.addDownloaded(download_list[0]);
258+
download_list.shift();
259+
}
260+
});
261+
}
262+
});
263+
225264

226-
let isLive = video.hlsvideosource.endsWith('flv') || video.hlsvideosource.indexOf('liveplay') > 0 ? true : false;
227-
if (isLive) {
228-
mainWindow.webContents.send('popup-message', {
229-
text: 'Video is live and cannot be downloaded.'
230-
});
231-
} else {
232-
request({
233-
url: 'http://localhost:8297/addLink',
234-
method: 'post',
235-
json: true,
236-
timeout: 3000,
237-
body: {
238-
url: video.hlsvideosource,
239-
packageName: video.vid,
240-
forcePackageName: false
241-
}
242-
}, function(err,httpResponse,body) {
243-
if (err) {
244-
mainWindow.webContents.send('popup-message', {
245-
text: 'No response from jDownloader, trying again...'
246-
});
247-
setTimeout(function(){ downloadFile(); }, 2000);
248-
} else if (httpResponse.statusCode == 200) {
249-
DataManager.addDownloaded(download_list[0]);
250-
download_list.shift();
251-
}
252-
});
253-
}
254-
});
255265
}
256266

257267

0 commit comments

Comments
 (0)