]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/postprocessor/common.py
e54ae678da17bef5c5848bc7165d42d5eec912a4
1 from __future__
import unicode_literals
3 from ..utils
import PostProcessingError
6 class PostProcessor(object):
7 """Post Processor class.
9 PostProcessor objects can be added to downloaders with their
10 add_post_processor() method. When the downloader has finished a
11 successful download, it will take its internal chain of PostProcessors
12 and start calling the run() method on each one of them, first with
13 an initial argument and then with the returned value of the previous
16 The chain will be stopped if one of them ever returns None or the end
17 of the chain is reached.
19 PostProcessor objects follow a "mutual registration" process similar
20 to InfoExtractor objects.
25 def __init__(self
, downloader
=None):
26 self
._downloader
= downloader
28 def set_downloader(self
, downloader
):
29 """Sets the downloader for this PP."""
30 self
._downloader
= downloader
32 def run(self
, information
):
33 """Run the PostProcessor.
35 The "information" argument is a dictionary like the ones
36 composed by InfoExtractors. The only difference is that this
37 one has an extra field called "filepath" that points to the
40 This method returns a tuple, the first element of which describes
41 whether the original file should be kept (i.e. not deleted - None for
42 no preference), and the second of which is the updated information.
44 In addition, this method may raise a PostProcessingError
45 exception if post processing fails.
47 return None, information
# by default, keep file and do nothing
50 class AudioConversionError(PostProcessingError
):