Add podgrab featureset
This commit is contained in:
parent
095bf52a2f
commit
233dd5b5c0
33 changed files with 2315 additions and 125 deletions
|
@ -128,20 +128,60 @@ def update_podcast(podcast_id, progress_callback=None):
|
|||
published_date=episode_data.get('published_date'),
|
||||
duration=episode_data.get('duration'),
|
||||
file_size=episode_data.get('file_size'),
|
||||
season=episode_data.get('season'), # Season number
|
||||
episode_number=episode_data.get('episode_number'),
|
||||
guid=episode_data['guid'],
|
||||
downloaded=False
|
||||
downloaded=False,
|
||||
explicit=episode_data.get('explicit') # Explicit flag
|
||||
)
|
||||
|
||||
db.session.add(episode)
|
||||
stats['new_episodes'] += 1
|
||||
logger.info(f"Added new episode: {episode.title}")
|
||||
|
||||
# Auto-download if enabled
|
||||
if podcast.auto_download and episode.audio_url:
|
||||
try:
|
||||
# Need to commit first to ensure episode has an ID
|
||||
# Need to commit first to ensure episode has an ID
|
||||
db.session.commit()
|
||||
|
||||
# Check if file already exists for this episode
|
||||
try:
|
||||
from app.services.podcast_downloader import format_filename
|
||||
import os
|
||||
from app.models.settings import Settings
|
||||
|
||||
settings = Settings.query.first()
|
||||
if not settings:
|
||||
settings = Settings(
|
||||
download_path=current_app.config['DOWNLOAD_PATH'],
|
||||
naming_format="{podcast_title}/{episode_title}"
|
||||
)
|
||||
db.session.add(settings)
|
||||
db.session.commit()
|
||||
|
||||
# Use podcast's naming format if available, otherwise use global settings
|
||||
naming_format = podcast.naming_format or settings.naming_format
|
||||
|
||||
# Format filename using the naming format
|
||||
filename = format_filename(naming_format, podcast, episode)
|
||||
download_path = settings.download_path
|
||||
|
||||
# Check for common audio file extensions
|
||||
extensions = ['.mp3', '.m4a', '.ogg', '.wav']
|
||||
for ext in extensions:
|
||||
file_path = os.path.normpath(os.path.join(download_path, filename + ext))
|
||||
if os.path.exists(file_path):
|
||||
logger.info(f"Found existing file for episode: {file_path}")
|
||||
episode.downloaded = True
|
||||
episode.file_path = file_path
|
||||
db.session.commit()
|
||||
break
|
||||
|
||||
logger.info(f"Checked for existing files for episode: {episode.title}")
|
||||
except Exception as e:
|
||||
logger.error(f"Error checking for existing files for episode {episode.title}: {str(e)}")
|
||||
|
||||
# Auto-download if enabled and not already downloaded
|
||||
if podcast.auto_download and episode.audio_url and not episode.downloaded:
|
||||
try:
|
||||
download_episode(episode.id)
|
||||
stats['episodes_downloaded'] += 1
|
||||
logger.info(f"Auto-downloaded episode: {episode.title}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue