Spaces:
Running
Running
File size: 3,216 Bytes
9244222 ef92443 72ac633 cc0613d 9244222 10cbb02 9244222 dae8a39 9244222 dae8a39 9244222 b276a18 efb41de 9244222 b276a18 655bd0a d80da81 2ecb5dd 6b98176 36f134b 880e208 b276a18 655bd0a b276a18 36f134b 6044ebd 10cbb02 87b5262 8113efd 8cc72fc 2aa172f ceb9108 10cbb02 6044ebd f8706a3 b276a18 880e208 6044ebd f8706a3 6044ebd 3d4fd71 6044ebd a71b012 c632686 6044ebd b276a18 6044ebd 880e208 6044ebd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
import gradio as gr
import urllib
from urllib.parse import urlparse, parse_qs
from playlist_duration import playlist_duration_func
from average_duration import playlist_average_duration_func
from playlists_mismatch import playlists_mismatch_func
def playlist_duration_calculator(playlist_link, calculation_type):
if calculation_type == "Total Duration":
result = playlist_duration_func(playlist_link)
return f"Total Duration: {result}"
elif calculation_type == "Average Duration":
result = playlist_average_duration_func(playlist_link)
return f"Average Duration: {result}"
playlist_link_input = gr.inputs.Textbox(label="Playlist Link")
calculation_type_input = gr.inputs.Radio(["Total Duration", "Average Duration"], label="What to calculate?")
outputs = gr.outputs.Textbox(label="Result")
heading = "YouTube Playlist Duration Calculator"
description = '''Enter a YouTube playlist link to calculate its total duration or average duration.\n
Do not enter the link of a video that belongs to that playlist.\n
Use the link in the share option of the playlist's page
'''
duration_interface = gr.Interface(
fn=playlist_duration_calculator,
inputs=[playlist_link_input, calculation_type_input],
outputs=outputs,
title=heading,
description=description,
examples=[
["https://www.youtube.com/playlist?list=PL-osiE80TeTsWmV9i9c58mdDCSskIFdDS", "Total Duration"],
["https://www.youtube.com/playlist?list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p", "Average Duration"],
],
theme="compact",
)
second_heading = "YouTube Playlist Mismatch Calculator"
second_description = "Enter two YouTube playlist links (without quotation marks) to compare their contents and find the mismatch."
mismatch_outputs = gr.outputs.Textbox(label="Mismatch between two playlists")
def playlist_mismatch_calculator(playlist_link_1, playlist_link_2, output_options):
result = playlists_mismatch_func(playlist_link_1, playlist_link_2, output_options)
playlist1name = result[2]
playlist2name = result[3]
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]))
return f"Mismatch Result between the two playlists are as follows: -\n\n {text}"
playlist_link_1_input = gr.inputs.Textbox(label="Playlist Link 1")
playlist_link_2_input = gr.inputs.Textbox(label="Playlist Link 2")
output_options = gr.inputs.Radio(["id", "link", "name"], label="Output Options")
mismatch_interface = gr.Interface(
fn=playlist_mismatch_calculator,
inputs=[playlist_link_1_input, playlist_link_2_input, output_options],
outputs=mismatch_outputs,
title=second_heading,
description=second_description,
# examples=[
# ["https://www.youtube.com/playlist?list=PL-osiE80TeTsWmV9i9c58mdDCSskIFdDS", "https://www.youtube.com/playlist?list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p"],
# ],
theme="compact",
)
# interface1.launch()
# interface2.launch()
combinedinterface = gr.TabbedInterface([duration_interface,mismatch_interface],['Playlist Total and Average Duration', 'Playlist Mismatch'])
combinedinterface.launch() |