Skip to content

Instantly share code, notes, and snippets.

@lambdan
Created November 15, 2015 22:25
Show Gist options
  • Save lambdan/cb20de01947c8e9b2546 to your computer and use it in GitHub Desktop.
Save lambdan/cb20de01947c8e9b2546 to your computer and use it in GitHub Desktop.
Generate "blank" .srt to make Plex not display external subtitles over burned in subtitles
import os
import shutil
import sys
triggers = ['swesub']
ignores = ['.py', '.jpg', '.nfo', '.txt', '.sh', '.db', '.srt', '.nu', '.url']
always = False
def writeSrt(srt):
print srt
with open(srt, 'w') as fi:
fi.write("1\n00:00:00,000 --> 00:00:01,000\nSWESUB\n")
files = [i for i in os.listdir('.') if not os.path.isdir(i)]
for filename in files:
if os.path.splitext(filename)[1] not in ignores:
f = os.path.splitext(filename)[0] # filename without extension
srt = f + ".sv.srt"
if not os.path.exists(srt): # check if there already is a srt
if any(word in f.lower() for word in triggers) or always == True or f.lower() == "cd1" or f.lower()=="cd2":
writeSrt(srt)
else:
print "Is '" + f + "' swesub? (y/all)"
choice = raw_input().lower()
if choice == "y":
writeSrt(srt)
elif choice == "all":
always = True
writeSrt(srt)
print 'All done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment