[ie/youtube] Refactor project structure

This commit is contained in:
coletdjnz 2025-04-12 09:19:40 +12:00
parent 0c857e5de8
commit 71de622d19
No known key found for this signature in database
GPG Key ID: 91984263BB39894A
11 changed files with 15 additions and 12 deletions

View File

@ -4,7 +4,7 @@ from collections import OrderedDict
import pytest
from yt_dlp.extractor.youtube.pot._provider import IEContentProvider, BuiltInIEContentProvider
from yt_dlp.utils import bug_reports_message
from yt_dlp.extractor.youtube.pot.builtin.cache.memory import MemoryLRUPCP, memorylru_preference, initialize_global_cache
from yt_dlp.extractor.youtube.pot._builtin.memory_cache import MemoryLRUPCP, memorylru_preference, initialize_global_cache
from yt_dlp.version import __version__
from yt_dlp.globals import _pot_memory_cache, _pot_cache_providers

View File

@ -4,7 +4,7 @@ from yt_dlp.extractor.youtube.pot.provider import (
)
from yt_dlp.extractor.youtube.pot.builtin.utils import get_webpo_content_binding, ContentBindingType
from yt_dlp.extractor.youtube.pot.utils import get_webpo_content_binding, ContentBindingType
class TestGetWebPoContentBinding:

View File

@ -10,7 +10,7 @@ from yt_dlp.extractor.youtube.pot.provider import (
)
from yt_dlp.version import __version__
from yt_dlp.extractor.youtube.pot.builtin.cachespec.webpo import WebPoPCSP
from yt_dlp.extractor.youtube.pot._builtin.webpo_cachespec import WebPoPCSP
from yt_dlp.globals import _pot_pcs_providers

View File

@ -8,7 +8,7 @@ Refer to the [PO Token Guide](https://github.com/yt-dlp/yt-dlp/wiki/PO-Token-Gui
- `yt_dlp.extractor.youtube.pot.cache`
- `yt_dlp.extractor.youtube.pot.provider`
- `yt_dlp.extractor.youtube.pot.builtin.utils`
- `yt_dlp.extractor.youtube.pot.utils`
Everything else is internal-only and no guarantees are made about the API stability.
@ -33,7 +33,7 @@ from yt_dlp.extractor.youtube.pot.provider import (
register_preference,
)
from yt_dlp.networking.common import Request
from yt_dlp.extractor.youtube.pot.builtin.utils import get_webpo_content_binding
from yt_dlp.extractor.youtube.pot.utils import get_webpo_content_binding
from yt_dlp.utils import traverse_obj
from yt_dlp.networking.exceptions import RequestError
import json
@ -50,7 +50,7 @@ class MyPoTokenProviderPTP(PoTokenProvider): # Provider name must end with "PTP
# Innertube Client Name.
# For example, "WEB", "ANDROID", "TVHTML5".
# For a list of WebPO client names, see yt_dlp.extractor.youtube.pot.builtin.utils.WEBPO_CLIENTS.
# For a list of WebPO client names, see yt_dlp.extractor.youtube.pot.utils.WEBPO_CLIENTS.
# Also see yt_dlp.extractor.youtube._base.INNERTUBE_CLIENTS for a list of client names currently supported by the YouTube extractor.
_SUPPORTED_CLIENTS = ('WEB', 'TVHTML5')

View File

@ -1 +1,2 @@
from .builtin import utils as _ # noqa: F401
# Trigger import of built-in providers
from ._builtin import _trigger_import # noqa: F401

View File

@ -0,0 +1,4 @@
from .memory_cache import MemoryLRUPCP as _MemoryLRUPCP # noqa: F401
from .webpo_cachespec import WebPoPCSP as _WebPoPCSP # noqa: F401
_trigger_import = None # noqa: F401

View File

@ -1,7 +1,6 @@
from __future__ import annotations
from yt_dlp.extractor.youtube.pot._provider import BuiltInIEContentProvider
from yt_dlp.extractor.youtube.pot.builtin.utils import ContentBindingType, get_webpo_content_binding
from yt_dlp.extractor.youtube.pot.cache import (
CacheProviderWritePolicy,
PoTokenCacheSpec,
@ -11,6 +10,7 @@ from yt_dlp.extractor.youtube.pot.cache import (
from yt_dlp.extractor.youtube.pot.provider import (
PoTokenRequest,
)
from yt_dlp.extractor.youtube.pot.utils import ContentBindingType, get_webpo_content_binding
from yt_dlp.utils import traverse_obj

View File

@ -1,2 +0,0 @@
from .cache.memory import MemoryLRUPCP as _MemoryPCP # noqa: F401
from .cachespec.webpo import WebPoPCSP as _WebPoPCSP # noqa: F401

View File

@ -97,7 +97,7 @@ class PoTokenProvider(IEContentProvider, abc.ABC, suffix='PTP'):
# Innertube Client Name.
# For example, "WEB", "ANDROID", "TVHTML5".
# For a list of WebPO client names, see yt_dlp.extractor.youtube.pot.builtin.utils.WEBPO_CLIENTS.
# For a list of WebPO client names, see yt_dlp.extractor.youtube.pot._builtin.utils.WEBPO_CLIENTS.
# Also see yt_dlp.extractor.youtube._base.INNERTUBE_CLIENTS for a list of client names currently supported by the YouTube extractor.
_SUPPORTED_CLIENTS: tuple[str] | None = ()

View File

@ -10,7 +10,7 @@ import urllib.parse
from yt_dlp.extractor.youtube.pot.provider import PoTokenContext, PoTokenRequest
from yt_dlp.utils import traverse_obj
__all__ = ['WEBPO_CLIENTS', 'get_webpo_content_binding']
__all__ = ['WEBPO_CLIENTS', 'ContentBindingType', 'get_webpo_content_binding']
WEBPO_CLIENTS = (
'WEB',