]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/postprocessor/atomicparsley.py
765b2d9ee7c834ee1d03be6fc4e20d7628ad0f76
1 # -*- coding: utf-8 -*-
2 from __future__
import unicode_literals
8 from .common
import PostProcessor
20 class AtomicParsleyPPError(PostProcessingError
):
24 class AtomicParsleyPP(PostProcessor
):
26 if not check_executable('AtomicParsley', ['-v']):
27 raise AtomicParsleyPPError('AtomicParsley was not found. Please install.')
29 filename
= info
['filepath']
30 temp_filename
= prepend_extension(filename
, 'temp')
31 temp_thumbnail
= prepend_extension(filename
, 'thumb')
33 if not info
.get('thumbnail'):
34 raise AtomicParsleyPPError('Thumbnail was not found. Nothing to do.')
36 compat_urlretrieve(info
['thumbnail'], temp_thumbnail
)
38 cmd
= ['AtomicParsley', filename
, '--artwork', temp_thumbnail
, '-o', temp_filename
]
40 self
._downloader
.to_screen('[atomicparsley] Adding thumbnail to "%s"' % filename
)
42 if self
._downloader
.params
.get('verbose', False):
43 self
._downloader
.to_screen('[debug] AtomicParsley command line: %s' % shell_quote(cmd
))
45 p
= subprocess
.Popen(cmd
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
46 stdout
, stderr
= p
.communicate()
49 msg
= stderr
.decode('utf-8', 'replace').strip()
50 raise AtomicParsleyPPError(msg
)
52 os
.remove(encodeFilename(filename
))
53 os
.remove(encodeFilename(temp_thumbnail
))
54 os
.rename(encodeFilename(temp_filename
), encodeFilename(filename
))