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