-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
33 lines (27 loc) · 1.82 KB
/
app.py
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
from scraper import create_yt_df
import streamlit as st
import pandas as pd
st.set_page_config(layout="wide")
st.title('My yt Links')
st.markdown('This is a simple Streamlit app with a multiselect widget and a function that returns a dataframe containing yt links.')
# serach terms
search_terms=['TheViper', 'T90Official - Age Of Empires 2', 'Spirit Of The Law','Veritasium','Gamestar','PBS Eons','Kurzgesagt – In a Nutshell',
'Hashoshi','Be Smart','Real Science','Two Minute Papers','Vsauce','Daniel Madison','BeHaind','Chris Ramsay',
'Doug Conn','Heath Cards','Mike Boyd','Siegismund']
# channel names as listed in channel_name, filtering for them will drop videos from other channels wich might occur in the search results
channel_names = ['TheViper', 'T90Official - Age Of Empires 2', 'Spirit Of The Law','Veritasium','Gamestar','PBS Eons','Kurzgesagt – In a Nutshell',
'Hashoshi','Be Smart','Real Science','Two Minute Papers','Vsauce','Daniel Madison','BeHaind','Chris Ramsay',
'Doug Conn','Heath Cards','Mike Boyd','Siegismund']
# Set the default values for the multiselect widget
default_options = st.multiselect(
'Select your search terms',search_terms
,search_terms)
# Add the text input widget to the app
# Split the input string into a list of stringszz
num_videos = st.number_input('How many searches to perform for every search?',value= 40)
# # Call the create_yt_df function and pass the results from the multiselect widget as a list
df = create_yt_df(default_options,num_videos=num_videos)
# filter the results by cahnnel names to drop search results from other channels that contain the same name
df2= df[df['channel_name'].isin(channel_names)]
# write result df to dashboard as a html file with clickable hyperlinks
st.write(df2.to_html(render_links=True,escape=False, index=False), unsafe_allow_html=True)