Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,22 +12,22 @@ import gradio as gr
|
|
| 12 |
#def transcript_extract():
|
| 13 |
|
| 14 |
#specifying the YouTube channel URL
|
| 15 |
-
|
| 16 |
|
| 17 |
#accessing the webpage
|
| 18 |
-
|
| 19 |
|
| 20 |
#reading the source code
|
| 21 |
-
|
| 22 |
|
| 23 |
#creating a directory to save the transcripts
|
| 24 |
# os.makedirs('Transcripts',exist_ok=True)
|
| 25 |
|
| 26 |
#finding the transcripts
|
| 27 |
-
|
| 28 |
|
| 29 |
#looping through each transcript to download
|
| 30 |
-
|
| 31 |
video_url = 'http://www.youtube.com'+link
|
| 32 |
#access the video page
|
| 33 |
video_page = urllib.request.urlopen(video_url)
|
|
|
|
| 12 |
#def transcript_extract():
|
| 13 |
|
| 14 |
#specifying the YouTube channel URL
|
| 15 |
+
channel_url = gr.inputs.Textbox(label="Channel URL")
|
| 16 |
|
| 17 |
#accessing the webpage
|
| 18 |
+
page = urllib.request.urlopen(channel_url)
|
| 19 |
|
| 20 |
#reading the source code
|
| 21 |
+
data = page.read().decode("utf-8")
|
| 22 |
|
| 23 |
#creating a directory to save the transcripts
|
| 24 |
# os.makedirs('Transcripts',exist_ok=True)
|
| 25 |
|
| 26 |
#finding the transcripts
|
| 27 |
+
transcript_links = re.findall(r'(\/watch\?v=[A-Za-z0-9_.-]*)', str(data))
|
| 28 |
|
| 29 |
#looping through each transcript to download
|
| 30 |
+
for link in transcript_links:
|
| 31 |
video_url = 'http://www.youtube.com'+link
|
| 32 |
#access the video page
|
| 33 |
video_page = urllib.request.urlopen(video_url)
|