[test_unicode_literals] Arm unicode_literals check
[youtube-dl] / youtube_dl / postprocessor / common.py
1 from __future__ import unicode_literals
2
3 from ..utils import PostProcessingError
4
5
6 class PostProcessor(object):
7     """Post Processor class.
8
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
14     PostProcessor.
15
16     The chain will be stopped if one of them ever returns None or the end
17     of the chain is reached.
18
19     PostProcessor objects follow a "mutual registration" process similar
20     to InfoExtractor objects.
21     """
22
23     _downloader = None
24
25     def __init__(self, downloader=None):
26         self._downloader = downloader
27
28     def set_downloader(self, downloader):
29         """Sets the downloader for this PP."""
30         self._downloader = downloader
31
32     def run(self, information):
33         """Run the PostProcessor.
34
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
38         downloaded file.
39
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.
43
44         In addition, this method may raise a PostProcessingError
45         exception if post processing fails.
46         """
47         return None, information  # by default, keep file and do nothing
48
49
50 class AudioConversionError(PostProcessingError):
51     pass