Make sure things still work without pkg_resources
This commit is contained in:
parent
8f2216b9f6
commit
7afa5c42bf
@ -1,5 +1,4 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from .abc import ABCIE
|
from .abc import ABCIE
|
||||||
from .academicearth import AcademicEarthCourseIE
|
from .academicearth import AcademicEarthCourseIE
|
||||||
@ -541,6 +540,7 @@ from .zingmp3 import (
|
|||||||
ZingMp3SongIE,
|
ZingMp3SongIE,
|
||||||
ZingMp3AlbumIE,
|
ZingMp3AlbumIE,
|
||||||
)
|
)
|
||||||
|
from ..utils import pkg_resources_iter_entry_points
|
||||||
|
|
||||||
|
|
||||||
_ALL_CLASSES = [
|
_ALL_CLASSES = [
|
||||||
@ -555,23 +555,25 @@ def gen_extractors():
|
|||||||
""" Return a list of an instance of every supported extractor.
|
""" Return a list of an instance of every supported extractor.
|
||||||
The order does matter; the first extractor matched is the one handling the URL.
|
The order does matter; the first extractor matched is the one handling the URL.
|
||||||
"""
|
"""
|
||||||
|
extractors = [klass() for klass in _ALL_CLASSES]
|
||||||
|
|
||||||
# our extractors have priority over external extractors, but
|
# our extractors have priority over external extractors, but
|
||||||
# the GenericIE must be inserted later
|
# the GenericIE must be the last one in the list, so we'll reappend it
|
||||||
extractors = [klass() for klass in _ALL_CLASSES[:-1]]
|
# later
|
||||||
|
generic_ie = extractors.pop()
|
||||||
|
|
||||||
# load external extractors registered throguh the setuptools
|
# load external extractors registered through the entry point
|
||||||
# entry-point `youtube_dl.extractor.gen_extractors`
|
# `youtube_dl.extractors`
|
||||||
group = 'youtube_dl.extractors'
|
group = 'youtube_dl.extractors'
|
||||||
|
|
||||||
for entrypoint in pkg_resources.iter_entry_points(group=group):
|
for entrypoint in pkg_resources_iter_entry_points(group=group):
|
||||||
# grab the callable that is the actual plugin
|
# grab the callable that is the actual plugin
|
||||||
plugin = entrypoint.load()
|
plugin = entrypoint.load()
|
||||||
|
|
||||||
# install the plugin
|
# install the plugin
|
||||||
extractors.append(plugin())
|
extractors.append(plugin())
|
||||||
|
|
||||||
extractors.append(GenericIE())
|
extractors.append(generic_ie)
|
||||||
|
|
||||||
return extractors
|
return extractors
|
||||||
|
|
||||||
|
@ -1543,3 +1543,13 @@ def ytdl_is_updateable():
|
|||||||
def args_to_str(args):
|
def args_to_str(args):
|
||||||
# Get a short string representation for a subprocess command
|
# Get a short string representation for a subprocess command
|
||||||
return ' '.join(shlex_quote(a) for a in args)
|
return ' '.join(shlex_quote(a) for a in args)
|
||||||
|
|
||||||
|
|
||||||
|
# Support for platforms where pkg_resources is not available
|
||||||
|
try:
|
||||||
|
import pkg_resources
|
||||||
|
def pkg_resources_iter_entry_points(*args, **kwargs):
|
||||||
|
return pkg_resources.iter_entry_points(*args, **kwargs)
|
||||||
|
except ImportError:
|
||||||
|
def pkg_resources_iter_entry_points(*args, **kwargs):
|
||||||
|
return []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user