Add podgrab featureset
This commit is contained in:
parent
233dd5b5c0
commit
4527504c80
5 changed files with 71 additions and 11 deletions
|
@ -351,21 +351,29 @@ def get_podcast_episodes(feed_url):
|
|||
# Check if the URL is accessible
|
||||
if head_response.status_code >= 400:
|
||||
logger.warning(f"Audio URL returned status code {head_response.status_code}: {episode['audio_url']}")
|
||||
continue
|
||||
# Instead of skipping, add the episode with error information
|
||||
episode['download_error'] = f"Server returned status code {head_response.status_code}"
|
||||
episode['status_code'] = head_response.status_code
|
||||
else:
|
||||
# Check if the content type is audio
|
||||
content_type = head_response.headers.get('Content-Type', '')
|
||||
if not content_type.startswith('audio/') and 'application/octet-stream' not in content_type:
|
||||
logger.warning(f"Audio URL has non-audio content type: {content_type}")
|
||||
# Don't skip here as some servers might not report the correct content type
|
||||
episode['download_error'] = f"Non-audio content type: {content_type}"
|
||||
else:
|
||||
# If we got here, the audio URL is valid with no issues
|
||||
episode['download_error'] = None
|
||||
episode['status_code'] = head_response.status_code
|
||||
|
||||
# Check if the content type is audio
|
||||
content_type = head_response.headers.get('Content-Type', '')
|
||||
if not content_type.startswith('audio/') and 'application/octet-stream' not in content_type:
|
||||
logger.warning(f"Audio URL has non-audio content type: {content_type}")
|
||||
# Don't skip here as some servers might not report the correct content type
|
||||
|
||||
# If we got here, the audio URL is probably valid
|
||||
# Add the episode regardless of status code
|
||||
episodes.append(episode)
|
||||
logger.debug(f"Added episode with valid audio URL: {episode['title']}")
|
||||
logger.debug(f"Added episode: {episode['title']} (Status: {episode.get('status_code')})")
|
||||
|
||||
except Exception as e:
|
||||
# If we can't validate the URL, still add the episode but log a warning
|
||||
logger.warning(f"Could not validate audio URL: {str(e)}")
|
||||
episode['download_error'] = f"Could not validate URL: {str(e)}"
|
||||
episodes.append(episode)
|
||||
logger.debug(f"Added episode with unvalidated audio URL: {episode['title']}")
|
||||
else:
|
||||
|
|
|
@ -79,6 +79,16 @@ def update_podcast(podcast_id, progress_callback=None):
|
|||
if not episodes:
|
||||
logger.warning(f"No episodes found for podcast: {podcast.title}")
|
||||
stats['feed_status'] = 'no_episodes'
|
||||
else:
|
||||
# Check if all episodes have download errors
|
||||
error_episodes = [ep for ep in episodes if ep.get('download_error')]
|
||||
if len(error_episodes) == len(episodes):
|
||||
logger.warning(f"All {len(episodes)} episodes have download errors for podcast: {podcast.title}")
|
||||
stats['feed_status'] = 'all_episodes_have_errors'
|
||||
# Store the most common error for reporting
|
||||
if error_episodes:
|
||||
stats['error_message'] = error_episodes[0].get('download_error', 'Unknown error')
|
||||
stats['status_code'] = error_episodes[0].get('status_code')
|
||||
|
||||
# Check if we need to refresh the feed URL from iTunes
|
||||
if podcast.external_id:
|
||||
|
@ -132,7 +142,9 @@ def update_podcast(podcast_id, progress_callback=None):
|
|||
episode_number=episode_data.get('episode_number'),
|
||||
guid=episode_data['guid'],
|
||||
downloaded=False,
|
||||
explicit=episode_data.get('explicit') # Explicit flag
|
||||
explicit=episode_data.get('explicit'), # Explicit flag
|
||||
download_error=episode_data.get('download_error'), # Error message if download failed
|
||||
status_code=episode_data.get('status_code') # HTTP status code
|
||||
)
|
||||
|
||||
db.session.add(episode)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue