全部博文(330)
分类:
2011-11-20 20:11:40
:
betime = line.replace('.', ',').split('"')
endtime = time_add(betime[1], betime[3])
lines.append( str(num) + '\n')
subtime = betime[1] + ' --> ' + endtime
lines.append(subtime + '\n')
elif line[-4:-1] == '/p>':
lines.append(line.split('<')[0] + '\n\n')
num += 1
else:
pass
fdr.close()
subtitlename = os.path.splitext(xml)[0] + '.srt'
fdw = open(os.path.join(path, subtitlename), 'w')
fdw.writelines(''.join(lines))
fdw.close()
if __name__ == '__main__':
if len(sys.argv) < 2:
print 'Please give the \'Path\' argument!'
for path in sys.argv:
if os.path.isdir(path):
files = os.listdir(path)
i = 0
while i < len(files):
if '-subtitles.xml' in files[i]:
del files[i]
else:
i += 1
print files
download_sub(path, files)
convert_xml(path, files)