mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-14 07:37:25 +08:00
Add support for third-party extractors
Other packages can register new extractors through the `youtube_dl.extractors` setuptools entry-point: # in mypackage/setup.py setup( ... entry_points={ 'youtube_dl.extractors': [ 'myextractor = mypackage.extractor.MyExtractorIE', ], }, )
This commit is contained in:
parent
60e5428925
commit
8f2216b9f6
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user