Add podgrab featureset

This commit is contained in:
Cody Cook 2025-06-16 23:07:36 -07:00
commit 4527504c80
5 changed files with 71 additions and 11 deletions

View file

@ -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: