Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,16 @@ import urllib.request
|
|
5 |
# Replace 'YOUR_API_KEY' with your actual YouTube Data API key
|
6 |
API_KEY = os.getenv('api_key')
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
def check_cc_license(youtube_url):
|
9 |
# Extract video ID from the URL
|
10 |
-
video_id = youtube_url
|
11 |
|
12 |
# YouTube Data API URL to get video details
|
13 |
api_url = f'https://www.googleapis.com/youtube/v3/videos?id={video_id}&part=status&key={API_KEY}'
|
|
|
5 |
# Replace 'YOUR_API_KEY' with your actual YouTube Data API key
|
6 |
API_KEY = os.getenv('api_key')
|
7 |
|
8 |
+
def get_youtube_id(youtube_url):
|
9 |
+
if 'youtube.com' in youtube_url:
|
10 |
+
video_id = youtube_url.split('v=')[-1]
|
11 |
+
elif 'youtu.be' in youtube_url:
|
12 |
+
video_id = youtube_url.split('/')[-1].split('?')[0]
|
13 |
+
return video_id
|
14 |
+
|
15 |
def check_cc_license(youtube_url):
|
16 |
# Extract video ID from the URL
|
17 |
+
video_id = get_youtube_id(youtube_url)
|
18 |
|
19 |
# YouTube Data API URL to get video details
|
20 |
api_url = f'https://www.googleapis.com/youtube/v3/videos?id={video_id}&part=status&key={API_KEY}'
|