diff options
Diffstat (limited to 'youtube_dl/FileDownloader.py')
-rw-r--r-- | youtube_dl/FileDownloader.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index a861086c3..d9a4ecd3a 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -433,11 +433,8 @@ class FileDownloader(object): try: srtfn = filename.rsplit('.', 1)[0] + u'.srt' self.report_writesubtitles(srtfn) - srtfile = open(encodeFilename(srtfn), 'wb') - try: - srtfile.write(info_dict['subtitles'].encode('utf-8')) - finally: - srtfile.close() + with io.open(encodeFilename(srtfn), 'w', encoding='utf-8') as srtfile: + srtfile.write(info_dict['subtitles']) except (OSError, IOError): self.trouble(u'ERROR: Cannot write subtitles file ' + descfn) return |