mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 16:58:51 -05:00
Fix rare MediaInfo issues on Mac OS X (the special characters issue... again... broken during refactoring)
@see https://www.filebot.net/forums/viewtopic.php?f=12&t=3988&p=22392#p22392
This commit is contained in:
parent
5a9169c5ed
commit
1da4b53942
@ -1,10 +1,11 @@
|
|||||||
package net.filebot.mediainfo;
|
package net.filebot.mediainfo;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.*;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@ -35,20 +36,20 @@ public class MediaInfo implements Closeable {
|
|||||||
String path = file.getCanonicalPath();
|
String path = file.getCanonicalPath();
|
||||||
|
|
||||||
// on Mac files that contain accents cannot be opened via JNA WString file paths due to encoding differences so we use the buffer interface instead for these files
|
// on Mac files that contain accents cannot be opened via JNA WString file paths due to encoding differences so we use the buffer interface instead for these files
|
||||||
if (Platform.isMac() && !StandardCharsets.US_ASCII.newEncoder().canEncode(path)) {
|
if (Platform.isMac() && !US_ASCII.newEncoder().canEncode(path)) {
|
||||||
try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
|
try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
|
||||||
if (openViaBuffer(raf)) {
|
if (openViaBuffer(raf)) {
|
||||||
throw new IOException("Failed to initialize media info buffer: " + path);
|
return this;
|
||||||
}
|
}
|
||||||
|
throw new IOException("Failed to initialize media info buffer: " + path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == MediaInfoLibrary.INSTANCE.Open(handle, new WString(path))) {
|
// open via file path
|
||||||
// failed to open file
|
if (0 != MediaInfoLibrary.INSTANCE.Open(handle, new WString(path))) {
|
||||||
throw new IOException("Failed to open media file: " + path);
|
return this;
|
||||||
}
|
}
|
||||||
|
throw new IOException("Failed to open media file: " + path);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean openViaBuffer(RandomAccessFile f) throws IOException {
|
private boolean openViaBuffer(RandomAccessFile f) throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user