Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -71,6 +71,11 @@ def fetch_rss_feed(url):
|
|
| 71 |
response = requests.get(url)
|
| 72 |
response.raise_for_status()
|
| 73 |
root = ET.fromstring(response.content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
items = root.findall('.//item')
|
| 75 |
feed_data = []
|
| 76 |
|
|
@@ -84,8 +89,8 @@ def fetch_rss_feed(url):
|
|
| 84 |
# Handle cases where description might be None
|
| 85 |
description_text = BeautifulSoup(description.text, 'html.parser').get_text() if description is not None and description.text else "No description available"
|
| 86 |
|
| 87 |
-
# Extract image URL
|
| 88 |
-
image_url = media_content.attrib['url'] if media_content is not None and 'url' in media_content.attrib else
|
| 89 |
|
| 90 |
feed_data.append({
|
| 91 |
'title': title,
|
|
|
|
| 71 |
response = requests.get(url)
|
| 72 |
response.raise_for_status()
|
| 73 |
root = ET.fromstring(response.content)
|
| 74 |
+
|
| 75 |
+
# Extract channel-wide image URL
|
| 76 |
+
channel_image = root.find('.//image/url')
|
| 77 |
+
channel_image_url = channel_image.text if channel_image is not None else None
|
| 78 |
+
|
| 79 |
items = root.findall('.//item')
|
| 80 |
feed_data = []
|
| 81 |
|
|
|
|
| 89 |
# Handle cases where description might be None
|
| 90 |
description_text = BeautifulSoup(description.text, 'html.parser').get_text() if description is not None and description.text else "No description available"
|
| 91 |
|
| 92 |
+
# Extract image URL from media content or fallback to channel image
|
| 93 |
+
image_url = media_content.attrib['url'] if media_content is not None and 'url' in media_content.attrib else channel_image_url
|
| 94 |
|
| 95 |
feed_data.append({
|
| 96 |
'title': title,
|