From cc300769b4005fe5508fdbf1599e0876dcbcd756 Mon Sep 17 00:00:00 2001 From: PaulaBras <68814660+PaulaBras@users.noreply.github.com> Date: Sun, 6 Nov 2022 21:19:00 +0100 Subject: [PATCH] etwas besser geschrieben + href added --- updater/package-lock.json | 11 ++++++ updater/package.json | 1 + updater/src/index.html | 4 +-- updater/src/index.js | 22 ++++++++++-- updater/src/renderer.js | 72 +++++++++++++++++++++++++++++++-------- updater/yarn.lock | 5 +++ 6 files changed, 97 insertions(+), 18 deletions(-) diff --git a/updater/package-lock.json b/updater/package-lock.json index 42ffc01..7ef5a44 100644 --- a/updater/package-lock.json +++ b/updater/package-lock.json @@ -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", diff --git a/updater/package.json b/updater/package.json index 2944419..bafc040 100644 --- a/updater/package.json +++ b/updater/package.json @@ -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" }, diff --git a/updater/src/index.html b/updater/src/index.html index a4e65c6..adeebaa 100644 --- a/updater/src/index.html +++ b/updater/src/index.html @@ -12,9 +12,9 @@
Output Test here
Input URL
- +Input Directory
- + diff --git a/updater/src/index.js b/updater/src/index.js index b7b67ec..47a40b5 100644 --- a/updater/src/index.js +++ b/updater/src/index.js @@ -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())); }); diff --git a/updater/src/renderer.js b/updater/src/renderer.js index 3fe8862..acc586a 100644 --- a/updater/src/renderer.js +++ b/updater/src/renderer.js @@ -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 = ""; + let lastElement = ""; + 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