charantejapolavarapu commited on
Commit
910cc1c
·
verified ·
1 Parent(s): c1dc542

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +489 -38
src/streamlit_app.py CHANGED
@@ -1,40 +1,491 @@
1
- import altair as alt
2
- import numpy as np
3
- import pandas as pd
4
  import streamlit as st
5
 
6
- """
7
- # Welcome to Streamlit!
8
-
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
-
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
- ))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
 
3
+ # --- CRITICAL: set_page_config MUST BE THE FIRST STREAMLIT COMMAND ---
4
+ st.set_page_config(
5
+ page_title="భారత్ పల్స్ (BharatPulse) - వార్తలు",
6
+ page_icon="📰",
7
+ layout="wide",
8
+ initial_sidebar_state="expanded"
9
+ )
10
+
11
+ # --- Remaining Imports (after set_page_config) ---
12
+ import feedparser
13
+ import requests
14
+ from bs4 import BeautifulSoup
15
+ from newspaper import Article # Make sure newspaper3k and lxml_html_clean are installed
16
+ # Removed torch, transformers imports for now to simplify
17
+ import time
18
+ # Removed geocoder import for now to simplify
19
+ import json
20
+ import datetime
21
+
22
+ # --- Configuration ---
23
+ TELUGU_CATEGORIES = {
24
+ "జాతీయ వార్తలు": "National",
25
+ "రాష్ట్ర వార్తలు": "State",
26
+ "క్రైం": "Crime",
27
+ "రాజకీయాలు": "Politics",
28
+ "వ్యాపారం": "Business",
29
+ "క్రీడలు": "Sports",
30
+ "వినోదం": "Entertainment",
31
+ "ఉద్యోగాలు": "Jobs",
32
+ "వాతావరణం": "Weather",
33
+ "వైరల్": "Viral",
34
+ }
35
+
36
+ # --- RSS Feed URLs ---
37
+ # IMPORTANT: These URLs might be outdated or not provide full content.
38
+ # You might need to find current, active RSS feeds for Telugu news sources.
39
+ # Many news sites change their RSS feeds frequently or don't offer comprehensive ones.
40
+ RSS_FEEDS = {
41
+ "Sakshi": "https://www.sakshi.com/tags/rss", # Check if this still provides full content
42
+ "Eenadu": "https://www.eenadu.net/telugu-news/rss", # This URL from search might be old/unofficial.
43
+ # Add more reliable Telugu news RSS feeds here if the above don't work well
44
+ # Example: "MyNewSource": "http://mynewsource.com/rss_feed_link",
45
+ }
46
+
47
+ # --- OpenWeatherMap API Configuration (for Realtime Weather) ---
48
+ # YOUR ACTUAL API KEY IS SET HERE:
49
+ OPENWEATHERMAP_API_KEY = "52f888dddede635f9b1d8a08141b5c49"
50
+ OPENWEATHERMAP_API_URL = "http://api.openweathermap.org/data/2.5/weather"
51
+
52
+ # --- Dummy Translation Function (Translation is temporarily disabled) ---
53
+ def translate_en_to_te(text):
54
+ return text # Just return the original text
55
+
56
+ # --- RSS Feed Fetching and Parsing (Cached for performance) ---
57
+ @st.cache_data(ttl=3600) # Cache for 1 hour to reduce API calls to news sites
58
+ def get_news_from_rss(url):
59
+ try:
60
+ feed = feedparser.parse(url)
61
+ articles = []
62
+ for entry in feed.entries:
63
+ title = entry.title if hasattr(entry, 'title') else ""
64
+ link = entry.link if hasattr(entry, 'link') else "#"
65
+ summary = entry.summary if hasattr(entry, 'summary') and entry.summary.strip() else ""
66
+ published = entry.published if hasattr(entry, 'published') else "N/A"
67
+ image_url = None
68
+
69
+ # Attempt to find image from media_content (common in some RSS feeds)
70
+ if hasattr(entry, 'media_content') and entry.media_content:
71
+ for media in entry.media_content:
72
+ if 'url' in media and media.get('type', '').startswith('image'):
73
+ image_url = media['url']
74
+ break
75
+ # Attempt to find image from description HTML (common in others)
76
+ elif hasattr(entry, 'description'):
77
+ soup = BeautifulSoup(entry.description, 'html.parser')
78
+ img_tag = soup.find('img')
79
+ if img_tag and 'src' in img_tag.attrs:
80
+ image_url = img_tag['src']
81
+
82
+ # Fallback to newspaper3k for better image/summary extraction from the article link
83
+ if link and "http" in link and link != "#" and (not image_url or not summary):
84
+ try:
85
+ article_parser = Article(link)
86
+ article_parser.download()
87
+ article_parser.parse()
88
+ if not image_url and article_parser.top_image:
89
+ image_url = article_parser.top_image
90
+ if not summary and article_parser.text:
91
+ summary = article_parser.text[:200] + "..." if len(article_parser.text) > 200 else article_parser.text
92
+
93
+ except Exception as e:
94
+ pass # Silently fail if newspaper3k can't extract
95
+
96
+ if title.strip() and link.strip() != "#":
97
+ articles.append({
98
+ "title": title,
99
+ "link": link,
100
+ "summary": summary,
101
+ "published": published,
102
+ "image_url": image_url,
103
+ "translated_title": None # Placeholder, will just be original title
104
+ })
105
+ return articles
106
+ except Exception as e:
107
+ st.error(f"Error fetching news from {url}: {e}")
108
+ return []
109
+
110
+ # --- Voice Search (Placeholder - requires a separate library/API) ---
111
+ def voice_search_widget():
112
+ st.write("### 🎙️ వాయిస్ సెర్చ్ (Voice Search)")
113
+ st.warning("Voice search integration with Whisper requires external setup (e.g., a local Whisper model, an API, or a custom Streamlit component). This is a placeholder.")
114
+ audio_file = st.file_uploader("Upload an audio file (e.g., .wav, .mp3) for transcription:", type=["wav", "mp3"])
115
+ if audio_file:
116
+ st.audio(audio_file, format="audio/wav")
117
+ st.info("Transcribing audio... (This is a mock transcription)")
118
+ st.write("ట్రాన్స్క్రిప్షన్: ఇది వాయిస్ సెర్చ్ కోసం ఒక నకిలీ ట్రాన్స్క్రిప్షన్ (Transcription: This is a mock transcription for voice search)")
119
+
120
+ # --- Hardcoded Location (Bypasses ipinfo.io issues) ---
121
+ @st.cache_data(ttl=3600)
122
+ def get_user_location():
123
+ return "Hyderabad", "Telangana", "India"
124
+
125
+ # --- Weather Integration ---
126
+ @st.cache_data(ttl=600)
127
+ def get_current_weather(city_name, api_key):
128
+ if not api_key: # Check if API key is empty or None
129
+ return None
130
+
131
+ params = {
132
+ 'q': city_name,
133
+ 'appid': api_key,
134
+ 'units': 'metric',
135
+ 'lang': 'te'
136
+ }
137
+ try:
138
+ response = requests.get(OPENWEATHERMAP_API_URL, params=params)
139
+ response.raise_for_status()
140
+ weather_data = response.json()
141
+
142
+ main_weather = weather_data['weather'][0]['description'] if weather_data.get('weather') else "N/A"
143
+ temperature = weather_data['main']['temp']
144
+ feels_like = weather_data['main']['feels_like']
145
+ humidity = weather_data['main']['humidity']
146
+ wind_speed = weather_data['wind']['speed']
147
+
148
+ weather_info = {
149
+ "description": main_weather.capitalize(),
150
+ "temperature": temperature,
151
+ "feels_like": feels_like,
152
+ "humidity": humidity,
153
+ "wind_speed": wind_speed
154
+ }
155
+ return weather_info
156
+ except requests.exceptions.RequestException as e:
157
+ st.error(f"Error fetching weather for {city_name}: {e}. This might be due to an invalid city name or network issues.")
158
+ return None
159
+ except json.JSONDecodeError:
160
+ st.error(f"Error decoding weather data for {city_name}. Invalid response from API.")
161
+ return None
162
+ except KeyError as e:
163
+ st.error(f"Missing key in weather data for {city_name}: {e}. API response might be incomplete or unexpected.")
164
+ return None
165
+
166
+ # --- Custom CSS for card-like appearance, horizontal scrolling (no background color) ---
167
+ st.markdown("""
168
+ <style>
169
+ /* Streamlit Tabs Styling */
170
+ .stTabs [data-baseweb="tab-list"] button {
171
+ padding: 10px 15px;
172
+ font-size: 16px;
173
+ }
174
+ .stTabs [data-baseweb="tab-list"] {
175
+ gap: 15px;
176
+ flex-wrap: nowrap;
177
+ overflow-x: auto;
178
+ -webkit-overflow-scrolling: touch;
179
+ scrollbar-width: thin;
180
+ scrollbar-color: #ccc #f1f1f1;
181
+ }
182
+ .stTabs [data-baseweb="tab-list"]::-webkit-scrollbar {
183
+ height: 6px;
184
+ }
185
+ .stTabs [data-baseweb="tab-list"]::-webkit-scrollbar-thumb {
186
+ background-color: #ccc;
187
+ border-radius: 3px;
188
+ }
189
+ .stTabs [data-baseweb="tab-list"]::-webkit-scrollbar-track {
190
+ background-color: #f1f1f1;
191
+ }
192
+
193
+ /* News Card Styling */
194
+ .news-card {
195
+ border: 1px solid #ddd;
196
+ border-radius: 8px;
197
+ padding: 15px;
198
+ margin-bottom: 20px;
199
+ box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
200
+ display: flex;
201
+ flex-direction: column;
202
+ height: 100%;
203
+ background-color: #ffffff;
204
+ }
205
+ .news-card img {
206
+ max-width: 100%;
207
+ height: 200px;
208
+ object-fit: cover;
209
+ border-radius: 4px;
210
+ margin-bottom: 10px;
211
+ }
212
+ .news-card h3 {
213
+ font-size: 1.2em;
214
+ margin-bottom: 5px;
215
+ min-height: 2.4em;
216
+ display: -webkit-box;
217
+ -webkit-line-clamp: 2;
218
+ -webkit-box-orient: vertical;
219
+ overflow: hidden;
220
+ text-overflow: ellipsis;
221
+ }
222
+ .news-card p {
223
+ font-size: 0.9em;
224
+ color: #555;
225
+ flex-grow: 1;
226
+ min-height: 4.5em;
227
+ display: -webkit-box;
228
+ -webkit-line-clamp: 3;
229
+ -webkit-box-orient: vertical;
230
+ overflow: hidden;
231
+ text-overflow: ellipsis;
232
+ }
233
+ .news-card a {
234
+ text-decoration: none;
235
+ color: #007bff;
236
+ font-weight: bold;
237
+ margin-top: auto;
238
+ }
239
+ .news-card a:hover {
240
+ text_decoration: underline;
241
+ }
242
+
243
+ /* For horizontal scrolling category buttons (using st.radio) */
244
+ .stRadio > label {
245
+ margin-right: 15px;
246
+ padding: 8px 12px;
247
+ border: 1px solid #007bff;
248
+ border-radius: 20px;
249
+ cursor: pointer;
250
+ background-color: #f0f8ff;
251
+ white-space: nowrap;
252
+ }
253
+ .stRadio > label:hover {
254
+ background-color: #e0f0ff;
255
+ }
256
+ /* Style for the selected radio button */
257
+ .stRadio [aria-checked="true"] > div:first-child {
258
+ background-color: #007bff !important;
259
+ color: white !important;
260
+ border-color: #007bff !important;
261
+ }
262
+
263
+ /* Make the radio button container scrollable */
264
+ div[data-testid="stRadio"] > div {
265
+ flex-wrap: nowrap;
266
+ overflow-x: auto;
267
+ -webkit-overflow-scrolling: touch;
268
+ scrollbar-width: thin;
269
+ scrollbar-color: #ccc #f1f1f1;
270
+ }
271
+ div[data-testid="stRadio"] > div::-webkit-scrollbar {
272
+ height: 6px;
273
+ }
274
+ div[data-testid="stRadio"] > div::-webkit-scrollbar-thumb {
275
+ background-color: #ccc;
276
+ border-radius: 3px;
277
+ }
278
+ div[data-testid="stRadio"] > div::-webkit-scrollbar-track {
279
+ background-color: #f1f1f1;
280
+ }
281
+
282
+ </style>
283
+ """, unsafe_allow_html=True)
284
+
285
+
286
+ st.title("భారత్ పల్స్ (BharatPulse) 🇮🇳")
287
+ st.markdown("మీ స్థానిక మరియు జాతీయ వార్తల వన్-స్టాప్ మూలం (Your one-stop source for local and national news)")
288
+
289
+ # Add "User Profile" to the main tabs
290
+ main_tabs = st.tabs(["📰 Headlines", "📍 My Location", "🔍 Search City", "🎙️ Voice Search", "👤 User Profile"])
291
+
292
+ # Initialize session state variables for user profile details
293
+ if 'user_name' not in st.session_state:
294
+ st.session_state.user_name = ""
295
+ if 'user_email' not in st.session_state:
296
+ st.session_state.user_email = ""
297
+ if 'user_location' not in st.session_state:
298
+ st.session_state.user_location = ""
299
+ if 'account_creation_date' not in st.session_state:
300
+ st.session_state.account_creation_date = "N/A"
301
+
302
+ # --- Tab 1: Headlines ---
303
+ with main_tabs[0]:
304
+ st.header("ప్రధాన వార్తలు (Headlines)")
305
+
306
+ # Category selection for filtering
307
+ st.markdown("##### వార్తల విభాగాలు (News Categories)")
308
+ selected_category_tl = st.radio(
309
+ "విభాగం ఎంచుకోండి (Select Category):",
310
+ options=list(TELUGU_CATEGORIES.keys()),
311
+ index=0,
312
+ horizontal=True,
313
+ key="headlines_category_select"
314
+ )
315
+ st.markdown(f"**ఎంచుకున్న విభాగం:** {selected_category_tl}")
316
+
317
+ st.markdown("---")
318
+
319
+ all_articles = []
320
+ with st.spinner("వార్తలను లోడ్ చేస్తోంది... (Loading news...)"):
321
+ for source_name, rss_url in RSS_FEEDS.items():
322
+ st.markdown(f"**{source_name} నుండి వార్తలు**")
323
+ articles = get_news_from_rss(rss_url)
324
+
325
+ for article in articles:
326
+ # Since translation is disabled, translated_title is just the original title
327
+ article['translated_title'] = article['title']
328
+
329
+ all_articles.extend(articles)
330
+
331
+ if not all_articles:
332
+ st.warning("వార్తలు లోడ్ చేయబడలేదు. దయచేసి మీ RSS ఫీడ్ URLలను తనిఖి చేయండి లేదా ఇంటర్నెట్ కనెక్షన్\u200cని తనిఖి చేయండి. (No news loaded. Please check your RSS feed URLs or internet connection.)")
333
+
334
+ if all_articles:
335
+ num_cols = 3
336
+ rows = []
337
+ for i in range(0, len(all_articles), num_cols):
338
+ rows.append(all_articles[i:i + num_cols])
339
+
340
+ for row_articles in rows:
341
+ cols = st.columns(num_cols)
342
+ for i, article in enumerate(row_articles):
343
+ with cols[i]:
344
+ with st.container():
345
+ st.markdown(f'<div class="news-card">', unsafe_allow_html=True)
346
+ if article['image_url']:
347
+ st.image(article['image_url'], use_column_width="always", caption="")
348
+
349
+ st.markdown(f"### {article['title']}") # Always display original title
350
+
351
+ st.markdown(f"<p>{article['summary']}</p>", unsafe_allow_html=True)
352
+ st.markdown(f"[పూర్తిగా చదవండి (Read More)]({article['link']})", unsafe_allow_html=True)
353
+ st.markdown('</div>', unsafe_allow_html=True)
354
+
355
+
356
+ # --- Tab 2: My Location ---
357
+ with main_tabs[1]:
358
+ st.header("📍 నా స్థానం (My Location)")
359
+
360
+ user_city, user_state, user_country = get_user_location()
361
+ st.write(f"మీ ప్రస్తుత స్థానం: **{user_city}, {user_state}, {user_country}**")
362
+
363
+ st.subheader("నిజ-సమయ వాతావరణం + హెచ్చరికలు (Real-time Weather + Alerts)")
364
+
365
+ weather_data = get_current_weather(user_city, OPENWEATHERMAP_API_KEY)
366
+ if weather_data:
367
+ st.metric(label="ఉష్ణోగ్రత (Temperature)", value=f"{weather_data['temperature']:.1f}°C", delta=f"Feels like {weather_data['feels_like']:.1f}°C")
368
+ st.write(f"**పరిస్థితి (Condition):** {weather_data['description']}")
369
+ st.write(f"**తేమ (Humidity):** {weather_data['humidity']}%")
370
+ st.write(f"**గాలి వేగం (Wind Speed):** {weather_data['wind_speed']:.1f} m/s")
371
+ st.info(f"'{user_city}' కోసం ప్రస్తుత వాతావరణం. (Current weather for '{user_city}').")
372
+ else:
373
+ st.info(f"'{user_city}' కోసం వాతావరణ డేటా అందుబాటులో లేదు. (Weather data not available for '{user_city}').")
374
+
375
+ st.subheader("స్థానిక వార్తలు (Local News)")
376
+ st.info(f"'{user_city}' కు సంబంధించిన స్థానిక వార్తలు ఇక్కడ ప్రదర్శించబడతాయి. (Local news for '{user_city}' will be displayed here.)")
377
+
378
+ st.subheader("అలర్ట్స్ (Alerts)")
379
+ st.info("స్థానిక హెచ్చరికలు ఇక్కడ ప్రదర్శించబడతాయి. (Local alerts will be displayed here.)")
380
+
381
+
382
+ # --- Tab 3: Search City ---
383
+ with main_tabs[2]:
384
+ st.header("🔍 నగరాన్ని శోధించండి (Search City)")
385
+
386
+ search_city = st.text_input("నగరం లేదా జిల్లా పేరును నమోదు చేయండి (Enter City or District Name):", "హైదరాబాద్", key="city_search_input")
387
+
388
+ if st.button("వార్తలు శోధించండి (Search News)", key="search_city_button"):
389
+ st.write(f"**'{search_city}'** కోసం వార్తలు లోడ్ అవుతున్నాయి... (Loading news for '{search_city}')...")
390
+
391
+ st.subheader(f"వాతావరణం: {search_city} (Weather: {search_city})")
392
+
393
+ weather_data_search = get_current_weather(search_city, OPENWEATHERMAP_API_KEY)
394
+ if weather_data_search:
395
+ st.metric(label="ఉష్ణోగ్రత (Temperature)", value=f"{weather_data_search['temperature']:.1f}°C", delta=f"Feels like {weather_data_search['feels_like']:.1f}°C")
396
+ st.write(f"**పరిస్థితి (Condition):** {weather_data_search['description']}")
397
+ st.write(f"**తేమ (Humidity):** {weather_data_search['humidity']}%")
398
+ st.write(f"**గాలి వేగం (Wind Speed):** {weather_data_search['wind_speed']:.1f} m/s")
399
+ else:
400
+ st.info(f"'{search_city}' కోసం వాతావరణ డేటా అందుబాటులో లేదు. (Weather data not available for '{search_city}').")
401
+
402
+ st.subheader(f"స్థానిక వార్తలు: {search_city} (Local News: {search_city})")
403
+ st.warning("ఈ ఫీచర్ కోసం స్థానిక వార్తా వనరులను అనుసంధానించడం అవసరం. (This feature requires integration with local news sources.)")
404
+ st.info(f"'{search_city}' కు సంబంధించిన వార్తలు ఇక్కడ ప్రదర్శించబడతాయి. (News for '{search_city}' will be displayed here.)")
405
+
406
+
407
+ # --- Tab 4: Voice Search ---
408
+ with main_tabs[3]:
409
+ voice_search_widget()
410
+
411
+ # --- Tab 5: User Profile (New Tab) ---
412
+ with main_tabs[4]:
413
+ st.header("👤 యూజర్ ప్రొఫైల్ (User Profile)")
414
+ st.markdown("మీ ప్రొఫైల్ వివరాలు మరియు యాప్ వినియోగ విశ్లేషణలు (Your profile details and app usage analytics)")
415
+
416
+ # User Input for Personal Details
417
+ st.subheader("వ్యక్తిగత వివరాలు (Personal Details)")
418
+
419
+ st.session_state.user_name = st.text_input(
420
+ "పేరు (Name):",
421
+ value=st.session_state.user_name,
422
+ placeholder="మీ పేరు నమోదు చేయండి (Enter your name)",
423
+ key="profile_name"
424
+ )
425
+ st.session_state.user_email = st.text_input(
426
+ "ఇమెయిల్ (Email):",
427
+ value=st.session_state.user_email,
428
+ placeholder="మీ ఇమెయిల్ నమోదు చేయండి (Enter your email)",
429
+ key="profile_email"
430
+ )
431
+ st.session_state.user_location = st.text_input(
432
+ "స్థానం (Location):",
433
+ value=st.session_state.user_location,
434
+ placeholder="మీ స్థాన�� నమోదు చేయండి (Enter your location)",
435
+ key="profile_location"
436
+ )
437
+
438
+ if st.session_state.account_creation_date == "N/A" and st.session_state.user_name:
439
+ st.session_state.account_creation_date = datetime.date.today().strftime("%B %d, %Y")
440
+
441
+ st.write(f"**ఖాతా సృష్టించిన తేదీ (Account Created On):** {st.session_state.account_creation_date}")
442
+
443
+ st.markdown("---")
444
+
445
+ st.subheader("యాప్ వినియోగం (App Usage)")
446
+
447
+ st.markdown("###### మీ వీక్షణలు (Your Views):")
448
+ st.info("ఈ విభాగానికి వాస్తవ వినియోగదారు డేటా నిల్వ అవసరం. ఇవి ఉదాహరణ పాయింట్లు. (This section requires actual user data storage. These are example points.)")
449
+
450
+ st.markdown("""
451
+ <ul>
452
+ <li><b>చూసిన వార్తల సంఖ్య (Articles Viewed):</b> 150+</li>
453
+ <li><b>అత్యంత ఎక్కువగా చూసిన వర్గం (Most Viewed Category):</b> రాజకీయాలు (Politics)</li>
454
+ <li><b>అత్యంత ఎక్కువగా చూసిన మూలం (Most Viewed Source):</b> సాక్షి (Sakshi)</li>
455
+ <li><b>చివరిగా చూసిన వార్త (Last Viewed Article):</b> "హైదరాబాద్‌లో కొత్త వంతెన నిర్మాణం" (New Bridge Construction in Hyderabad)</li>
456
+ <li><b>అనువాదాలను ఉపయోగించిన సంఖ్య (Translations Used):</b> 0 సార్లు (0 times)</li>
457
+ </ul>
458
+ """, unsafe_allow_html=True)
459
+
460
+ st.markdown("---")
461
+
462
+ st.subheader("ప్రాధాన్యతలు (Preferences)")
463
+ st.write("వార్తల వర్గం ప్రాధాన్యతలు (Preferred News Categories):")
464
+ preferred_categories = st.multiselect(
465
+ "మీ ప్రాధాన్యత గల వర్గాలను ఎంచుకోండి (Select your preferred categories):",
466
+ options=list(TELUGU_CATEGORIES.keys()),
467
+ default=["జాతీయ వార్తలు", "రాష్ట్ర వార్తలు", "వ్యాపారం"]
468
+ )
469
+ st.write(f"మీరు ఎంచుకున్నవి: {', '.join(preferred_categories)}")
470
+
471
+ st.write("వార్తా మూలాల ప్రాధాన్యతలు (Preferred News Sources):")
472
+ preferred_sources = st.multiselect(
473
+ "మీ ప్రాధాన్యత గల వార్తా మూలాలను ఎంచుకోండి (Select your preferred news sources):",
474
+ options=list(RSS_FEEDS.keys()),
475
+ default=["Sakshi"]
476
+ )
477
+ st.write(f"మీరు ఎంచుకున్నవి: {', '.join(preferred_sources)}")
478
+
479
+ st.info("ఈ ప్రాధాన్యతలు భవిష్యత్తులో మీ వార్తల ఫీడ్‌ను వ్యక్తిగతీకరించడానికి ఉపయోగించబడతాయి. (These preferences will be used to personalize your news feed in the future.)")
480
+
481
+ st.sidebar.title("భారత్ పల్స్ - సెట్టింగ్‌లు")
482
+ st.sidebar.info("ఇక్కడ మీరు యాప్ సెట్టింగ్‌లను కాన్ఫిగర్ చేయవచ్చు. (Here you can configure app settings.)")
483
+
484
+ if st.sidebar.button("రీఫ్రెష్ వార్తలు", key="refresh_news_button"):
485
+ st.cache_data.clear() # Clear all data caches (news, location, weather)
486
+ # st.cache_resource.clear() # Commented out as translation model is removed
487
+ st.rerun() # Rerun the app to load fresh data
488
+ st.sidebar.success("వార్తలు రీఫ్రెష్ చేయబడ్డాయి!")
489
+
490
+ st.sidebar.markdown("---")
491
+ st.sidebar.markdown("© 2025 భారత్ పల్స్")