[postprocessor] Add DEPENDENCY markers

This commit is contained in:
Yen Chi Hsuan 2016-06-09 22:28:10 +08:00
parent 28bc56459a
commit 3799177bdb
5 changed files with 32 additions and 1 deletions

View File

@ -9,6 +9,7 @@ from .ffmpeg import FFmpegPostProcessor
from ..utils import ( from ..utils import (
check_executable, check_executable,
DownloadTarget,
encodeArgument, encodeArgument,
encodeFilename, encodeFilename,
PostProcessingError, PostProcessingError,
@ -22,6 +23,8 @@ class EmbedThumbnailPPError(PostProcessingError):
class EmbedThumbnailPP(FFmpegPostProcessor): class EmbedThumbnailPP(FFmpegPostProcessor):
DEPENDENCY = set([DownloadTarget.MEDIA, DownloadTarget.THUMBNAILS])
def __init__(self, downloader=None, already_have_thumbnail=False): def __init__(self, downloader=None, already_have_thumbnail=False):
super(EmbedThumbnailPP, self).__init__(downloader) super(EmbedThumbnailPP, self).__init__(downloader)
self._already_have_thumbnail = already_have_thumbnail self._already_have_thumbnail = already_have_thumbnail

View File

@ -4,10 +4,15 @@ import subprocess
from .common import PostProcessor from .common import PostProcessor
from ..compat import compat_shlex_quote from ..compat import compat_shlex_quote
from ..utils import PostProcessingError from ..utils import (
DownloadTarget,
PostProcessingError,
)
class ExecAfterDownloadPP(PostProcessor): class ExecAfterDownloadPP(PostProcessor):
DEPENDENCY = set([DownloadTarget.MEDIA])
def __init__(self, downloader, exec_cmd): def __init__(self, downloader, exec_cmd):
super(ExecAfterDownloadPP, self).__init__(downloader) super(ExecAfterDownloadPP, self).__init__(downloader)
self.exec_cmd = exec_cmd self.exec_cmd = exec_cmd

View File

@ -12,6 +12,7 @@ from ..compat import (
compat_subprocess_get_DEVNULL, compat_subprocess_get_DEVNULL,
) )
from ..utils import ( from ..utils import (
DownloadTarget,
encodeArgument, encodeArgument,
encodeFilename, encodeFilename,
get_exe_version, get_exe_version,
@ -180,6 +181,8 @@ class FFmpegPostProcessor(PostProcessor):
class FFmpegExtractAudioPP(FFmpegPostProcessor): class FFmpegExtractAudioPP(FFmpegPostProcessor):
DEPENDENCY = set([DownloadTarget.MEDIA])
def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, nopostoverwrites=False): def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, nopostoverwrites=False):
FFmpegPostProcessor.__init__(self, downloader) FFmpegPostProcessor.__init__(self, downloader)
if preferredcodec is None: if preferredcodec is None:
@ -308,6 +311,8 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
class FFmpegVideoConvertorPP(FFmpegPostProcessor): class FFmpegVideoConvertorPP(FFmpegPostProcessor):
DEPENDENCY = set([DownloadTarget.MEDIA])
def __init__(self, downloader=None, preferedformat=None): def __init__(self, downloader=None, preferedformat=None):
super(FFmpegVideoConvertorPP, self).__init__(downloader) super(FFmpegVideoConvertorPP, self).__init__(downloader)
self._preferedformat = preferedformat self._preferedformat = preferedformat
@ -331,6 +336,8 @@ class FFmpegVideoConvertorPP(FFmpegPostProcessor):
class FFmpegEmbedSubtitlePP(FFmpegPostProcessor): class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
DEPENDENCY = set([DownloadTarget.MEDIA, DownloadTarget.SUBTITLES])
def run(self, information): def run(self, information):
if information['ext'] not in ('mp4', 'webm', 'mkv'): if information['ext'] not in ('mp4', 'webm', 'mkv'):
self._downloader.to_screen('[ffmpeg] Subtitles can only be embedded in mp4, webm or mkv files') self._downloader.to_screen('[ffmpeg] Subtitles can only be embedded in mp4, webm or mkv files')
@ -387,6 +394,8 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
class FFmpegMetadataPP(FFmpegPostProcessor): class FFmpegMetadataPP(FFmpegPostProcessor):
DEPENDENCY = set([DownloadTarget.MEDIA])
def run(self, info): def run(self, info):
metadata = {} metadata = {}
@ -437,6 +446,8 @@ class FFmpegMetadataPP(FFmpegPostProcessor):
class FFmpegMergerPP(FFmpegPostProcessor): class FFmpegMergerPP(FFmpegPostProcessor):
DEPENDENCY = set([DownloadTarget.MEDIA])
def run(self, info): def run(self, info):
filename = info['filepath'] filename = info['filepath']
temp_filename = prepend_extension(filename, 'temp') temp_filename = prepend_extension(filename, 'temp')
@ -465,6 +476,8 @@ class FFmpegMergerPP(FFmpegPostProcessor):
class FFmpegFixupStretchedPP(FFmpegPostProcessor): class FFmpegFixupStretchedPP(FFmpegPostProcessor):
DEPENDENCY = set([DownloadTarget.MEDIA])
def run(self, info): def run(self, info):
stretched_ratio = info.get('stretched_ratio') stretched_ratio = info.get('stretched_ratio')
if stretched_ratio is None or stretched_ratio == 1: if stretched_ratio is None or stretched_ratio == 1:
@ -484,6 +497,8 @@ class FFmpegFixupStretchedPP(FFmpegPostProcessor):
class FFmpegFixupM4aPP(FFmpegPostProcessor): class FFmpegFixupM4aPP(FFmpegPostProcessor):
DEPENDENCY = set([DownloadTarget.MEDIA])
def run(self, info): def run(self, info):
if info.get('container') != 'm4a_dash': if info.get('container') != 'm4a_dash':
return [], info return [], info
@ -502,6 +517,8 @@ class FFmpegFixupM4aPP(FFmpegPostProcessor):
class FFmpegFixupM3u8PP(FFmpegPostProcessor): class FFmpegFixupM3u8PP(FFmpegPostProcessor):
DEPENDENCY = set([DownloadTarget.MEDIA])
def run(self, info): def run(self, info):
filename = info['filepath'] filename = info['filepath']
temp_filename = prepend_extension(filename, 'temp') temp_filename = prepend_extension(filename, 'temp')
@ -517,6 +534,8 @@ class FFmpegFixupM3u8PP(FFmpegPostProcessor):
class FFmpegSubtitlesConvertorPP(FFmpegPostProcessor): class FFmpegSubtitlesConvertorPP(FFmpegPostProcessor):
DEPENDENCY = set([DownloadTarget.SUBTITLES])
def __init__(self, downloader=None, format=None): def __init__(self, downloader=None, format=None):
super(FFmpegSubtitlesConvertorPP, self).__init__(downloader) super(FFmpegSubtitlesConvertorPP, self).__init__(downloader)
self.format = format self.format = format

View File

@ -11,6 +11,8 @@ class MetadataFromTitlePPError(PostProcessingError):
class MetadataFromTitlePP(PostProcessor): class MetadataFromTitlePP(PostProcessor):
DEPENDENCY = set()
def __init__(self, downloader, titleformat): def __init__(self, downloader, titleformat):
super(MetadataFromTitlePP, self).__init__(downloader) super(MetadataFromTitlePP, self).__init__(downloader)
self._titleformat = titleformat self._titleformat = titleformat

View File

@ -9,6 +9,7 @@ from .common import PostProcessor
from ..compat import compat_os_name from ..compat import compat_os_name
from ..utils import ( from ..utils import (
check_executable, check_executable,
DownloadTarget,
hyphenate_date, hyphenate_date,
version_tuple, version_tuple,
PostProcessingError, PostProcessingError,
@ -33,6 +34,7 @@ class XAttrMetadataError(PostProcessingError):
class XAttrMetadataPP(PostProcessor): class XAttrMetadataPP(PostProcessor):
DEPENDENCY = set([DownloadTarget.MEDIA])
# #
# More info about extended attributes for media: # More info about extended attributes for media: