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