mirror of
https://github.com/anxdpanic/plugin.video.youtube.git
synced 2025-12-06 02:30:50 -08:00
Allow urls from www.youtubekids.com to be directly handled by the addon
This commit is contained in:
parent
92a7c81698
commit
01e4322791
3 changed files with 13 additions and 16 deletions
|
|
@ -53,6 +53,13 @@ VALUE_TO_STR = {
|
|||
1: 'true',
|
||||
}
|
||||
|
||||
YOUTUBE_HOSTNAMES = {
|
||||
'youtube.com',
|
||||
'www.youtube.com',
|
||||
'm.youtube.com',
|
||||
'www.youtubekids.com',
|
||||
}
|
||||
|
||||
# Flags
|
||||
ABORT_FLAG = 'abort_requested'
|
||||
BUSY_FLAG = 'busy'
|
||||
|
|
@ -217,6 +224,7 @@ __all__ = (
|
|||
# Const values
|
||||
'BOOL_FROM_STR',
|
||||
'VALUE_TO_STR',
|
||||
'YOUTUBE_HOSTNAMES',
|
||||
|
||||
# Flags
|
||||
'ABORT_FLAG',
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ from re import compile as re_compile
|
|||
|
||||
from ...kodion import logging
|
||||
from ...kodion.compatibility import parse_qsl, unescape, urlencode, urlsplit
|
||||
from ...kodion.constants import YOUTUBE_HOSTNAMES
|
||||
from ...kodion.network import BaseRequestsClass
|
||||
|
||||
|
||||
|
|
@ -68,11 +69,7 @@ class YouTubeResolver(AbstractResolver):
|
|||
super(YouTubeResolver, self).__init__(*args, **kwargs)
|
||||
|
||||
def supports_url(self, url, url_components):
|
||||
if url_components.hostname not in {
|
||||
'www.youtube.com',
|
||||
'youtube.com',
|
||||
'm.youtube.com',
|
||||
}:
|
||||
if url_components.hostname not in YOUTUBE_HOSTNAMES:
|
||||
return False
|
||||
|
||||
path = url_components.path.lower()
|
||||
|
|
@ -217,11 +214,7 @@ class CommonResolver(AbstractResolver):
|
|||
super(CommonResolver, self).__init__(*args, **kwargs)
|
||||
|
||||
def supports_url(self, url, url_components):
|
||||
if url_components.hostname in {
|
||||
'www.youtube.com',
|
||||
'youtube.com',
|
||||
'm.youtube.com',
|
||||
}:
|
||||
if url_components.hostname in YOUTUBE_HOSTNAMES:
|
||||
return False
|
||||
return 'HEAD'
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ from ...kodion.constants import (
|
|||
START,
|
||||
VIDEO_ID,
|
||||
VIDEO_IDS,
|
||||
YOUTUBE_HOSTNAMES,
|
||||
)
|
||||
from ...kodion.items import DirectoryItem, UriItem, VideoItem
|
||||
from ...kodion.utils.convert_format import duration_to_seconds
|
||||
|
|
@ -41,11 +42,6 @@ class UrlToItemConverter(object):
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
RE_PATH_ID = re_compile(r'/[^/]*?[/@](?P<id>[^/?#]+)', IGNORECASE)
|
||||
VALID_HOSTNAMES = {
|
||||
'youtube.com',
|
||||
'www.youtube.com',
|
||||
'm.youtube.com',
|
||||
}
|
||||
|
||||
def __init__(self, flatten=True):
|
||||
self._flatten = flatten
|
||||
|
|
@ -67,7 +63,7 @@ class UrlToItemConverter(object):
|
|||
def add_url(self, url):
|
||||
parsed_url = urlsplit(url)
|
||||
if (not parsed_url.hostname
|
||||
or parsed_url.hostname.lower() not in self.VALID_HOSTNAMES):
|
||||
or parsed_url.hostname.lower() not in YOUTUBE_HOSTNAMES):
|
||||
self.log.debug('Unknown hostname "{hostname}" in url "{url}"',
|
||||
hostname=parsed_url.hostname,
|
||||
url=url)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue