Page 1 of 1

CLI windows output encoding?

Posted: 23 Oct 2014, 01:19
by laharah
Hi!

I'm writing a script (python) that calls filebot as a subprocess and takes in it's stdoutput and parses it. Everything works great, except for when there is a non-english character.

To be clear, the actual file itself gets moved to the correct filename without trouble, it's only the output "Rename x to y" that has encoding errors

for example:
If you run

Code: Select all

filebot -rename --action test "hannibal s02e05.avi"
the output you get (on windows) is this:

Code: Select all

Filename pattern: [1.00] SxE, [0.00] CWS
Rename episodes using [TheTVDB]
Auto-detected query: [Hannibal]
Fetching episode data for [Hannibal]
[TEST] Rename [F:\Waste\Movies and shows\Shows\Hannibal\Hannibal Season 2\Hannibal S02E05 - Mukozuke.mp4] to [Hannibal - 2x05 - Muk?zuke.mp4]
Processed 1 files
Done ?(?????)?
After a ton of research I finally figured out that windows is using cp-1252 encoding, so some non-english letters work ok when I decode them. However in situations like the one above, I still get question marks. Is there a specific codec that filebot is outputting? Does anyone know a way in python I can get the unicode output directly from filebot without letting windows and it's crap encoding mess it up?

my systeminfo should it be useful:

Code: Select all

FileBot 4.5 (r2612)
JNA Native: 4.0.0
MediaInfo: MediaInfoLib - v0.7.69
7-Zip-JBinding: OK
chromaprint-tools: fpcalc version 1.1.0 (C:\Program Files\FileBot\fpcalc.exe)
Extended Attributes: OK
Groovy Engine: 2.3.7
JRE: Java(TM) SE Runtime Environment 1.8.0_25
JVM: 64-bit Java HotSpot(TM) 64-Bit Server VM
CPU/MEM: 8 Core / 3 GB Max Memory / 13 MB Used Memory
OS: Windows 7 (amd64)
uname: MINGW32_NT-6.1 LAHARAH 1.0.12(0.46/3/2) 2012-07-05 14:56 i686 unknown
Done ?(?????)?

Re: CLI windows output encoding?

Posted: 23 Oct 2014, 04:43
by rednoah
Windows makes these things pretty tricky.

Just use --log-file <path> and then parse that file after the filebot process has terminated.

Re: CLI windows output encoding?

Posted: 23 Oct 2014, 06:32
by laharah
Thanks so much for your reply, it's a very good workaround! I wish it could be direct, but oh well, needs must.

-laharah