diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index c30cbc926..4bdfcc558 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals +import pkg_resources from .abc import ABCIE from .academicearth import AcademicEarthCourseIE from .addanime import AddAnimeIE @@ -541,6 +542,7 @@ from .zingmp3 import ( ZingMp3AlbumIE, ) + _ALL_CLASSES = [ klass for name, klass in globals().items() @@ -553,7 +555,25 @@ def gen_extractors(): """ Return a list of an instance of every supported extractor. The order does matter; the first extractor matched is the one handling the URL. """ - return [klass() for klass in _ALL_CLASSES] + + # our extractors have priority over external extractors, but + # the GenericIE must be inserted later + extractors = [klass() for klass in _ALL_CLASSES[:-1]] + + # load external extractors registered throguh the setuptools + # entry-point `youtube_dl.extractor.gen_extractors` + group = 'youtube_dl.extractors' + + for entrypoint in pkg_resources.iter_entry_points(group=group): + # grab the callable that is the actual plugin + plugin = entrypoint.load() + + # install the plugin + extractors.append(plugin()) + + extractors.append(GenericIE()) + + return extractors def get_info_extractor(ie_name):