Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,5 @@
|
|
1 |
|
2 |
-
#
|
3 |
|
4 |
-
Fix these riot errors:
|
5 |
-
|
6 |
-
Remove the unused keyword argument in Interface:
|
7 |
-
gr.Interface(fn=transcript_extract, inputs="textbox", outputs="textbox").launch(share=True)
|
8 |
-
|
9 |
-
Specify the expected number of arguments for the function "transcript_extract":
|
10 |
-
warnings.warn(Expected 0 arguments for function <function transcript_extract at 0x7f3e82e2b280>, received 0)
|
11 |
-
|
12 |
-
Remove the "share" argument when launching in Spaces:
|
13 |
-
gr.Interface(fn=transcript_extract, inputs="textbox", outputs="textbox").launch()
|
14 |
-
#changing the code to have a Gradio Blocks App Menu on Huggingface Space prompting the channel URL
|
15 |
#importing the necessary modules
|
16 |
import os
|
17 |
import urllib.request
|
@@ -28,10 +16,10 @@ def transcript_extract():
|
|
28 |
page = urllib.request.urlopen(channel_url)
|
29 |
|
30 |
#reading the source code
|
31 |
-
data = page.read()
|
32 |
|
33 |
#creating a directory to save the transcripts
|
34 |
-
os.
|
35 |
|
36 |
#finding the transcripts
|
37 |
transcript_links = re.findall(r'(\/watch\?v=[A-Za-z0-9_.-]*)', str(data))
|
@@ -42,7 +30,7 @@ def transcript_extract():
|
|
42 |
#access the video page
|
43 |
video_page = urllib.request.urlopen(video_url)
|
44 |
#read the source code
|
45 |
-
video_data = video_page.read()
|
46 |
#find the transcript
|
47 |
transcript_link = re.findall(r'(\/timedtext_editor\?[A-Za-z0-9_.-]*)', str(video_data))
|
48 |
#check if there is a transcript available
|
@@ -50,7 +38,7 @@ def transcript_extract():
|
|
50 |
#access the transcript page
|
51 |
transcript_url ='http://www.youtube.com'+ transcript_link[0]
|
52 |
transcript_page = urllib.request.urlopen(transcript_url)
|
53 |
-
transcript_data = transcript_page.read()
|
54 |
#find the link to the transcript
|
55 |
transcript_download_link = re.findall(r'(\/api\/timedtext\?[A-Za-z0-9_.-]*)', str(transcript_data))
|
56 |
#check if the transcript is available for download
|
@@ -67,4 +55,4 @@ def transcript_extract():
|
|
67 |
print("Transcript not available for video " + link[9:])
|
68 |
|
69 |
#upload to Huggingface Space
|
70 |
-
gr.Interface(fn=transcript_extract, inputs="textbox", outputs="textbox"
|
|
|
1 |
|
|
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
#importing the necessary modules
|
4 |
import os
|
5 |
import urllib.request
|
|
|
16 |
page = urllib.request.urlopen(channel_url)
|
17 |
|
18 |
#reading the source code
|
19 |
+
data = page.read().decode("utf-8")
|
20 |
|
21 |
#creating a directory to save the transcripts
|
22 |
+
os.makedirs('Transcripts',exist_ok=True)
|
23 |
|
24 |
#finding the transcripts
|
25 |
transcript_links = re.findall(r'(\/watch\?v=[A-Za-z0-9_.-]*)', str(data))
|
|
|
30 |
#access the video page
|
31 |
video_page = urllib.request.urlopen(video_url)
|
32 |
#read the source code
|
33 |
+
video_data = video_page.read().decode("utf-8")
|
34 |
#find the transcript
|
35 |
transcript_link = re.findall(r'(\/timedtext_editor\?[A-Za-z0-9_.-]*)', str(video_data))
|
36 |
#check if there is a transcript available
|
|
|
38 |
#access the transcript page
|
39 |
transcript_url ='http://www.youtube.com'+ transcript_link[0]
|
40 |
transcript_page = urllib.request.urlopen(transcript_url)
|
41 |
+
transcript_data = transcript_page.read().decode("utf-8")
|
42 |
#find the link to the transcript
|
43 |
transcript_download_link = re.findall(r'(\/api\/timedtext\?[A-Za-z0-9_.-]*)', str(transcript_data))
|
44 |
#check if the transcript is available for download
|
|
|
55 |
print("Transcript not available for video " + link[9:])
|
56 |
|
57 |
#upload to Huggingface Space
|
58 |
+
gr.Interface(fn=transcript_extract, inputs="textbox", outputs="textbox").launch(share=True)
|