DebasishDhal99 commited on
Commit
9244222
1 Parent(s): 4f0687a

Create app.py

Browse files

Combining the two functions to create a app file.

Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from playlist_duration import playlist_duration_func
3
+ from average_duration import playlist_average_duration_func
4
+
5
+ def playlist_duration_calculator(playlist_link, calculation_type):
6
+ if calculation_type == "Total Duration":
7
+ result = total_duration_func(playlist_link)
8
+ return f"Total Duration: {result}"
9
+ elif calculation_type == "Average Duration":
10
+ result = average_duration_func(playlist_link)
11
+ return f"Average Duration: {result}"
12
+
13
+ playlist_link_input = gr.inputs.Textbox(label="Playlist Link")
14
+ calculation_type_input = gr.inputs.Radio(["Total Duration", "Average Duration"], label="What to calculate?")
15
+ outputs = gr.outputs.Textbox(label="Result")
16
+
17
+ heading = "YouTube Playlist Duration Calculator"
18
+ description = "Enter a YouTube playlist link and choose the calculation type to calculate its total duration or average duration."
19
+
20
+ gr.Interface(
21
+ fn=playlist_duration_calculator,
22
+ inputs=[playlist_link_input, calculation_type_input],
23
+ outputs=outputs,
24
+ title=heading,
25
+ description=description,
26
+ examples=[
27
+ ["https://www.youtube.com/playlist?list=PL-osiE80TeTsWmV9i9c58mdDCSskIFdDS", "Total Duration"],
28
+ ["https://www.youtube.com/playlist?list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p", "Average Duration"],
29
+ ],
30
+ theme="compact",
31
+ ).launch()