Docker and more calendar work
This commit is contained in:
parent
4527504c80
commit
f7a919ebf2
22 changed files with 2036 additions and 79 deletions
|
@ -93,9 +93,34 @@ def add_podcast():
|
|||
logger.info(f"Fetching episodes for podcast: {podcast.title} (ID: {podcast.id})")
|
||||
logger.info(f"Feed URL: {podcast.feed_url}")
|
||||
|
||||
episodes_data = get_podcast_episodes(podcast.feed_url)
|
||||
episodes_data, podcast_metadata = get_podcast_episodes(podcast.feed_url)
|
||||
logger.info(f"Found {len(episodes_data)} episodes in feed")
|
||||
|
||||
# Update podcast metadata if available from feed
|
||||
updated = False
|
||||
|
||||
# Update image URL if available
|
||||
if podcast_metadata.get('image_url') and not podcast.image_url:
|
||||
logger.info(f"Updating podcast image URL from feed: {podcast_metadata['image_url']}")
|
||||
podcast.image_url = podcast_metadata['image_url']
|
||||
updated = True
|
||||
|
||||
# Update author if available
|
||||
if podcast_metadata.get('author') and (not podcast.author or podcast.author == "Unknown Author"):
|
||||
logger.info(f"Updating podcast author from feed: '{podcast_metadata['author']}'")
|
||||
podcast.author = podcast_metadata['author']
|
||||
updated = True
|
||||
|
||||
# Update description if available
|
||||
if podcast_metadata.get('description') and not podcast.description:
|
||||
logger.info(f"Updating podcast description from feed")
|
||||
podcast.description = podcast_metadata['description']
|
||||
updated = True
|
||||
|
||||
# Commit changes if any updates were made
|
||||
if updated:
|
||||
db.session.commit()
|
||||
|
||||
episodes_added = 0
|
||||
for episode_data in episodes_data:
|
||||
# Check if episode has required fields
|
||||
|
@ -236,3 +261,27 @@ def delete_episode(episode_id):
|
|||
return jsonify({'error': str(e)}), 500
|
||||
else:
|
||||
return jsonify({'error': 'Episode file not found'}), 404
|
||||
|
||||
# Update all podcasts API
|
||||
@api_bp.route('/podcasts/update-all', methods=['POST'])
|
||||
def update_all_podcasts_api():
|
||||
"""
|
||||
Update all podcasts to fetch new episodes.
|
||||
"""
|
||||
from app.services.podcast_updater import update_all_podcasts
|
||||
from app.services.task_manager import task_manager
|
||||
|
||||
try:
|
||||
# Create a background task for updating all podcasts
|
||||
task_id = task_manager.create_task(
|
||||
'update_all',
|
||||
"Updating all podcasts",
|
||||
update_all_podcasts
|
||||
)
|
||||
|
||||
return jsonify({
|
||||
'message': 'Update of all podcasts started in the background. Check the status in the tasks panel.',
|
||||
'task_id': task_id
|
||||
})
|
||||
except Exception as e:
|
||||
return jsonify({'error': str(e)}), 500
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue