Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

auto conversion to UTF8 when time shifting subs + code simplification…

… + tests
  • Loading branch information...
commit 36f6e9ddf79538f0d14765163503aab1bdc56615 1 parent 62c6d3b
@Happy-Neko Happy-Neko authored
View
44 src/main/java/net/pms/encoders/FFMpegVideo.java
@@ -28,6 +28,7 @@
import net.pms.configuration.PmsConfiguration;
import net.pms.configuration.RendererConfiguration;
import net.pms.dlna.DLNAMediaInfo;
+import net.pms.dlna.DLNAMediaSubtitle;
import net.pms.dlna.DLNAResource;
import net.pms.dlna.InputFile;
import net.pms.formats.Format;
@@ -118,7 +119,7 @@ public FFMpegVideo(PmsConfiguration configuration) {
* @return a {@link List} of <code>String</code>s representing the rescale options for this video,
* or an empty list if the video doesn't need to be resized.
*/
- public List<String> getVideoFilterOptions(File tempSubs, RendererConfiguration renderer, DLNAMediaInfo media) throws IOException {
+ public List<String> getVideoFilterOptions(DLNAMediaSubtitle tempSubs, RendererConfiguration renderer, DLNAMediaInfo media) throws IOException {
List<String> videoFilterOptions = new ArrayList<String>();
String subsOption = null;
String padding = null;
@@ -130,7 +131,7 @@ public FFMpegVideo(PmsConfiguration configuration) {
if (tempSubs != null) {
StringBuilder s = new StringBuilder();
- CharacterIterator it = new StringCharacterIterator(tempSubs.getAbsolutePath());
+ CharacterIterator it = new StringCharacterIterator(tempSubs.getExternalFile().getAbsolutePath());
for (char ch = it.first(); ch != CharacterIterator.DONE; ch = it.next()) {
switch (ch) {
@@ -574,11 +575,11 @@ public ProcessWrapper launchTranscode(
List<String> cmdList = new ArrayList<String>();
RendererConfiguration renderer = params.mediaRenderer;
setAudioAndSubs(filename, media, params, configuration);
- File tempSubs = null;
+ DLNAMediaSubtitle tempSubs = null;
// params.waitbeforestart = 1000;
if (!isDisableSubtitles(params)) {
- tempSubs = getSubtitleFile(filename, media, params);
+ tempSubs = getSubtitles(filename, media, params);
}
cmdList.add(executable());
@@ -1084,17 +1085,15 @@ public boolean isCompatible(DLNAResource resource) {
}
/**
- * @deprecated use {@link #getSubtitleFile(String, net.pms.dlna.DLNAMediaInfo, net.pms.io.OutputParams)} instead.
+ * @deprecated use {@link #getSubtitles(String, net.pms.dlna.DLNAMediaInfo, net.pms.io.OutputParams)} instead.
*/
@Deprecated
- public File subsConversion(String fileName, DLNAMediaInfo media, OutputParams params) throws IOException {
- return getSubtitleFile(fileName, media, params);
+ public DLNAMediaSubtitle subsConversion(String fileName, DLNAMediaInfo media, OutputParams params) throws IOException {
+ return getSubtitles(fileName, media, params);
}
/**
- * Extracts embedded subtitles from video to file in SSA/ASS format, converts external SRT
- * subtitles file to SSA/ASS format and applies fontconfig setting to that converted file
- * and applies timeseeking when required.
+ * Shift timing of external subtitles in SSA/ASS or SRT format and converts charset to UTF8 if necessary
*
* @param fileName Video file
* @param media Media file metadata
@@ -1102,8 +1101,8 @@ public File subsConversion(String fileName, DLNAMediaInfo media, OutputParams pa
* @return Converted subtitle file
* @throws IOException
*/
- public File getSubtitleFile(String fileName, DLNAMediaInfo media, OutputParams params) throws IOException {
- File tempSubs = null;
+ public DLNAMediaSubtitle getSubtitles(String fileName, DLNAMediaInfo media, OutputParams params) throws IOException {
+ DLNAMediaSubtitle tempSubs = null;
if (params.sid.getId() == -1) {
return null;
@@ -1114,26 +1113,9 @@ public File getSubtitleFile(String fileName, DLNAMediaInfo media, OutputParams p
subtitlesDirectory.mkdirs();
}
- if (params.sid.isEmbedded()) {
- /* TODO disable embedded subtitles extraction because of a) broken track ids b) unacceptable duration of remux
- process for large files and/or slow (network) drives
- TODO extract track with real file extension (ass or srt)
- final String convertedSubsPath = subtitlesDirectory.getAbsolutePath() + File.separator + getBaseName(new File(fileName).getName()).replaceAll("\\W", "_") + "_" + new File(fileName).length() + "_EMB_ID" + params.sid.getId() + ".ass";
- final File tmp = new File(convertedSubsPath);
-
- if (tmp.canRead()) {
- tempSubs = tmp;
- } else {
- tempSubs = extractEmbeddedSubtitlesTrack(fileName, media, params);
- }
- */
- } else if (params.sid.isExternal()) {
- tempSubs = params.sid.getExternalFile();
- }
-
- if (tempSubs != null && params.timeseek > 0 && params.sid.getType() != null) {
+ if (params.sid.isExternal() && SubtitleUtils.isSupportsTimeShifting(params.sid.getType())) {
try {
- tempSubs = SubtitleUtils.shiftSubtitlesTiming(tempSubs, params.timeseek, params.sid.getType());
+ tempSubs = SubtitleUtils.shiftSubtitlesTimingWithUtfConversion(params.sid, params.timeseek);
} catch (IOException e) {
LOGGER.debug("Applying times shift caused an error: " + e);
tempSubs = null;
View
5 src/main/java/net/pms/encoders/FFMpegWebVideo.java
@@ -21,6 +21,7 @@
import net.pms.configuration.PmsConfiguration;
import net.pms.configuration.RendererConfiguration;
import net.pms.dlna.DLNAMediaInfo;
+import net.pms.dlna.DLNAMediaSubtitle;
import net.pms.dlna.DLNAResource;
import net.pms.formats.Format;
import net.pms.formats.FormatFactory;
@@ -125,10 +126,10 @@ public ProcessWrapper launchTranscode(
params.minBufferSize = params.minFileSize;
params.secondread_minsize = 100000;
RendererConfiguration renderer = params.mediaRenderer;
- File tempSubs = null;
+ DLNAMediaSubtitle tempSubs = null;
if (!isDisableSubtitles(params)) {
- tempSubs = getSubtitleFile(filename, media, params);
+ tempSubs = getSubtitles(filename, media, params);
}
// XXX work around an ffmpeg bug: http://ffmpeg.org/trac/ffmpeg/ticket/998
View
101 src/main/java/net/pms/formats/v2/SubtitleUtils.java
@@ -26,7 +26,13 @@
import org.slf4j.LoggerFactory;
import java.io.*;
-import java.util.*;
+import java.nio.charset.Charset;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
import static org.apache.commons.io.FilenameUtils.getBaseName;
import static org.apache.commons.lang3.StringUtils.*;
@@ -34,7 +40,7 @@
public class SubtitleUtils {
private final static Logger LOGGER = LoggerFactory.getLogger(SubtitleUtils.class);
- private final static PmsConfiguration configuration = PMS.getConfiguration();
+ private static PmsConfiguration configuration = PMS.getConfiguration();
private final static Map<String, String> fileCharsetToMencoderSubcpOptionMap = new HashMap<String, String>() {
{
// Cyrillic / Russian
@@ -67,6 +73,19 @@
put(CHARSET_SHIFT_JIS, "shift-jis");
}
};
+ private static final EnumSet<SubtitleType> SUPPORTS_TIME_SHIFTING = EnumSet.of(SubtitleType.SUBRIP, SubtitleType.ASS);
+ private static final DecimalFormat ASS_DECIMAL_FORMAT = new DecimalFormat("00.00");
+ private static final DecimalFormat SRT_DECIMAL_FORMAT = new DecimalFormat("00.000");
+
+ static {
+ final DecimalFormatSymbols dotDecimalSeparator = new DecimalFormatSymbols();
+ dotDecimalSeparator.setDecimalSeparator('.');
+ ASS_DECIMAL_FORMAT.setDecimalFormatSymbols(dotDecimalSeparator);
+
+ final DecimalFormatSymbols commaDecimalSeparator = new DecimalFormatSymbols();
+ commaDecimalSeparator.setDecimalSeparator(',');
+ SRT_DECIMAL_FORMAT.setDecimalFormatSymbols(commaDecimalSeparator);
+ }
/**
* Returns value for -subcp option for non UTF-8 external subtitles based on
@@ -85,40 +104,54 @@ public static String getSubCpOptionForMencoder(DLNAMediaSubtitle dlnaMediaSubtit
}
/**
- * Shift timing of subtitles in SSA/ASS or SRT format
+ * Shift timing of subtitles in SSA/ASS or SRT format and converts charset to UTF8 if necessary
+ *
*
* @param inputSubtitles Subtitles file in SSA/ASS or SRT format
* @param timeShift Time stamp value
* @return Converted subtitles file
* @throws IOException
*/
- public static File shiftSubtitlesTiming(final File inputSubtitles, double timeShift, SubtitleType subtitleType) throws IOException {
+ public static DLNAMediaSubtitle shiftSubtitlesTimingWithUtfConversion(final DLNAMediaSubtitle inputSubtitles, double timeShift) throws IOException {
if (inputSubtitles == null) {
throw new NullPointerException("inputSubtitles should not be null.");
}
- if (isBlank(inputSubtitles.getName())) {
- throw new IllegalArgumentException("inputSubtitles should not have blank name.");
+ if (!inputSubtitles.isExternal()) {
+ throw new IllegalArgumentException("inputSubtitles should be external.");
}
- if (subtitleType == null) {
- throw new NullPointerException("subtitleType should not be null.");
+ if (isBlank(inputSubtitles.getExternalFile().getName())) {
+ throw new IllegalArgumentException("inputSubtitles' external file should not have blank name.");
}
- if (!EnumSet.of(SubtitleType.SUBRIP, SubtitleType.ASS).contains(subtitleType)) {
- throw new IllegalArgumentException("subtitleType " + subtitleType + " is not supported.");
+ if (inputSubtitles.getType() == null) {
+ throw new NullPointerException("inputSubtitles.getType() should not be null.");
}
- if (!(timeShift > 0)) {
- return inputSubtitles; // time shifting is not needed
+ if (!isSupportsTimeShifting(inputSubtitles.getType())) {
+ throw new IllegalArgumentException("inputSubtitles.getType() " + inputSubtitles.getType() + " is not supported.");
}
- final File convertedSubtitles = new File(configuration.getTempFolder(), getBaseName(inputSubtitles.getName()) + System.currentTimeMillis() + ".tmp");
- FileUtils.forceDeleteOnExit(convertedSubtitles);
- final BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream(inputSubtitles)));
- final BufferedWriter output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(convertedSubtitles)));
+ final File convertedSubtitlesFile = new File(configuration.getTempFolder(), getBaseName(inputSubtitles.getExternalFile().getName()) + System.currentTimeMillis() + ".tmp");
+ FileUtils.forceDeleteOnExit(convertedSubtitlesFile);
+ BufferedReader input;
+
+ final boolean isSubtitlesCodepageForcedInConfigurationAndSupportedByJVM = isNotBlank(configuration.getSubtitlesCodepage()) && Charset.isSupported(configuration.getSubtitlesCodepage());
+ final boolean isSubtitlesCodepageAutoDetectedAndSupportedByJVM = isNotBlank(inputSubtitles.getExternalFileCharacterSet()) && Charset.isSupported(inputSubtitles.getExternalFileCharacterSet());
+ if (!inputSubtitles.isExternalFileUtf()
+ && (isSubtitlesCodepageForcedInConfigurationAndSupportedByJVM || isSubtitlesCodepageAutoDetectedAndSupportedByJVM)) {
+ if (isSubtitlesCodepageForcedInConfigurationAndSupportedByJVM) {
+ input = new BufferedReader(new InputStreamReader(new FileInputStream(inputSubtitles.getExternalFile()), Charset.forName(configuration.getSubtitlesCodepage())));
+ } else {
+ input = new BufferedReader(new InputStreamReader(new FileInputStream(inputSubtitles.getExternalFile()), Charset.forName(inputSubtitles.getExternalFileCharacterSet())));
+ }
+ } else {
+ input = new BufferedReader(new InputStreamReader(new FileInputStream(inputSubtitles.getExternalFile())));
+ }
+ final BufferedWriter output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(convertedSubtitlesFile), Charset.forName("UTF-8")));
String line;
double startTime;
double endTime;
try {
- if (SubtitleType.ASS.equals(subtitleType)) {
+ if (SubtitleType.ASS.equals(inputSubtitles.getType())) {
while ((line = input.readLine()) != null) {
if (startsWith(line, "Dialogue:")) {
String[] timings = splitPreserveAllTokens(line, ",");
@@ -139,7 +172,7 @@ public static File shiftSubtitlesTiming(final File inputSubtitles, double timeSh
output.write(line + "\n");
}
}
- } else if (SubtitleType.SUBRIP.equals(subtitleType)) {
+ } else if (SubtitleType.SUBRIP.equals(inputSubtitles.getType())) {
int n = 1;
while ((line = input.readLine()) != null) {
if (contains(line, ("-->"))) {
@@ -169,9 +202,24 @@ public static File shiftSubtitlesTiming(final File inputSubtitles, double timeSh
}
}
+ final DLNAMediaSubtitle convertedSubtitles = new DLNAMediaSubtitle();
+ convertedSubtitles.setExternalFile(convertedSubtitlesFile);
+ convertedSubtitles.setType(inputSubtitles.getType());
+ convertedSubtitles.setLang(inputSubtitles.getLang());
+ convertedSubtitles.setFlavor(inputSubtitles.getFlavor());
+ convertedSubtitles.setId(inputSubtitles.getId());
return convertedSubtitles;
}
+ /**
+ * Check if subtitleType supports time shifting
+ * @param subtitleType to check
+ * @return true if subtitleType can be time shifted with {@link #shiftSubtitlesTimingWithUtfConversion(net.pms.dlna.DLNAMediaSubtitle, double)}
+ */
+ public static boolean isSupportsTimeShifting(SubtitleType subtitleType) {
+ return SUPPORTS_TIME_SHIFTING.contains(subtitleType);
+ }
+
enum TimingFormat {
ASS_TIMING,
SRT_TIMING,
@@ -195,13 +243,13 @@ static String convertTimeToSubtitleTimingString(final double time, final TimingF
int m = Math.abs(((int) (time / 60)) % 60);
switch (timingFormat) {
case ASS_TIMING:
- return trim(String.format(Locale.ENGLISH, "% 02d:%02d:%02.2f", h, m, s));
+ return trim(String.format("% 02d:%02d:%s", h, m, ASS_DECIMAL_FORMAT.format(s)));
case SRT_TIMING:
- return trim(String.format(Locale.ENGLISH, "% 03d:%02d:%02.3f", h, m, s));
+ return trim(String.format("% 03d:%02d:%s", h, m, SRT_DECIMAL_FORMAT.format(s)));
case SECONDS_TIMING:
- return trim(String.format(Locale.ENGLISH, "% 03d:%02d:%02.0f", h, m, s));
+ return trim(String.format("% 03d:%02d:%02.0f", h, m, s));
default:
- return trim(String.format(Locale.ENGLISH, "% 03d:%02d:%02.0f", h, m, s));
+ return trim(String.format("% 03d:%02d:%02.0f", h, m, s));
}
}
@@ -231,4 +279,13 @@ static Double convertSubtitleTimingStringToTime(final String timingString) throw
throw nfe;
}
}
+
+ /**
+ * For testing purposes.
+ *
+ * @param configuration
+ */
+ static void setConfiguration(PmsConfiguration configuration) {
+ SubtitleUtils.configuration = configuration;
+ }
}
View
78 src/test/java/net/pms/formats/v2/SubtitleUtilsTest.java
@@ -1,6 +1,6 @@
/*
* PS3 Media Server, for streaming any medias to your PS3.
- * Copyright (C) 2012 I. Sokolov
+ * Copyright (C) 2012-2013 I. Sokolov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -19,14 +19,18 @@
package net.pms.formats.v2;
import ch.qos.logback.classic.LoggerContext;
+import net.pms.configuration.PmsConfiguration;
import net.pms.dlna.DLNAMediaSubtitle;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
import org.slf4j.LoggerFactory;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import static net.pms.formats.v2.SubtitleType.VOBSUB;
@@ -36,15 +40,24 @@
public class SubtitleUtilsTest {
private final Class<?> CLASS = SubtitleUtilsTest.class;
+ @Rule
+ public final TemporaryFolder temporaryFolder = new TemporaryFolder();
/**
* Set up testing conditions before running the tests.
*/
@Before
- public final void setUp() {
+ public final void setUp() throws IOException, ConfigurationException {
// Silence all log messages from the PMS code that is being tested
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
context.reset();
+
+ SubtitleUtils.setConfiguration(new PmsConfiguration() {
+ @Override
+ public File getTempFolder() throws IOException {
+ return temporaryFolder.newFolder("subutils");
+ }
+ });
}
@Test(expected = NullPointerException.class)
@@ -135,15 +148,15 @@ public void testGetSubCpOptionForMencoder_UTF() throws Exception {
}
@Test
- public void testConvertTimeToSubtitleTimingString_withAssFormat() {
+ public void testConvertTimeToSubtitleTimingString() {
assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(5057.056, ASS_TIMING)).isEqualTo("1:24:17.06");
assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(-5057.056, ASS_TIMING)).isEqualTo("-1:24:17.06");
assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(5057.1, ASS_TIMING)).isEqualTo("1:24:17.10");
assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(46814, ASS_TIMING)).isEqualTo("13:00:14.00");
assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(-46814, ASS_TIMING)).isEqualTo("-13:00:14.00");
- assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(5057.056, SRT_TIMING)).isEqualTo("01:24:17.056");
- assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(-5057.056, SRT_TIMING)).isEqualTo("-01:24:17.056");
- assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(5057.1, SRT_TIMING)).isEqualTo("01:24:17.100");
+ assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(5057.056, SRT_TIMING)).isEqualTo("01:24:17,056");
+ assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(-5057.056, SRT_TIMING)).isEqualTo("-01:24:17,056");
+ assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(5057.1, SRT_TIMING)).isEqualTo("01:24:17,100");
assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(5057.056, SECONDS_TIMING)).isEqualTo("01:24:17");
assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(-5057.056, SECONDS_TIMING)).isEqualTo("-01:24:17");
assertThat(SubtitleUtils.convertTimeToSubtitleTimingString(5057.956, SECONDS_TIMING)).isEqualTo("01:24:18");
@@ -176,27 +189,62 @@ public void testConvertSubtitleTimingStringToTime_withEmptyTimingString() {
}
@Test(expected = NullPointerException.class)
- public void testShiftSubtitlesTiming_withNullInputSubtitles() throws IOException {
- SubtitleUtils.shiftSubtitlesTiming(null, 12, SubtitleType.ASS);
+ public void testShiftSubtitlesTimingWithUtfConversion_withNullInputSubtitles() throws IOException {
+ SubtitleUtils.shiftSubtitlesTimingWithUtfConversion(null, 12);
}
@Test(expected = IllegalArgumentException.class)
- public void testShiftSubtitlesTiming_withBlankInputSubtitlesName() throws IOException {
- SubtitleUtils.shiftSubtitlesTiming(new File("no-name-file.test") {
+ public void testShiftSubtitlesTimingWithUtfConversion_withInputSubtitles_withoutExternalFile() throws IOException {
+ SubtitleUtils.shiftSubtitlesTimingWithUtfConversion(new DLNAMediaSubtitle(), 12);
+ }
+
+ @Test(expected = FileNotFoundException.class)
+ public void testShiftSubtitlesTimingWithUtfConversion_withInputSubtitles_withBlankExternalFileName() throws IOException {
+ final DLNAMediaSubtitle inputSubtitles = new DLNAMediaSubtitle();
+ inputSubtitles.setExternalFile(new File("no-name-file.test") {
@Override
public String getName() {
return "";
}
- }, 12, SubtitleType.ASS);
+ });
+ SubtitleUtils.shiftSubtitlesTimingWithUtfConversion(inputSubtitles, 12);
}
@Test(expected = NullPointerException.class)
- public void testShiftSubtitlesTiming_withNullSubtitleType() throws IOException {
- SubtitleUtils.shiftSubtitlesTiming(new File("good-file.test"), 12, null);
+ public void testShiftSubtitlesTimingWithUtfConversion_withNullSubtitleType() throws IOException {
+ final DLNAMediaSubtitle inputSubtitles = new DLNAMediaSubtitle();
+ inputSubtitles.setExternalFile(FileUtils.toFile(CLASS.getResource("../../util/russian-utf8-without-bom.srt")));
+ SubtitleUtils.shiftSubtitlesTimingWithUtfConversion(inputSubtitles, 12);
}
@Test(expected = IllegalArgumentException.class)
- public void testShiftSubtitlesTiming_withInvalidSubtitleType() throws IOException, ConfigurationException {
- SubtitleUtils.shiftSubtitlesTiming(new File("good-file.test"), 12, SubtitleType.VOBSUB);
+ public void testShiftSubtitlesTimingWithUtfConversion_withInvalidSubtitleType() throws IOException {
+ final DLNAMediaSubtitle inputSubtitles = new DLNAMediaSubtitle();
+ inputSubtitles.setExternalFile(FileUtils.toFile(CLASS.getResource("../../util/russian-utf8-without-bom.srt")));
+ SubtitleUtils.shiftSubtitlesTimingWithUtfConversion(inputSubtitles, 12);
+ }
+
+ @Test
+ public void testShiftSubtitlesTimingWithUtfConversion_charsetConversion_withoutTimeShift() throws IOException {
+ final DLNAMediaSubtitle inputSubtitles = new DLNAMediaSubtitle();
+ inputSubtitles.setExternalFile(FileUtils.toFile(CLASS.getResource("../../util/russian-cp1251.srt")));
+ final DLNAMediaSubtitle convertedSubtitles = SubtitleUtils.shiftSubtitlesTimingWithUtfConversion(inputSubtitles, 0);
+ assertThat(convertedSubtitles.isExternalFileUtf8()).isTrue();
+ }
+
+ @Test
+ public void testShiftSubtitlesTimingWithUtfConversion_doNotConvertUtf8_withoutTimeShift() throws IOException {
+ final DLNAMediaSubtitle inputSubtitles = new DLNAMediaSubtitle();
+ inputSubtitles.setExternalFile(FileUtils.toFile(CLASS.getResource("../../util/russian-utf8-without-bom.srt")));
+ final DLNAMediaSubtitle convertedSubtitles = SubtitleUtils.shiftSubtitlesTimingWithUtfConversion(inputSubtitles, 0);
+ assertThat(convertedSubtitles.getExternalFile()).hasSameContentAs(inputSubtitles.getExternalFile());
@Raptor399 Owner

I'm getting a failed test when running mvn test from the command line.
Outcommenting line 248 results in no failure. Note that the test runs fine from within Eclipse: I stepped through it and the file copies line by line.

Error output from Maven:

Running net.pms.formats.v2.SubtitleUtilsTest
Tests run: 18, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.183 sec <<< FAILURE!
testShiftSubtitlesTimingWithUtfConversion_doNotConvertUtf8_withoutTimeShift(net.pms.formats.v2.SubtitleUtilsTest)  Time elapsed: 129 sec  <<< FAILURE!
java.lang.AssertionError: file:</var/folders/22/mk15r87109qf3h56sxm74ptr0000gn/T/junit1188821808550719808/subutils/russian-utf8-without-bom1370545795824.tmp> and file:</Users/patricka/Work/ps3mediaserver-git/raptor399/target/test-classes/net/pms/util/russian-utf8-without-bom.srt> do not have same contents:
line:<2>, expected:<'Ни фига себе.'> but was:<'–ù–∏ —Ñ–∏–≥–∞ —Å–µ–±–µ.'>
line:<6>, expected:<'Я смотрю, у вас беспроводный Дэволт.'> but was:<'–Ø —Å–º–æ—Ç—Ä—é, —É –≤–∞—Å –±–µ—Å–ø—Ä–æ–≤–æ–¥–Ω—ã–π –î—ç–≤–æ–ª—Ç.'>
...
line:<198>, expected:<'это настоящий кадиллак.'> but was:<'—ç—Ç–æ –Ω–∞—Å—Ç–æ—è—â–∏–π –∫–∞–¥–∏–ª–ª–∞–∫.'>
    at org.fest.assertions.Fail.failure(Fail.java:228)
    at org.fest.assertions.Assert.failure(Assert.java:149)
    at org.fest.assertions.Assert.fail(Assert.java:140)
    at org.fest.assertions.FileAssert.fail(FileAssert.java:152)
    at org.fest.assertions.FileAssert.hasSameContentAs(FileAssert.java:136)
    at net.pms.formats.v2.SubtitleUtilsTest.testShiftSubtitlesTimingWithUtfConversion_doNotConvertUtf8_withoutTimeShift(SubtitleUtilsTest.java:248)

It seems like the resource is not loaded as UTF-8 properly.

@Raptor399 Owner

Note: that was with Java 6 on Mac OSX.
Just now I updated to Java 7 and the test no longer fails...?

@Happy-Neko Owner

I hope this problem should be fixed with a144c8c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ }
+
+ @Test
+ public void testIsSupportsTimeShifting() {
+ assertThat(SubtitleUtils.isSupportsTimeShifting(null)).isFalse();
+ assertThat(SubtitleUtils.isSupportsTimeShifting(SubtitleType.ASS)).isTrue();
+ assertThat(SubtitleUtils.isSupportsTimeShifting(SubtitleType.SUBRIP)).isTrue();
+ assertThat(SubtitleUtils.isSupportsTimeShifting(SubtitleType.VOBSUB)).isFalse();
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.