File size: 4,282 Bytes
f616749
 
 
 
 
 
76b4f1b
 
2c88b84
4d12526
76b4f1b
4d12526
 
2c88b84
76b4f1b
2c88b84
76b4f1b
4d12526
76b4f1b
 
4d12526
76b4f1b
4d12526
76b4f1b
 
 
 
 
4d12526
c8ec90e
4d12526
c8ec90e
 
 
 
 
 
 
76b4f1b
c8ec90e
4d12526
 
c8ec90e
 
4d12526
0b918ce
c8ec90e
4d12526
 
 
 
 
 
51ac369
4d12526
 
 
f616749
4d12526
 
 
f616749
4d12526
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0decf7e
 
 
 
76f0426
0decf7e
 
 
 
 
 
 
 
 
4d12526
 
 
 
 
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import json
import os
import feedparser
import streamlit as st
from functions import *

def main():
    st.title("PodcastGPT Dashboard")
    
    st.markdown("""
    This app assists busy professionals with transcribing and summarizing Podcasts from [Listen Notes](https://www.listennotes.com/) website by following the below steps:
    - Search for your desired podcast from the Listen Notes website and click on the "RSS" tab to generate a unique link to the podcast. Example shown below:
    """)
    
    col1, col2 = st.columns(2)
    
    with col1:
        st.image('RSS.png', caption='Click RSS')
    
    with col2:
        st.image('RSS_copy.png', caption='Copy RSS Link')
    
    st.markdown("- Copy the generated link and paste in the sidebar on the left:")
    
    # Left section - Input fields
    st.sidebar.header("Podcast RSS Feeds")
    podcast_url = st.sidebar.text_input('Please paste the podcast RSS feed link here')
    latest_ep_button = st.sidebar.button("Get latest 5 Episodes")

    if latest_ep_button or 'pods' in st.session_state:
        try:
            if latest_ep_button:
                # Parse the podcast feed and update session state
                podcast_feed = feedparser.parse(podcast_url)
                st.session_state['pods'] = {
                    pod['title']: [pod.get('links', [{}])[0].get('href', ''), pod.get('image', {}).get('href', '')] 
                    for pod in podcast_feed.entries[:5]
                }

            if st.session_state['pods']:
                # Dropdown box
                st.sidebar.subheader("Available Podcasts Feeds")
                podcast_titles = ['Select an episode'] + list(st.session_state['pods'].keys())
                selected_podcast = st.sidebar.selectbox("Select Podcast", options=podcast_titles)

                if selected_podcast and selected_podcast != 'Select an episode':
                    podcast_link, podcast_image = st.session_state['pods'][selected_podcast]

                    st.header("Newsletter Content")

                    # Display the podcast title
                    st.subheader("Episode Title")
                    st.write(selected_podcast)

                    # Display the podcast summary and the cover image
                    col1, col2 = st.columns([7, 3])
                    podcast_info = process_podcast(podcast_link)

                    with col1:
                        st.subheader("Podcast Episode Summary")
                        st.write(podcast_info['podcast_summary'])

                    if podcast_image:
                        with col2:
                            st.image(podcast_image, caption="Podcast Cover", width=300)

                    # Display the podcast guest and their details
                    col3, col4 = st.columns([3, 7])

                    with col3:
                        st.subheader("Podcast Guest")
                        st.write(podcast_info['podcast_guest'])

                    with col4:
                        st.subheader("Podcast Guest Details")
                        st.write(podcast_info["podcast_guest_title"])
                        st.write(podcast_info["podcast_guest_org"])

                    # Display the five key moments
                    st.subheader("Key Moments")
                    key_moments = podcast_info['podcast_highlights']
                    for moment in key_moments.split('\n'):
                        st.markdown(f"<p style='margin-bottom: 5px;'>{moment}</p>", unsafe_allow_html=True)

                    export_button = st.button("Export Summary to Word")

                    if export_button:
                        byte_io = export_to_word(podcast_info,selected_podcast)
    
                        # Download link for the Word document
                        st.download_button(
                            label="Download Summary",
                            data=byte_io,
                            file_name=f"{selected_podcast}_summary.docx",
                            mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
                        )
                        
        except Exception as e:
            st.sidebar.error(f"An error occurred: {e}")

if __name__ == '__main__':
    main()