encoding, sync subtitles.py

This commit is contained in:
j 2007-07-12 19:47:19 +00:00
parent 3b61a5e4b7
commit 4ff287b98b
2 changed files with 7 additions and 3 deletions

View file

@ -12,6 +12,10 @@ def extractNew():
for f in ArchiveFile.select(ArchiveFile.q.extracted == False):
f.extractAll()
def cleanScrapeitCache():
#remove files older than 30 days from scrapeit cache
os.system("""find /var/cache/scrapeit/ -type f -ctime +30 -exec rm '{}' \;""")
def cleanClipMovieCache():
cache = os.path.abspath('oxdb/cache/mini/')

View file

@ -12,14 +12,14 @@ import chardet
img_extension = 'jpg'
def srt2txt(srt, encoding = "latin-1"):
def srt2txt(srt, encoding = "utf-8"):
subtitles = srt2dict(srt, encoding)
txt = ''
for k in sorted([int(k) for k in subtitles.keys()]):
txt += "%s\n\n" % subtitles["%s" % k]['text']
return txt.strip()
def srt2dict(srt, encoding = "latin-1"):
def srt2dict(srt, encoding = "utf-8"):
'''convert srt string into a dict in the form
dict(num = dict(start, stop, text))
'''
@ -39,7 +39,7 @@ def srt2dict(srt, encoding = "latin-1"):
}
return subdict
def dict2srt(subtitles, encoding = "latin-1"):
def dict2srt(subtitles, encoding = "utf-8"):
'''convert dict in the form dict(num = dict(start, stop, text))
into an srt file
'''