jpdiazpardo commited on
Commit
4055a7e
1 Parent(s): febac70

Create youtube.py

Browse files
Files changed (1) hide show
  1. youtube.py +13 -0
youtube.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from urllib.parse import parse_qs, urlparse
2
+
3
+ def get_youtube_video_id(url):
4
+ # Parse the URL using urlparse
5
+ parsed_url = urlparse(url)
6
+
7
+ # Extract the 'v' parameter from the query string
8
+ video_id = parse_qs(parsed_url.query).get('v')
9
+
10
+ if video_id:
11
+ return video_id[0]
12
+ else:
13
+ return None