GameReview commited on
Commit
a70cd5e
1 Parent(s): ec6e4d2

Added retrieval of video details

Browse files
Files changed (1) hide show
  1. app.py +25 -10
app.py CHANGED
@@ -20,6 +20,16 @@ def get_comment_data(youtube_id):
20
  df = pd.DataFrame(comments, columns=['Comment_Text', 'Like_Count'])
21
  return df
22
 
 
 
 
 
 
 
 
 
 
 
23
  #In case we ever want all comments
24
  def get_all_comments(youtube_id):
25
  comments = [[]]
@@ -170,14 +180,19 @@ with gr.Blocks() as app:
170
  ### Insert a YouTube URL to analyze the comments and get the population's review on the game!
171
  """
172
  )
173
-
174
- input = gr.Textbox(label="YouTube URL", placeholder = "Place link here")
175
- output = gr.Textbox(label = "Community's Rating of the Game")
176
- with gr.Row():
177
- feeling1 = gr.Textbox(label="Top 3 Feelings")
178
- feeling2 = gr.Textbox(label="")
179
- feeling3 = gr.Textbox(label="")
180
- rate_btn = gr.Button("Rate!")
181
- rate_btn.click(fn=rate, inputs=input,outputs=[output,feeling1,feeling2,feeling3])
182
-
 
 
 
 
 
183
  app.launch()
 
20
  df = pd.DataFrame(comments, columns=['Comment_Text', 'Like_Count'])
21
  return df
22
 
23
+ #Get title and thumbnail
24
+ def get_vid_details(youtube_link):
25
+ youtube_id = get_video_id(youtube_link)
26
+ request = youtube_api.videos().list(
27
+ part="snippet",
28
+ id= youtube_id
29
+ )
30
+ response = request.execute()
31
+ return response['items'][0]['snippet']['title'],response['items'][0]['snippet']['thumbnails']['high']['url']
32
+
33
  #In case we ever want all comments
34
  def get_all_comments(youtube_id):
35
  comments = [[]]
 
180
  ### Insert a YouTube URL to analyze the comments and get the population's review on the game!
181
  """
182
  )
183
+ with gr.Tab("Video Rating"):
184
+ input = gr.Textbox(label="YouTube URL", placeholder = "Place link here")
185
+ output = gr.Textbox(label = "Community's Rating of the Game")
186
+ with gr.Row():
187
+ feeling1 = gr.Textbox(label="Top 3 Feelings")
188
+ feeling2 = gr.Textbox(label="")
189
+ feeling3 = gr.Textbox(label="")
190
+ rate_btn = gr.Button("Rate!")
191
+ rate_btn.click(fn=rate, inputs=input,outputs=[output,feeling1,feeling2,feeling3])
192
+ with gr.Tab("Video Details"):
193
+ input = gr.Textbox(label="Youtube URL", placeholder = "Place link here")
194
+ title = gr.Textbox(label="Title")
195
+ thumbnail = gr.Image()
196
+ info_btn = gr.Button("Get Video Info!")
197
+ info_btn.click(fn=get_vid_details, inputs=input, outputs=[title,thumbnail])
198
  app.launch()