DebasishDhal99 commited on
Commit
e2f4294
·
verified ·
1 Parent(s): ecf6dca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -34
app.py CHANGED
@@ -14,61 +14,51 @@ def playlist_duration_calculator(playlist_link, calculation_type):
14
  result = playlist_average_duration_func(playlist_link)
15
  return f"Average Duration: {result}"
16
 
17
- playlist_link_input = gr.inputs.Textbox(label="Playlist Link")
18
- calculation_type_input = gr.inputs.Radio(["Total Duration", "Average Duration"], label="What to calculate?")
19
- outputs = gr.outputs.Textbox(label="Result")
20
-
21
  heading = "YouTube Playlist Duration Calculator"
22
  description = '''Enter a YouTube playlist link to calculate its total duration or average duration.\n
23
  Do not enter the link of a video that belongs to that playlist.\n
24
  Use the link in the share option of the playlist's page
25
  '''
26
 
27
-
28
  duration_interface = gr.Interface(
29
  fn=playlist_duration_calculator,
30
- inputs=[playlist_link_input, calculation_type_input],
31
- outputs=outputs,
 
 
 
32
  title=heading,
33
- description=description,
34
- # examples=[
35
- # ["https://www.youtube.com/playlist?list=PL-osiE80TeTsWmV9i9c58mdDCSskIFdDS", "Total Duration"],
36
- # ["https://www.youtube.com/playlist?list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p", "Average Duration"],
37
- # ],
38
- theme="compact",
39
  )
40
 
41
  second_heading = "YouTube Playlist Mismatch Calculator"
42
- second_description = "Enter two YouTube playlist links (without quotation marks) to compare their contents and find the mismatch."
43
- mismatch_outputs = gr.outputs.Textbox(label="Mismatch between two playlists")
44
 
45
  def playlist_mismatch_calculator(playlist_link_1, playlist_link_2, output_options):
46
  result = playlists_mismatch_func(playlist_link_1, playlist_link_2, output_options)
47
  playlist1name = result[2]
48
  playlist2name = result[3]
49
- text = 'Present in {}, not in {} :- \n{} \n \nPresent in {}, not in {} :-\n {}'.format(result[2],result[3], '\n'.join(result[0]), result[3], result[2], '\n'.join(result[1]))
50
- return f"Mismatch Result between the two playlists are as follows: -\n\n {text}"
51
-
52
- playlist_link_1_input = gr.inputs.Textbox(label="Playlist Link 1")
53
- playlist_link_2_input = gr.inputs.Textbox(label="Playlist Link 2")
54
- output_options = gr.inputs.Radio(["id", "link", "name"], label="Output Options")
55
 
56
  mismatch_interface = gr.Interface(
57
  fn=playlist_mismatch_calculator,
58
- inputs=[playlist_link_1_input, playlist_link_2_input, output_options],
59
- outputs=mismatch_outputs,
 
 
 
 
60
  title=second_heading,
61
- description=second_description,
62
- # examples=[
63
- # ["https://www.youtube.com/playlist?list=PL-osiE80TeTsWmV9i9c58mdDCSskIFdDS", "https://www.youtube.com/playlist?list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p"],
64
- # ],
65
- theme="compact",
66
  )
67
 
 
 
 
 
68
 
69
- # interface1.launch()
70
- # interface2.launch()
71
-
72
- combinedinterface = gr.TabbedInterface([duration_interface,mismatch_interface],['Playlist Total and Average Duration', 'Playlist Mismatch'])
73
-
74
- combinedinterface.launch()
 
14
  result = playlist_average_duration_func(playlist_link)
15
  return f"Average Duration: {result}"
16
 
 
 
 
 
17
  heading = "YouTube Playlist Duration Calculator"
18
  description = '''Enter a YouTube playlist link to calculate its total duration or average duration.\n
19
  Do not enter the link of a video that belongs to that playlist.\n
20
  Use the link in the share option of the playlist's page
21
  '''
22
 
 
23
  duration_interface = gr.Interface(
24
  fn=playlist_duration_calculator,
25
+ inputs=[
26
+ gr.Textbox(label="Playlist Link"),
27
+ gr.Radio(["Total Duration", "Average Duration"], label="What to calculate?")
28
+ ],
29
+ outputs=gr.Textbox(label="Result"),
30
  title=heading,
31
+ description=description
 
 
 
 
 
32
  )
33
 
34
  second_heading = "YouTube Playlist Mismatch Calculator"
35
+ second_description = "Enter two YouTube playlist links to compare their contents and find the mismatch."
 
36
 
37
  def playlist_mismatch_calculator(playlist_link_1, playlist_link_2, output_options):
38
  result = playlists_mismatch_func(playlist_link_1, playlist_link_2, output_options)
39
  playlist1name = result[2]
40
  playlist2name = result[3]
41
+ text = 'Present in {}, not in {} :- \n{} \n \nPresent in {}, not in {} :-\n {}'.format(
42
+ playlist1name, playlist2name, '\n'.join(result[0]),
43
+ playlist2name, playlist1name, '\n'.join(result[1])
44
+ )
45
+ return f"Mismatch Result between the two playlists are as follows: -\n\n{text}"
 
46
 
47
  mismatch_interface = gr.Interface(
48
  fn=playlist_mismatch_calculator,
49
+ inputs=[
50
+ gr.Textbox(label="Playlist Link 1"),
51
+ gr.Textbox(label="Playlist Link 2"),
52
+ gr.Radio(["id", "link", "name"], label="Output Options")
53
+ ],
54
+ outputs=gr.Textbox(label="Mismatch between two playlists"),
55
  title=second_heading,
56
+ description=second_description
 
 
 
 
57
  )
58
 
59
+ combined_interface = gr.TabbedInterface(
60
+ [duration_interface, mismatch_interface],
61
+ ['Playlist Total and Average Duration', 'Playlist Mismatch']
62
+ )
63
 
64
+ combined_interface.launch()