Fixed parsing of YouTube urls
This commit is contained in:
parent
d553231ff2
commit
d71db727d5
|
@ -205,12 +205,21 @@ WIKIDATA_PROPERTIES: dict[SocialSiteId | int, WikidataInfo] = {
|
|||
}
|
||||
|
||||
|
||||
RE_ID_AT = r'@([^\s/]+)'
|
||||
RE_ID_NOAT = r'([^\s/]+)'
|
||||
RE_ID = r'@?([^\s/]+)'
|
||||
RE_DUAL_ID = r'@?([^\s/]+/[^\s/]+)'
|
||||
RE_ANY_SUBPATH = r'(|\/|\/\S*)$'
|
||||
|
||||
SPECIAL_REGEX_LITERALS = frozenset({RE_ID, RE_DUAL_ID, RE_ANY_SUBPATH})
|
||||
REGEX_LITERALS_TO_FORMATTER = {RE_ID: '{id}', RE_DUAL_ID: '{id}', RE_ANY_SUBPATH: ''}
|
||||
SPECIAL_REGEX_LITERALS = frozenset({RE_ID, RE_DUAL_ID, RE_ANY_SUBPATH,
|
||||
RE_ID_AT, RE_ID_NOAT})
|
||||
REGEX_LITERALS_TO_FORMATTER = {
|
||||
RE_ID: '{id}',
|
||||
RE_ID_AT: '@{id}',
|
||||
RE_ID_NOAT: '{id}',
|
||||
RE_DUAL_ID: '{id}',
|
||||
RE_ANY_SUBPATH: '',
|
||||
}
|
||||
DOES_NOT_NEED_AUTO_SLASH = frozenset({RE_ANY_SUBPATH})
|
||||
|
||||
|
||||
|
@ -349,7 +358,7 @@ URL_FORMATS: list[tuple[object, SocialPathFormat]] = [
|
|||
# Youtube
|
||||
(
|
||||
SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
|
||||
social_path_format_adv('youtube.com', RE_ID, RE_ANY_SUBPATH),
|
||||
social_path_format_adv('youtube.com', RE_ID_AT, RE_ANY_SUBPATH),
|
||||
),
|
||||
(
|
||||
SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
|
||||
|
@ -359,6 +368,10 @@ URL_FORMATS: list[tuple[object, SocialPathFormat]] = [
|
|||
SocialSiteId.YOUTUBE_CHANNEL_ID,
|
||||
social_path_format_adv('youtube.com', 'channel', RE_ID),
|
||||
),
|
||||
(
|
||||
SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
|
||||
social_path_format_adv('youtube.com', RE_ID_NOAT, RE_ANY_SUBPATH),
|
||||
),
|
||||
# Vimeo
|
||||
(SocialSiteId.VIMEO_CHANNEL, social_path_format_adv('vimeo.com', RE_ID)),
|
||||
# Newgrounds
|
||||
|
|
|
@ -80,6 +80,11 @@ PARSABLE_SOCIAL_IDS_COMBINED: list[tuple[str, object, str | None]] = [
|
|||
('https://wikidata.org/wiki/Q594400', SocialSiteId.WIKIDATA, 'Q594400'),
|
||||
('https://m.wikidata.org/wiki/Q594400', SocialSiteId.WIKIDATA, 'Q594400'),
|
||||
# YouTube formats
|
||||
(
|
||||
'https://youtube.com/WheelieYellow',
|
||||
SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
|
||||
'WheelieYellow',
|
||||
),
|
||||
(
|
||||
'https://youtube.com/@WheelieYellow',
|
||||
SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
|
||||
|
@ -100,11 +105,21 @@ PARSABLE_SOCIAL_IDS_COMBINED: list[tuple[str, object, str | None]] = [
|
|||
SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
|
||||
'WheelieYellow',
|
||||
),
|
||||
(
|
||||
'https://www.youtube.com/c/WheelieYellow',
|
||||
SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
|
||||
'WheelieYellow',
|
||||
),
|
||||
(
|
||||
'https://www.youtube.com/@WheelieYellow/featured',
|
||||
SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
|
||||
'WheelieYellow',
|
||||
),
|
||||
(
|
||||
'https://www.youtube.com/channel/UCe8PM1vX4w_spGwYy7gQV4w',
|
||||
SocialSiteId.YOUTUBE_CHANNEL_ID,
|
||||
'UCe8PM1vX4w_spGwYy7gQV4w',
|
||||
),
|
||||
# GitHub
|
||||
('https://github.com/love2d/love', SocialSiteId.GITHUB_REPOSITORY, 'love2d/love'),
|
||||
('https://github.com/love2d/love/', SocialSiteId.GITHUB_REPOSITORY, 'love2d/love'),
|
||||
|
|
Loading…
Reference in New Issue
Block a user