Download checking.py from ayushparwal2004/youtubeVideoSummarizer: direct link, hf CLI and curl.
- Browser
- Download file 753 Bytes
-
https://huggingface.co/spaces/ayushparwal2004/youtubeVideoSummarizer/resolve/main/checking.py
- Command line
-
hf download hf://spaces/ayushparwal2004/youtubeVideoSummarizer/checking.py
-
curl -L -o checking.py https://huggingface.co/spaces/ayushparwal2004/youtubeVideoSummarizer/resolve/main/checking.py
753 Bytes
| ## this file is used to check the url of the youtube video summarizer. | |
| import re | |
| def extract_video_id(url): | |
| regex = r"(?:youtube\.com\/(?:.*[?&]v=|embed\/|v\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})" | |
| match = re.search(regex, url) | |
| if match: | |
| return match.group(1) | |
| return None | |
| # Test cases | |
| urls = [ | |
| "https://www.youtube.com/watch?v=FooC7gp4wk4", | |
| "https://youtu.be/FooC7gp4wk4", | |
| "https://www.youtube.com/embed/FooC7gp4wk4", | |
| "https://www.youtube.com/v/FooC7gp4wk4", | |
| "https://www.youtube.com/shorts/FooC7gp4wk4", | |
| "https://www.youtube.com/watch?v=Bar12345678&ab_channel=Example" | |
| ] | |
| for url in urls: | |
| print(f"{url} -> {extract_video_id(url)}") # Should print the 11-character video ID |