diff --git a/apps/api/src/util.py b/apps/api/src/util.py index a8bd003a..f29bab4e 100644 --- a/apps/api/src/util.py +++ b/apps/api/src/util.py @@ -15,7 +15,7 @@ class Supported_Filetype(str, Enum): class URL_Regex(str, Enum): - YOUTUBE = r"^(?:(?:https?://(?:www\.)?(?:m\.)?youtube\.com))/(?:(?:oembed\?url=https?%3A//(?:www\.)youtube.com/watch\?(?:v%3D)(?P[A-Za-z0-9_\-]{11}))|(?:attribution_link\?a=.*watch(?:%3Fv%3D|%3Fv%3D)(?P[A-Za-z0-9_\-]{11}))).*|(?:https?:)?(?:\/\/)?(?:(?:www\.|m\.)?youtube(?:-nocookie)?\.com\/(?:(?:watch)?\?(?:app=desktop&)?(?:feature=\w*&)?v=|embed\/|v\/|e\/)|youtu\.be\/)(?P[A-Za-z0-9_\-]{11}).*$" + YOUTUBE = r"^(?:(?:https?://(?:www\.)?(?:m\.)?youtube\.com))/(?:(?:oembed\?url=https?%3A//(?:www\.)youtube.com/watch\?(?:v%3D)(?P[A-Za-z0-9_\-]{11}))|(?:attribution_link\?a=.*watch(?:%3Fv%3D|%3Fv%3D)(?P[A-Za-z0-9_\-]{11}))).*|(?:https?:)?(?:\/\/)?(?:(?:www\.|m\.)?youtube(?:-nocookie)?\.com\/(?:(?:watch)?\?(?:app=desktop&)?(?:feature=\w*&)?v=|embed\/|v\/|e\/|shorts\/)|youtu\.be\/)(?P[A-Za-z0-9_\-]{11}).*$" """Matches all valid youtube url formats in this list: https://gist.github.com/Snailedlt/d54514e37dda68fefe15e6e056b30747""" VIMEO = r"(https?://)?(www.)?(player.)?vimeo.com/([a-z]*/)*(.*/)?(?P[0-9]{6,11})[?]?.*" diff --git a/apps/api/tests/data_for_testing.py b/apps/api/tests/data_for_testing.py index 6409ecab..f9a57454 100644 --- a/apps/api/tests/data_for_testing.py +++ b/apps/api/tests/data_for_testing.py @@ -288,6 +288,18 @@ ("https://www.youtube.com/e/dQw4w9WgXcQ", "dQw4w9WgXcQ"), ("https://youtube.com/e/dQw4w9WgXcQ", "dQw4w9WgXcQ"), ("https://m.youtube.com/e/dQw4w9WgXcQ", "dQw4w9WgXcQ"), + ("http://www.youtube.com/shorts/j9rZxAF3C0I", "j9rZxAF3C0I"), + ("http://youtube.com/shorts/j9rZxAF3C0I", "j9rZxAF3C0I"), + ("http://m.youtube.com/shorts/j9rZxAF3C0I", "j9rZxAF3C0I"), + ("https://www.youtube.com/shorts/j9rZxAF3C0I", "j9rZxAF3C0I"), + ("https://youtube.com/shorts/j9rZxAF3C0I", "j9rZxAF3C0I"), + ("https://m.youtube.com/shorts/j9rZxAF3C0I", "j9rZxAF3C0I"), + ("http://www.youtube.com/shorts/j9rZxAF3C0I?app=desktop", "j9rZxAF3C0I"), + ("http://youtube.com/shorts/j9rZxAF3C0I?app=desktop", "j9rZxAF3C0I"), + ("http://m.youtube.com/shorts/j9rZxAF3C0I?app=desktop", "j9rZxAF3C0I"), + ("https://www.youtube.com/shorts/j9rZxAF3C0I?app=desktop", "j9rZxAF3C0I"), + ("https://youtube.com/shorts/j9rZxAF3C0I?app=desktop", "j9rZxAF3C0I"), + ("https://m.youtube.com/shorts/j9rZxAF3C0I?app=desktop", "j9rZxAF3C0I"), ] active_vimeo_array_url_formats = [