Skip to content

essoen/pocketcast-to-snipcast

Repository files navigation

Pocket Casts to Snipcast Integration

Automatically send your starred Pocket Casts episodes to Snipcast.io for AI-powered summarization via AWS Lambda.

Overview

This AWS Lambda function:

  • Authenticates with Pocket Casts and retrieves unplayed starred episodes
  • Sends episode URLs to Snipcast API for summarization
  • Automatically removes stars and archives processed episodes
  • Returns detailed results including success/failure counts

Prerequisites

  • Python 3.12+
  • AWS account with appropriate permissions
  • Terraform installed (for deployment)
  • Pocket Casts account
  • Snipcast.io account with API key

Local Development

  1. Clone and setup:
git clone https://github.com/essoen/pocketcast-to-snipcast
cd pocketcast-to-snipcast
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
  1. Configure environment:
cp .env.example .env
# Edit .env with your credentials
  1. Test locally:
source venv/bin/activate
python lambda_function.py

AWS Lambda Deployment

See detailed instructions in CLAUDE.md.

Quick start:

cd terraform
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your credentials
terraform init
terraform plan
terraform apply

Architecture

Components

  1. Lambda Function (lambda_function.py) - Main entry point and processing logic
  2. Pocket Casts Client (pocketcasts_client.py) - Custom API client
  3. Terraform Infrastructure (terraform/) - AWS deployment configuration

Data Flow

  1. EventBridge triggers Lambda on schedule (default: every 2 hours)
  2. Lambda authenticates with Pocket Casts
  3. Fetches starred episodes, filters for unplayed (playingStatus == 1)
  4. For each episode:
    • Constructs share URL: https://pca.st/episode/{episode_uuid}
    • Posts to Snipcast API
    • If successful: unstars and archives episode
  5. Returns JSON summary with counts and episode details

File Structure

pocketcast-to-snipcast/
├── lambda_function.py          # Main Lambda handler
├── pocketcasts_client.py       # Pocket Casts API client
├── requirements.txt            # Python dependencies
├── .env.example                # Environment variables template
├── terraform/                  # Infrastructure as Code
│   ├── main.tf
│   ├── variables.tf
│   ├── outputs.tf
│   └── terraform.tfvars.example
├── lambda-deployment/          # Deployment package (auto-generated)
├── CLAUDE.md                   # Detailed architecture guide
└── README.md                   # This file

Configuration

Environment Variables

Required:

  • POCKET_CASTS_EMAIL: Pocket Casts account email
  • POCKET_CASTS_PASSWORD: Pocket Casts account password
  • SNIPCAST_API_KEY: Snipcast.io API key

Changing Schedule

Edit terraform/terraform.tfvars:

schedule_expression = "rate(1 hour)"   # or "cron(0 12 * * ? *)"
schedule_rate = "1 hour"

Then: terraform apply

Troubleshooting

Authentication failures

  • Verify credentials in terraform.tfvars
  • Ensure using email/password (not third-party auth)

Module not found in Lambda

  • Install dependencies: cd lambda-deployment && pip install -r ../requirements.txt -t .
  • Redeploy: terraform apply

Episodes being reprocessed

  • Check CloudWatch logs for unstar/archive operation status
  • Lambda uses Pocket Casts playing status to avoid reprocessing

Viewing Logs

# Real-time logs
aws logs tail /aws/lambda/pocketcast-to-snipcast --region eu-north-1 --follow

# Get CloudWatch URL
terraform output cloudwatch_logs_url

Testing Lambda Manually

aws lambda invoke \
  --function-name pocketcast-to-snipcast \
  --region eu-north-1 \
  response.json

cat response.json | jq

Security

  • All credentials passed as environment variables
  • Terraform variables marked as sensitive = true
  • Never commit terraform.tfstate or terraform.tfvars
  • IAM role follows principle of least privilege

License

MIT License

About

Lambda that takes starred episodes from Pocketcast and pushes to Snipcast.io for summarization

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors