mirror of
https://github.com/JustusPlays78/SectorFileUpdater.git
synced 2025-04-29 10:10:57 +00:00
etwas besser geschrieben + href added
This commit is contained in:
parent
5a71d336fb
commit
cc300769b4
11
updater/package-lock.json
generated
11
updater/package-lock.json
generated
@ -13,6 +13,7 @@
|
||||
"decompress-zip": "^0.3.3",
|
||||
"electron-dl": "^3.3.1",
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"http": "^0.0.1-security",
|
||||
"js-yaml": "^4.1.0",
|
||||
"superagent": "^8.0.3"
|
||||
},
|
||||
@ -3597,6 +3598,11 @@
|
||||
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/http": {
|
||||
"version": "0.0.1-security",
|
||||
"resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz",
|
||||
"integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g=="
|
||||
},
|
||||
"node_modules/http-cache-semantics": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
|
||||
@ -9216,6 +9222,11 @@
|
||||
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
|
||||
"dev": true
|
||||
},
|
||||
"http": {
|
||||
"version": "0.0.1-security",
|
||||
"resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz",
|
||||
"integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g=="
|
||||
},
|
||||
"http-cache-semantics": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
|
||||
|
@ -49,6 +49,7 @@
|
||||
"decompress-zip": "^0.3.3",
|
||||
"electron-dl": "^3.3.1",
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"http": "^0.0.1-security",
|
||||
"js-yaml": "^4.1.0",
|
||||
"superagent": "^8.0.3"
|
||||
},
|
||||
|
@ -12,9 +12,9 @@
|
||||
<p id="ouput">Output Test here</p>
|
||||
|
||||
<p>Input URL</p>
|
||||
<input type="text" id="urlBox" name="name" size="80">
|
||||
<input type="text" id="urlBox" name="name" size="80" readonly>
|
||||
<p>Input Directory</p>
|
||||
<input type="text" id="dirBox" name="name" size="80">
|
||||
<input type="text" id="dirBox" name="name" size="80" readonly>
|
||||
<progress id="progressbar" max="100" value="0"></progress>
|
||||
|
||||
|
||||
|
@ -5,6 +5,9 @@ const path = require('path');
|
||||
var fs = require('fs');
|
||||
const yaml = require('js-yaml');
|
||||
var DecompressZip = require('decompress-zip');
|
||||
const { Http2ServerRequest } = require('http2');
|
||||
const superagent = require('superagent').agent();
|
||||
const http = require('node:http');
|
||||
|
||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||
// eslint-disable-next-line global-require
|
||||
@ -75,8 +78,23 @@ const createWindow = () => {
|
||||
ipcMain.on("download", (event, info) => {
|
||||
// https://dms.pabr.de/s/SpBiQYADTNak7R5/download
|
||||
info.properties.onProgress = status => mainWindow.webContents.send("download progress", status);
|
||||
download(BrowserWindow.getFocusedWindow(), info.url, info.properties)
|
||||
.then(dl => mainWindow.webContents.send("download complete", dl.getSavePath()));
|
||||
// http.request
|
||||
let file = superagent.get('https://files.aero-nav.com/EDGG/Full_Package_20221104183433-221101-3.zip')
|
||||
.set('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0')
|
||||
.set('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8')
|
||||
.set('Accept-Language', 'en-US,en;q=0.5')
|
||||
.set('Accept-Encoding', 'gzip, deflate, br')
|
||||
.set('DNT', '1')
|
||||
.set('Connection', 'keep-alive')
|
||||
.set('Referer', 'http://files.aero-nav.com/')
|
||||
.set('Upgrade-Insecure-Requests', '1')
|
||||
.set('Sec-Fetch-Dest', 'document')
|
||||
.set('Sec-Fetch-Mode', 'navigate')
|
||||
.set('Sec-Fetch-Site', 'cross-site')
|
||||
.set('Sec-Fetch-User', '?1');
|
||||
// Working Download
|
||||
// download(BrowserWindow.getFocusedWindow(), info.url, info.properties)
|
||||
// .then(dl => mainWindow.webContents.send("download complete", dl.getSavePath()));
|
||||
});
|
||||
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
const { ipcRenderer, dialog } = require('electron');
|
||||
const superagent = require('superagent').agent();
|
||||
|
||||
// Global Variabels
|
||||
let hrefLinks = "";
|
||||
|
||||
|
||||
ipcRenderer.on("download complete", (event, file) => {
|
||||
console.log(file); // Full file path
|
||||
// Datei entpacken
|
||||
@ -11,13 +15,17 @@ ipcRenderer.on("download progress", (event, progress) => {
|
||||
document.getElementById('progressbar').value = cleanProgressInPercentages;
|
||||
});
|
||||
|
||||
let fileSelect = document.getElementById('files');
|
||||
let donwloadBtn = document.getElementById('download');
|
||||
donwloadBtn.addEventListener('click', (e) => {
|
||||
let directoryPath = document.getElementById('dirBox');
|
||||
let urlPath = document.getElementById('urlBox');
|
||||
console.log(hrefLinks[fileSelect.options.selectedIndex]);
|
||||
ipcRenderer.send("download", {
|
||||
url: urlPath.value,
|
||||
properties: { directory: directoryPath.value }
|
||||
url: hrefLinks[fileSelect.options.selectedIndex],
|
||||
properties: {
|
||||
directory: directoryPath.value
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -51,20 +59,22 @@ const removeFileItems = async() => {
|
||||
|
||||
const getUpdates = async() => {
|
||||
|
||||
|
||||
// Get all GNG Options
|
||||
let courses = await superagent.get('https://files.aero-nav.com/');
|
||||
let text = courses.text.split("Download Pages").pop();
|
||||
let textArray = text.split("\n");
|
||||
let liste = "";
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
if (text[i] === ">" && text[i - 1] === "b" && text[i - 2] === "<") {
|
||||
let i2 = i + 1;
|
||||
while (text[i2] !== "<") {
|
||||
liste += text[i2];
|
||||
i2++;
|
||||
}
|
||||
liste += "\n";
|
||||
let firstElement = "<b>";
|
||||
let lastElement = "</b>";
|
||||
textArray.forEach(element => {
|
||||
if (element.includes(firstElement)) {
|
||||
liste += element.substring(
|
||||
element.indexOf(firstElement) + firstElement.length,
|
||||
element.indexOf(lastElement, element.indexOf(firstElement))) +
|
||||
"\n";
|
||||
}
|
||||
}
|
||||
});
|
||||
const listeArray = liste.split("\n");
|
||||
|
||||
// Add to html selector
|
||||
@ -82,7 +92,8 @@ const getUpdates = async() => {
|
||||
// Check Files
|
||||
let getFilesBtn = document.getElementById('getFiles');
|
||||
getFilesBtn.addEventListener('click', (e) => {
|
||||
getFiles();
|
||||
hrefLinks = getFiles();
|
||||
console.log("leaveme alone " + hrefLinks);
|
||||
});
|
||||
|
||||
const getFiles = async() => {
|
||||
@ -92,8 +103,27 @@ const getFiles = async() => {
|
||||
let courses = await superagent.get(region);
|
||||
let text = courses.text.split("Released</th><th colspan='2'>Download</th></tr>").pop();
|
||||
text = text.split("<h1>AIRAC <small>News</small></h1>")[0]
|
||||
console.log(text);
|
||||
//console.log(text);
|
||||
let rows = "";
|
||||
|
||||
// As an idea
|
||||
|
||||
// textArray = text.split("\n");
|
||||
// let liste = "";
|
||||
// let firstElement = "<td>";
|
||||
// let lastElement = "</td>";
|
||||
// textArray.forEach(element => {
|
||||
// if (element.includes(firstElement)) {
|
||||
// liste += element.substring(
|
||||
// element.indexOf(firstElement) + firstElement.length,
|
||||
// element.indexOf(lastElement, element.indexOf(firstElement))) +
|
||||
// "\n";
|
||||
// }
|
||||
// });
|
||||
// let outArray2 = liste.split("\n");
|
||||
// outArray2.pop();
|
||||
// console.log(outArray2);
|
||||
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
if (text[i] + text[i + 1] + text[i + 2] + text[i + 3] === "<td>") {
|
||||
let i2 = i + 4;
|
||||
@ -104,7 +134,7 @@ const getFiles = async() => {
|
||||
rows += "\n";
|
||||
}
|
||||
}
|
||||
// console.log(rows); // For debugging only
|
||||
//console.log(rows); // For debugging only
|
||||
|
||||
// All Rows in Table
|
||||
const listeArray = rows.split("\n");
|
||||
@ -124,4 +154,18 @@ const getFiles = async() => {
|
||||
option.text = item;
|
||||
dropDownFiles.add(option);
|
||||
}
|
||||
|
||||
let firstElement = "href=";
|
||||
let lastElement = "class=";
|
||||
let hrefLinksList = "";
|
||||
for (var i = 4; i < listeArray.length; i = i + 5) {
|
||||
hrefLinksList += listeArray[i].substring(
|
||||
listeArray[i].indexOf(firstElement) + firstElement.length + 1,
|
||||
listeArray[i].indexOf(lastElement) - 2) + "\n";
|
||||
}
|
||||
const hrefLinksArray = hrefLinksList.split("\n");
|
||||
hrefLinksArray.pop();
|
||||
|
||||
console.log(hrefLinksArray);
|
||||
return hrefLinksArray;
|
||||
}
|
@ -1828,6 +1828,11 @@
|
||||
"agent-base" "6"
|
||||
"debug" "4"
|
||||
|
||||
"http@^0.0.1-security":
|
||||
"integrity" "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g=="
|
||||
"resolved" "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz"
|
||||
"version" "0.0.1-security"
|
||||
|
||||
"http2-wrapper@^1.0.0-beta.5.2":
|
||||
"integrity" "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg=="
|
||||
"resolved" "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz"
|
||||
|
Loading…
x
Reference in New Issue
Block a user