Added more things that need to be translated

This commit is contained in:
cyian-1756 2018-08-13 19:12:29 -04:00
parent b7f8b0edf6
commit 7ac99282f4
15 changed files with 273 additions and 23 deletions

View File

@ -14,9 +14,11 @@ import java.net.URLConnection;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;
import javax.net.ssl.HttpsURLConnection;
import com.rarchives.ripme.ui.MainWindow;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.jsoup.HttpStatusException;
@ -30,6 +32,8 @@ import com.rarchives.ripme.utils.Utils;
*/
class DownloadFileThread extends Thread {
private ResourceBundle rb = MainWindow.rb;
private static final Logger logger = Logger.getLogger(DownloadFileThread.class);
private String referrer = "";
@ -77,16 +81,16 @@ class DownloadFileThread extends Thread {
try {
observer.stopCheck();
} catch (IOException e) {
observer.downloadErrored(url, "Download interrupted");
observer.downloadErrored(url, rb.getString("download.interrupted"));
return;
}
if (saveAs.exists() && !observer.tryResumeDownload() && !getFileExtFromMIME ||
Utils.fuzzyExists(new File(saveAs.getParent()), saveAs.getName()) && getFileExtFromMIME && !observer.tryResumeDownload()) {
if (Utils.getConfigBoolean("file.overwrite", false)) {
logger.info("[!] Deleting existing file" + prettySaveAs);
logger.info("[!] " + rb.getString("deleting.existing.file") + prettySaveAs);
saveAs.delete();
} else {
logger.info("[!] Skipping " + url + " -- file already exists: " + prettySaveAs);
logger.info("[!] " + rb.getString("skipping") + url + " -- " + rb.getString("file.already.exists") + ": " + prettySaveAs);
observer.downloadExists(url, saveAs);
return;
}
@ -132,14 +136,14 @@ class DownloadFileThread extends Thread {
huc.setRequestProperty("Range", "bytes=" + fileSize + "-");
}
}
logger.debug("Request properties: " + huc.getRequestProperties());
logger.debug(rb.getString("request.properties") + ": " + huc.getRequestProperties());
huc.connect();
int statusCode = huc.getResponseCode();
logger.debug("Status code: " + statusCode);
if (statusCode != 206 && observer.tryResumeDownload() && saveAs.exists()) {
// TODO find a better way to handle servers that don't support resuming downloads then just erroring out
throw new IOException("Server doesn't support resuming downloads");
throw new IOException(rb.getString("server.doesnt.support.resuming.downloads"));
}
if (statusCode / 100 == 3) { // 3xx Redirect
if (!redirected) {
@ -153,14 +157,14 @@ class DownloadFileThread extends Thread {
throw new IOException("Redirect status code " + statusCode + " - redirect to " + location);
}
if (statusCode / 100 == 4) { // 4xx errors
logger.error("[!] Non-retriable status code " + statusCode + " while downloading from " + url);
observer.downloadErrored(url, "Non-retriable status code " + statusCode + " while downloading " + url.toExternalForm());
logger.error("[!] " + rb.getString("nonretriable.status.code") + " " + statusCode + " while downloading from " + url);
observer.downloadErrored(url, rb.getString("nonretriable.status.code") + " " + statusCode + " while downloading " + url.toExternalForm());
return; // Not retriable, drop out.
}
if (statusCode / 100 == 5) { // 5xx errors
observer.downloadErrored(url, "Retriable status code " + statusCode + " while downloading " + url.toExternalForm());
observer.downloadErrored(url, rb.getString("retriable.status.code") + " " + statusCode + " while downloading " + url.toExternalForm());
// Throw exception so download can be retried
throw new IOException("Retriable status code " + statusCode);
throw new IOException(rb.getString("retriable.status.code") + " " + statusCode);
}
if (huc.getContentLength() == 503 && urlToDownload.getHost().endsWith("imgur.com")) {
// Imgur image with 503 bytes is "404"
@ -196,8 +200,8 @@ class DownloadFileThread extends Thread {
if (fileExt != null) {
saveAs = new File(saveAs.toString() + "." + fileExt);
} else {
logger.error("Was unable to get content type using magic number");
logger.error("Magic number was: " + Arrays.toString(magicBytes));
logger.error(rb.getString("was.unable.to.get.content.type.using.magic.number"));
logger.error(rb.getString("magic.number.was") + ": " + Arrays.toString(magicBytes));
}
}
}
@ -213,7 +217,7 @@ class DownloadFileThread extends Thread {
try {
observer.stopCheck();
} catch (IOException e) {
observer.downloadErrored(url, "Download interrupted");
observer.downloadErrored(url, rb.getString("download.interrupted"));
return;
}
fos.write(data, 0, bytesRead);
@ -232,7 +236,7 @@ class DownloadFileThread extends Thread {
// Download failed, break out of loop
break;
} catch (HttpStatusException hse) {
logger.debug("HTTP status exception", hse);
logger.debug(rb.getString("http.status.exception"), hse);
logger.error("[!] HTTP status " + hse.getStatusCode() + " while downloading from " + urlToDownload);
if (hse.getStatusCode() == 404 && Utils.getConfigBoolean("errors.skip404", false)) {
observer.downloadErrored(url, "HTTP status code " + hse.getStatusCode() + " while downloading " + url.toExternalForm());
@ -240,7 +244,7 @@ class DownloadFileThread extends Thread {
}
} catch (IOException e) {
logger.debug("IOException", e);
logger.error("[!] Exception while downloading file: " + url + " - " + e.getMessage());
logger.error("[!] " + rb.getString("exception.while.downloading.file") + ": " + url + " - " + e.getMessage());
} finally {
// Close any open streams
try {
@ -251,8 +255,8 @@ class DownloadFileThread extends Thread {
} catch (IOException e) { }
}
if (tries > this.retries) {
logger.error("[!] Exceeded maximum retries (" + this.retries + ") for URL " + url);
observer.downloadErrored(url, "Failed to download " + url.toExternalForm());
logger.error("[!] " + rb.getString ("exceeded.maximum.retries") + " (" + this.retries + ") for URL " + url);
observer.downloadErrored(url, rb.getString("failed.to.download") + " " + url.toExternalForm());
return;
}
} while (true);

View File

@ -141,7 +141,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
private static AbstractRipper ripper;
private ResourceBundle rb = Utils.getResourceBundle(null);
public static ResourceBundle rb = Utils.getResourceBundle(null);
// All the langs ripme has been translated into
private static String[] supportedLanges = new String[] {"en_US", "de_DE", "es_ES", "fr_CH", "kr_KR", "pt_BR", "pt_PT",
@ -513,7 +513,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
} catch (Exception e) { }
configSaveDirLabel.setToolTipText(configSaveDirLabel.getText());
configSaveDirLabel.setHorizontalAlignment(JLabel.RIGHT);
configSaveDirButton = new JButton("Select Save Directory...");
configSaveDirButton = new JButton(rb.getString("select.save.dir") + "...");
addItemToConfigGridBagConstraints(gbc, 0, configUpdateLabel, configUpdateButton);
addItemToConfigGridBagConstraints(gbc, 1, configAutoupdateCheckbox, configLogLevelCombobox);

View File

@ -34,4 +34,23 @@ interrupted.while.waiting.to.rip.next.album = Interrupted while waiting to rip n
inactive = Inactive
re-rip.checked = Re-rip Checked
remove = Remove
clear = Clear
clear = Clear
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists

View File

@ -35,4 +35,22 @@ inactive = Inaktiv
re-rip.checked = Re-rip Überprüft
remove = Entfernen
clear = Leeren
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists

View File

@ -34,4 +34,23 @@ interrupted.while.waiting.to.rip.next.album = Interrupted while waiting to rip n
inactive = Inactive
re-rip.checked = Re-rip Checked
remove = Remove
clear = Clear
clear = Clear
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists

View File

@ -34,4 +34,23 @@ interrupted.while.waiting.to.rip.next.album = Interrumpido esperando el Rip del
inactive = Inactivo
re-rip.checked = Re-rip marcado
remove = Quitar
clear = Limpiar
clear = Limpiar
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists

View File

@ -35,3 +35,22 @@ inactive = Toimeton
re-rip.checked = Uudelleenlataa merkatut
remove = Poista
clear = Tyhjennä
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists

View File

@ -34,4 +34,23 @@ interrupted.while.waiting.to.rip.next.album = Interrompu lors de l'attente pour
inactive = Inactif
re-rip.checked = Re-rip vérifié
remove = Enlever
clear = Effacer
clear = Effacer
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists

View File

@ -35,3 +35,22 @@ inactive = Tidak aktif
re-rip.checked = Rip Ulang
remove = Hapus
clear = Hapus Semua
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists

View File

@ -35,3 +35,22 @@ inactive = Inattivo
re-rip.checked = Re-rip selezionato
remove = Rimuovi
clear = Pulisci
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists

View File

@ -35,3 +35,22 @@ inactive = \uBE44\uD65C\uC131\uD654
re-rip.checked = \uB2E4\uC2DC \uBCF5\uC0AC\uD558\uAE30 \uCCB4\uD06C\uB428
remove = \uC120\uD0DD\uD55C \uAE30\uB85D \uC0AD\uC81C
clear = \uD788\uC2A4\uD1A0\uB9AC \uBAA8\uB450 \uC0AD\uC81C
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists

View File

@ -35,3 +35,22 @@ inactive = Inactief
re-rip.checked = Re-rip Gecheckt
remove = Verwijderen
clear = Opruimen
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists

View File

@ -35,3 +35,22 @@ inactive = Inativo
re-rip.checked = Re-ripar selecionados
remove = Remover
clear = Limpar
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists

View File

@ -35,3 +35,22 @@ inactive = Inativo
re-rip.checked = Re-rip verificado
remove = Remover
clear = Limpar
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists

View File

@ -34,4 +34,23 @@ interrupted.while.waiting.to.rip.next.album = Прервано во время
inactive = Неактивно
re-rip.checked = Перекачать выбранное
remove = Удалить
clear = Очистить
clear = Очистить
select.save.dir = Select Save Directory
# Keys for the logs generated by DownloadFileThread
nonretriable.status.code = Non-retriable status code
retriable.status.code = Retriable status code
server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads
# A "magic number" can also be called a file signature
was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number
magic.number.was = Magic number was
deleting.existing.file = Deleting existing file
request.properties = Request properties
download.interrupted = Download interrupted
exceeded.maximum.retries = Exceeded maximum retries
http.status.exception = HTTP status exception
exception.while.downloading.file = Exception while downloading file
failed.to.download = Failed to download
skipping = Skipping
file.already.exists = file already exists