def listingtimes(input1,input2): try: cleanid = get_vid_id(str(input2)) selenium_link = make_watch_link(cleanid) cache_lasttimestamp, cache_captionsd = search_cache(cleanid) if not cache_lasttimestamp and not cache_captionsd: print("we gots to runs seleny2222") captions_present = pull_transcript(selenium_link,cleanid) if captions_present == "No": print('RRRRRRRRRRRRRRRRRRRrrr') return html.P(children='Captions are not available.', style={ 'textAlign': 'left', }) if cache_captionsd == { "." : "[00:00]" }: return html.P(children='Captions are not available.', style={ 'textAlign': 'left', }) if input1 not in cache_captionsd: return html.P(children='{} does not appear in video.'.format(input1), style={ 'textAlign': 'left', }) searchedword, list_times, lasttime = searchword_cleanlasttime(input1, cache_lasttimestamp,cache_captionsd) print('XXXXXXXXXXXXXXXXXXXXXXXX', input2) intervalm, listofintervals = makeintervals(10, lasttime) dict_raw_times, dict_count_freq = classify_times(listofintervals, list_times) listtimes = makelist_timestamps(dict_raw_times) return html.Div(listtimes, style={'width': '180', 'height': '200', 'overflow': 'scroll'}, ) except: return ""
def update_value(input1, input2): try: cleanid = get_vid_id(str(input2)) selenium_link = make_watch_link(cleanid) cache_lasttimestamp, cache_captionsd = search_cache(cleanid) if not cache_lasttimestamp and not cache_captionsd: print("we gots to runs seleny") pull_transcript(selenium_link, cleanid) # if captions_present == "No": # print('RRRRRRRRRRRRRRRRRRRrrr') # return html.P(children='Your word is not in the video.', style={ # 'textAlign': 'left', }) searchedword, list_times, lasttime = searchword_cleanlasttime( input1, cache_lasttimestamp, cache_captionsd) print("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZz", input2) buckets = make_time_buckets(cache_lasttimestamp) intervalm, listofintervals = makeintervals(buckets, lasttime) dict_raw_times, dict_count_freq = classify_times( listofintervals, list_times) xaxis, yaxis, rawtimestamps = make_x_y_values(dict_raw_times, dict_count_freq) data = [ go.Bar(x=xaxis, y=yaxis, name='{}'.format(searchedword), text=rawtimestamps, marker=dict(color='rgb(78, 150, 150)'), hoverinfo='all') ] layout = go.Layout( title='Frequency for word = " {word}" in intervals of {min} minutes ' .format(word=searchedword, min=intervalm), xaxis=dict(title='Timestamp in video'), yaxis=dict(title='Occurrence frequency of word', autotick=True), bargap=0.1) return dcc.Graph(id='freqchart', figure=go.Figure(data=data, layout=layout)) except: #return "That word is not in the video!" return " "