1
0

Fixed parsing of YouTube urls
Some checks failed
Run Python tests (through Pytest) / Test (push) Waiting to run
Verify Python project can be installed, loaded and have version checked / Test (push) Waiting to run
Python Ruff Code Quality / ruff (push) Has been cancelled

This commit is contained in:
Jon Michael Aanes 2024-11-21 19:39:38 +01:00
parent d553231ff2
commit d71db727d5
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
2 changed files with 31 additions and 3 deletions

View File

@ -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_ID = r'@?([^\s/]+)'
RE_DUAL_ID = r'@?([^\s/]+/[^\s/]+)' RE_DUAL_ID = r'@?([^\s/]+/[^\s/]+)'
RE_ANY_SUBPATH = r'(|\/|\/\S*)$' RE_ANY_SUBPATH = r'(|\/|\/\S*)$'
SPECIAL_REGEX_LITERALS = frozenset({RE_ID, RE_DUAL_ID, RE_ANY_SUBPATH}) 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: ''} 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}) DOES_NOT_NEED_AUTO_SLASH = frozenset({RE_ANY_SUBPATH})
@ -349,7 +358,7 @@ URL_FORMATS: list[tuple[object, SocialPathFormat]] = [
# Youtube # Youtube
( (
SocialSiteId.YOUTUBE_CHANNEL_HANDLE, 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, SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
@ -359,6 +368,10 @@ URL_FORMATS: list[tuple[object, SocialPathFormat]] = [
SocialSiteId.YOUTUBE_CHANNEL_ID, SocialSiteId.YOUTUBE_CHANNEL_ID,
social_path_format_adv('youtube.com', 'channel', RE_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 # Vimeo
(SocialSiteId.VIMEO_CHANNEL, social_path_format_adv('vimeo.com', RE_ID)), (SocialSiteId.VIMEO_CHANNEL, social_path_format_adv('vimeo.com', RE_ID)),
# Newgrounds # Newgrounds

View File

@ -80,6 +80,11 @@ PARSABLE_SOCIAL_IDS_COMBINED: list[tuple[str, object, str | None]] = [
('https://wikidata.org/wiki/Q594400', SocialSiteId.WIKIDATA, 'Q594400'), ('https://wikidata.org/wiki/Q594400', SocialSiteId.WIKIDATA, 'Q594400'),
('https://m.wikidata.org/wiki/Q594400', SocialSiteId.WIKIDATA, 'Q594400'), ('https://m.wikidata.org/wiki/Q594400', SocialSiteId.WIKIDATA, 'Q594400'),
# YouTube formats # YouTube formats
(
'https://youtube.com/WheelieYellow',
SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
'WheelieYellow',
),
( (
'https://youtube.com/@WheelieYellow', 'https://youtube.com/@WheelieYellow',
SocialSiteId.YOUTUBE_CHANNEL_HANDLE, SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
@ -100,11 +105,21 @@ PARSABLE_SOCIAL_IDS_COMBINED: list[tuple[str, object, str | None]] = [
SocialSiteId.YOUTUBE_CHANNEL_HANDLE, SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
'WheelieYellow', 'WheelieYellow',
), ),
(
'https://www.youtube.com/c/WheelieYellow',
SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
'WheelieYellow',
),
( (
'https://www.youtube.com/@WheelieYellow/featured', 'https://www.youtube.com/@WheelieYellow/featured',
SocialSiteId.YOUTUBE_CHANNEL_HANDLE, SocialSiteId.YOUTUBE_CHANNEL_HANDLE,
'WheelieYellow', 'WheelieYellow',
), ),
(
'https://www.youtube.com/channel/UCe8PM1vX4w_spGwYy7gQV4w',
SocialSiteId.YOUTUBE_CHANNEL_ID,
'UCe8PM1vX4w_spGwYy7gQV4w',
),
# GitHub # GitHub
('https://github.com/love2d/love', SocialSiteId.GITHUB_REPOSITORY, 'love2d/love'), ('https://github.com/love2d/love', SocialSiteId.GITHUB_REPOSITORY, 'love2d/love'),
('https://github.com/love2d/love/', SocialSiteId.GITHUB_REPOSITORY, 'love2d/love'), ('https://github.com/love2d/love/', SocialSiteId.GITHUB_REPOSITORY, 'love2d/love'),