diff --git a/source/net/sourceforge/filebot/Settings.java b/source/net/sourceforge/filebot/Settings.java index c8ad7aef..e716d2c1 100644 --- a/source/net/sourceforge/filebot/Settings.java +++ b/source/net/sourceforge/filebot/Settings.java @@ -36,7 +36,7 @@ public final class Settings { // special handling for web start if (System.getProperty("javawebstart.version") != null) { // can't use working directory for web start applications - File folder = new File(System.getProperty("user.home"), ".filebot"); + File folder = new File(System.getProperty("user.home"), "." + getApplicationName().toLowerCase()); // create folder if necessary if (!folder.exists()) { diff --git a/source/net/sourceforge/filebot/subtitle/SubStationAlphaReader.java b/source/net/sourceforge/filebot/subtitle/SubStationAlphaReader.java index b22c442a..fc0b7fb9 100644 --- a/source/net/sourceforge/filebot/subtitle/SubStationAlphaReader.java +++ b/source/net/sourceforge/filebot/subtitle/SubStationAlphaReader.java @@ -14,7 +14,6 @@ public class SubStationAlphaReader extends SubtitleReader { private final DateFormat timeFormat = new SubtitleTimeFormat(); private final Pattern newline = Pattern.compile(Pattern.quote("\\n"), Pattern.CASE_INSENSITIVE); private final Pattern tag = Pattern.compile("[{]\\\\[^}]+[}]"); - private final Pattern separator = Pattern.compile("\\s*,\\s*"); private String[] format; private int formatIndexStart; @@ -36,12 +35,17 @@ public class SubStationAlphaReader extends SubtitleReader { throw new InputMismatchException("Illegal format header: " + Arrays.toString(event)); // read columns - format = separator.split(event[1]); + format = event[1].split(","); + + // normalize column names + for (int i = 0; i < format.length; i++) { + format[i] = format[i].trim().toLowerCase(); + } List lookup = Arrays.asList(format); - formatIndexStart = lookup.indexOf("Start"); - formatIndexEnd = lookup.indexOf("End"); - formatIndexText = lookup.indexOf("Text"); + formatIndexStart = lookup.indexOf("start"); + formatIndexEnd = lookup.indexOf("end"); + formatIndexText = lookup.indexOf("text"); } @@ -71,11 +75,11 @@ public class SubStationAlphaReader extends SubtitleReader { throw new InputMismatchException("Illegal dialogue event: " + Arrays.toString(event)); // extract information - String[] values = separator.split(event[1], format.length); + String[] values = event[1].split(",", format.length); - long start = timeFormat.parse(values[formatIndexStart]).getTime(); - long end = timeFormat.parse(values[formatIndexEnd]).getTime(); - String text = values[formatIndexText]; + long start = timeFormat.parse(values[formatIndexStart].trim()).getTime(); + long end = timeFormat.parse(values[formatIndexEnd].trim()).getTime(); + String text = values[formatIndexText].trim(); return new SubtitleElement(start, end, resolve(text)); } diff --git a/source/net/sourceforge/filebot/ui/panel/subtitle/RarArchive.java b/source/net/sourceforge/filebot/ui/panel/subtitle/RarArchive.java index bc01e5a6..09dd0ddf 100644 --- a/source/net/sourceforge/filebot/ui/panel/subtitle/RarArchive.java +++ b/source/net/sourceforge/filebot/ui/panel/subtitle/RarArchive.java @@ -63,7 +63,7 @@ class RarArchive implements Iterable { } catch (OutOfMemoryError e) { // ignore, there seems to be bug with JUnRar allocating lots of memory for no apparent reason // @see https://sourceforge.net/forum/forum.php?thread_id=2773018&forum_id=706772 - Logger.getLogger(getClass().getName()).log(Level.WARNING, "Cannot extract " + header.getFileNameString()); + Logger.getLogger(getClass().getName()).log(Level.WARNING, "Failed to extract " + header.getFileNameString(), e); } } } catch (RarException e) { diff --git a/source/net/sourceforge/filebot/web/TheTVDBClient.java b/source/net/sourceforge/filebot/web/TheTVDBClient.java index 6fd39309..9a26398e 100644 --- a/source/net/sourceforge/filebot/web/TheTVDBClient.java +++ b/source/net/sourceforge/filebot/web/TheTVDBClient.java @@ -3,6 +3,7 @@ package net.sourceforge.filebot.web; import static net.sourceforge.filebot.web.EpisodeListUtilities.*; +import static net.sourceforge.filebot.web.WebRequest.*; import static net.sourceforge.tuned.XPathUtilities.*; import java.io.FileNotFoundException; @@ -78,8 +79,8 @@ public class TheTVDBClient implements EpisodeListProvider { public List search(String query, Locale language) throws Exception { - - Document dom = getXmlDocument("/api/GetSeries.php?seriesname=" + URLEncoder.encode(query, "UTF-8") + "&language=" + language.getLanguage()); + URL url = getResource(null, "/api/GetSeries.php?seriesname=" + URLEncoder.encode(query, "UTF-8") + "&language=" + language.getLanguage()); + Document dom = getDocument(url); List nodes = selectNodes("Data/Series", dom); List searchResults = new ArrayList(nodes.size()); @@ -115,7 +116,6 @@ public class TheTVDBClient implements EpisodeListProvider { public List getEpisodeList(TheTVDBSearchResult searchResult, Locale language) throws Exception { - List episodes = cache.getEpisodeList(searchResult.getSeriesId(), language); if (episodes != null) @@ -156,8 +156,7 @@ public class TheTVDBClient implements EpisodeListProvider { public Document getSeriesRecord(TheTVDBSearchResult searchResult, Locale language) throws Exception { - - URL seriesRecord = new URL(getMirror(MirrorType.ZIP) + "/api/" + apikey + "/series/" + searchResult.getSeriesId() + "/all/" + language.getLanguage() + ".zip"); + URL seriesRecord = getResource(MirrorType.ZIP, "/api/" + apikey + "/series/" + searchResult.getSeriesId() + "/all/" + language.getLanguage() + ".zip"); ZipInputStream zipInputStream = new ZipInputStream(seriesRecord.openStream()); ZipEntry zipEntry; @@ -196,10 +195,10 @@ public class TheTVDBClient implements EpisodeListProvider { if (seasonId == null) { // get episode xml from first episode of given season - Document dom = getXmlDocument("/api/" + apikey + "/series/" + seriesId + "/default/" + season + "/1/en.xml"); + URL url = getResource(MirrorType.XML, "/api/" + apikey + "/series/" + seriesId + "/default/" + season + "/1/en.xml"); + Document dom = getDocument(url); seasonId = Integer.valueOf(selectString("Data/Episode/seasonid", dom)); - cache.putSeasonId(seriesId, season, seasonId); } @@ -217,7 +216,7 @@ public class TheTVDBClient implements EpisodeListProvider { synchronized (mirrors) { if (mirrors.isEmpty()) { // initialize mirrors - Document dom = getXmlDocument("/api/" + apikey + "/mirrors.xml"); + Document dom = getDocument(getResource(null, "/api/" + apikey + "/mirrors.xml")); // all mirrors by type Map> mirrorListMap = new EnumMap>(MirrorType.class); @@ -256,9 +255,13 @@ public class TheTVDBClient implements EpisodeListProvider { } - protected Document getXmlDocument(String path) throws Exception { - URL url = new URL("http", host, path); - return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(url.openStream()); + protected URL getResource(MirrorType mirrorType, String path) throws Exception { + // use default server + if (mirrorType == null) + return new URL("http", host, path); + + // use mirror + return new URL(getMirror(mirrorType) + path); }