]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/postprocessor/execafterdownload.py
baf1b1945126776c3ad64dd72d65b9223ab845a0
   1 from __future__ 
import unicode_literals
 
   5 from .common 
import PostProcessor
 
   6 from ..compat 
import shlex_quote
 
   7 from ..utils 
import PostProcessingError
 
  10 class ExecAfterDownloadPP(PostProcessor
): 
  11     def __init__(self
, downloader
=None, verboseOutput
=None, exec_cmd
=None): 
  12         self
.verboseOutput 
= verboseOutput
 
  13         self
.exec_cmd 
= exec_cmd
 
  15     def run(self
, information
): 
  20         cmd 
= cmd
.replace('{}', shlex_quote(information
['filepath'])) 
  22         self
._downloader
.to_screen("[exec] Executing command: %s" % cmd
) 
  23         retCode 
= subprocess
.call(cmd
, shell
=True) 
  25             raise PostProcessingError( 
  26                 'Command returned error code %d' % retCode
) 
  28         return None, information  
# by default, keep file and do nothing