]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/postprocessor/common.py
   1 from __future__ 
import unicode_literals
 
  11 class PostProcessor(object): 
  12     """Post Processor class. 
  14     PostProcessor objects can be added to downloaders with their 
  15     add_post_processor() method. When the downloader has finished a 
  16     successful download, it will take its internal chain of PostProcessors 
  17     and start calling the run() method on each one of them, first with 
  18     an initial argument and then with the returned value of the previous 
  21     The chain will be stopped if one of them ever returns None or the end 
  22     of the chain is reached. 
  24     PostProcessor objects follow a "mutual registration" process similar 
  25     to InfoExtractor objects. 
  27     Optionally PostProcessor can use a list of additional command-line arguments 
  28     with self._configuration_args. 
  33     def __init__(self
, downloader
=None): 
  34         self
._downloader 
= downloader
 
  36     def set_downloader(self
, downloader
): 
  37         """Sets the downloader for this PP.""" 
  38         self
._downloader 
= downloader
 
  40     def run(self
, information
): 
  41         """Run the PostProcessor. 
  43         The "information" argument is a dictionary like the ones 
  44         composed by InfoExtractors. The only difference is that this 
  45         one has an extra field called "filepath" that points to the 
  48         This method returns a tuple, the first element is a list of the files 
  49         that can be deleted, and the second of which is the updated 
  52         In addition, this method may raise a PostProcessingError 
  53         exception if post processing fails. 
  55         return [], information  
# by default, keep file and do nothing 
  57     def try_utime(self
, path
, atime
, mtime
, errnote
='Cannot update utime of file'): 
  59             os
.utime(encodeFilename(path
), (atime
, mtime
)) 
  61             self
._downloader
.report_warning(errnote
) 
  63     def _configuration_args(self
, default
=[]): 
  64         pp_args 
= self
._downloader
.params
.get('postprocessor_args') 
  67         assert isinstance(pp_args
, list) 
  71 class AudioConversionError(PostProcessingError
):