Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"helloWorld": "Hello World",
"appTitle": "LibGen Book Search",
"search": "Search",
"searching": "Searching...",
"noResults": "No results.",
"publisher": "Publisher",
"language": "Language",
Expand All @@ -32,5 +33,10 @@
"libgenServerSelection": "Libgen server selection",
"libgenPingDescription": "This feature pings the following servers and automatically selects the fastest one:",
"selectFastestServer": "Select fastest server",
"pingStatus": ""
"pingStatus": "",
"downloadLink": "Download link",
"noContentLength": "Warning: No content-length header was received.",
"opening": "Opening",
"downloadComplete": "Download complete!",
"downloading": "Downloading"
}
8 changes: 7 additions & 1 deletion locales/hu/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"helloWorld": "Hello Világ",
"appTitle": "LibGen Könyv Kereső",
"search": "Keresés",
"searching": "Keresés...",
"noResults": "Nincs találat.",
"publisher": "Kiadó",
"language": "Nyelv",
Expand All @@ -32,5 +33,10 @@
"libgenServerSelection": "Libgen szerver kiválasztása",
"libgenPingDescription": "Ez a funkció megpingeli a következő szervereket, és automatikusan kiválasztja a leggyorsabbat:",
"selectFastestServer": "Leggyorsabb szerver kiválasztása",
"pingStatus": ""
"pingStatus": "",
"downloadLink": "Letöltési link",
"noContentLength": "Figyelmeztetés: Nem érkezett content-length fejléc.",
"opening": "Megnyitás",
"downloadComplete": "Letöltés kész!",
"downloading": "Letöltés"
}
15 changes: 8 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ ipcMain.handle('start-download', async (event, md5, extension) => {
const detailUrl = `https://${libgenServer}/ads.php?md5=${md5}`;

try {
event.sender.send('download-status', 'Megnyitás: ' + detailUrl);
event.sender.send('download-status', { key: 'opening', value: detailUrl });

const detailResponse = await axios.get(detailUrl);
const $ = require('cheerio').load(detailResponse.data);
Expand All @@ -193,7 +193,7 @@ ipcMain.handle('start-download', async (event, md5, extension) => {
}

const fullLink = getLink.startsWith('http') ? getLink : `https://${libgenServer}/${getLink}`;
event.sender.send('download-status', 'Letöltési link: ' + fullLink);
event.sender.send('download-status', { key: 'downloadLink', value: fullLink });

const downloadsDir = path.join(downloadDir);
if (!fs.existsSync(downloadsDir)) {
Expand All @@ -210,7 +210,7 @@ ipcMain.handle('start-download', async (event, md5, extension) => {

const totalLength = parseInt(response.headers['content-length'], 10) || 0;
if (!totalLength) {
event.sender.send('download-status', 'Figyelmeztetés: Nem érkezett content-length fejléc.');
event.sender.send('download-status', { key: 'noContentLength' });
}

const writer = fs.createWriteStream(filePath);
Expand All @@ -223,9 +223,10 @@ ipcMain.handle('start-download', async (event, md5, extension) => {
return;
}
const downloadedLength = stats.size;
event.sender.send('download-status',
`Letöltés: ${(downloadedLength / 1024 / 1024).toFixed(2)} MB / ${(totalLength / 1024 / 1024).toFixed(2)} MB`
);
event.sender.send('download-status', {
key: 'downloading',
value: `${(downloadedLength / 1024 / 1024).toFixed(2)} MB / ${(totalLength / 1024 / 1024).toFixed(2)} MB`
});
});
}, 1500); // in millisecond

Expand All @@ -235,7 +236,7 @@ ipcMain.handle('start-download', async (event, md5, extension) => {
});

clearInterval(intervalId);
event.sender.send('download-status', 'Letöltés kész!');
event.sender.send('download-status', { key: 'downloadComplete' });
event.sender.send('download-done', filePath);

return { success: true, filePath };
Expand Down
2 changes: 1 addition & 1 deletion pages/settingsSite.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h2 data-i18n="settings">Beállítások</h2>

<button class="button" id="saveBtn" data-i18n="save">Mentés</button>

<p id="saveStatus" style="margin-top: 10px; display: none;"><span data-i18n="directorySaved">Könyvtár mentve:</span> <span id="savePath"></span></p>
<p id="saveStatus" style="margin-top: 10px;" hidden><span data-i18n="directorySaved">Könyvtár mentve:</span> <span id="savePath"></span></p>

<h3 data-i18n="libgenServerSelection">Libgen szerver kiválasztása</h3>
<p data-i18n="libgenPingDescription">
Expand Down
16 changes: 11 additions & 5 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@ async function showPage(page) {
if (page === 'downloadProgress') {
window.electronAPI.onDownloadStatus((event, status) => {
const statusDiv = document.getElementById('downloadStatus');
if (statusDiv) {
if (!statusDiv) return;
if (typeof status === 'object' && status.key && status.value) {
statusDiv.textContent = i18next.t(status.key) + ": " + status.value;
}
else if (typeof status === 'object' && status.key) {
statusDiv.textContent = i18next.t(status.key);
} else {
statusDiv.textContent = status;
}
});
Expand Down Expand Up @@ -139,7 +145,7 @@ async function showPage(page) {
const newPath = dirInput.value;
const result = await window.electronAPI.setConfig(newPath);
if (result.success) {
status.style.display= 'block';
status.hidden = false;
savePath.textContent = `${result.path}`;
status.style.color = 'green';
currentDirText.textContent = result.path;
Expand Down Expand Up @@ -211,8 +217,8 @@ async function performSearch() {
const table = document.getElementById('resultsTable');
const tbody = table.querySelector('tbody');

status.textContent = 'Keresés...';
table.style.display = 'none';
status.textContent = i18next.t('searching');
table.hidden = true;
tbody.innerHTML = '';

const results = await window.electronAPI.fetchLibgen(query);
Expand All @@ -227,7 +233,7 @@ async function performSearch() {
}

status.textContent = `${results.length} results.`;
table.style.display = 'table';
table.hidden = false;

results.forEach(book => {
const row = document.createElement('tr');
Expand Down