2025-01-02, 04:25 AM
(2023-07-02, 09:06 PM)skribe Wrote: I'm afraid that I have very little personal experience with subtitles. I would imagine that there isn't a way to add fonts to a TV app client. You may need, instead, to install them on the server device and force subtitle burn-in. The burn-in setting is a user setting in the client I believe, and the relevant server setting is the "fallback fonts" section under the playback section of your dashboard.
Just make sure to install a font that has complete support for all of the special characters utilized by whatever language you're trying to play.
Hi,
I've used the python script made by Yababakets with success and thank you for the explanation.
Here i modified the code to be able to specify the directory as an argument.
Code:
import os
import codecs
import argparse
def is_utf8(file_path):
try:
with open(file_path, 'r', encoding='UTF-8') as f:
f.read()
return True
except UnicodeDecodeError:
return False
def convert_encoding(file_path):
with codecs.open(file_path, 'r', 'ISO-8859-2') as f:
content = f.read()
with codecs.open(file_path, 'w', 'UTF-8') as f:
f.write(content)
def process_directory(directory):
for root, _, files in os.walk(directory):
for file in files:
if file.endswith(('.sub', '.srt')):
file_path = os.path.join(root, file)
if not is_utf8(file_path):
convert_encoding(file_path)
print(f"Converted: {file_path}")
else:
print(f"Skipping: {file_path} (already UTF-8)")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Convert subtitle files (.sub, .srt) to UTF-8.")
parser.add_argument("directory", type=str, help="Path to the directory containing subtitle files.")
args = parser.parse_args()
if os.path.isdir(args.directory):
process_directory(args.directory)
else:
print(f"Error: {args.directory} is not a valid directory.")
Usage
Code:
python iso2utf.py /media/movies/final