Skip to content

Conversation

Pobitro-B
Copy link

@Pobitro-B Pobitro-B commented Oct 6, 2025

Title: Migrating to yt-dlp

Shifted YouTube audio provider from pytube to yt-dlp for improved reliability, maintenance, and feature support.

Description: Modified youtube.py and logging.py, changed all uses of pytube to a similar yt-dlp implementation

  • Replaced pytube.Search and PyTube usages with yt_dlp.YoutubeDL for search and metadata extraction.
  • Updated initialization and search logic to match yt-dlp’s workflow (ytsearch5: query).
  • Removed deprecated innertube references.
  • Ensured returned Result objects preserve the same fields and data types as before.
  • Minor log-level adjustments in logging.py to silence yt-dlp internal messages.

Related Issue: migrate away from pytube #2417

Fixes #2417 — pytube dependency is no longer maintained and currently causes YouTube downloads/search to fail due to repeated HTTP 400 errors.

Motivation and Context

Pytube is outdated and unreliable, breaking frequently due to YouTube-side changes.
yt-dlp offers a stable and feature-rich alternative, ensuring consistent functionality for SpotDL’s YouTube-based downloads and searches.

This migration:

  • Restores YouTube search functionality.
  • Reduces dependency maintenance.
  • Improves resilience against API updates.

How Has This Been Tested?

Environment:

  • Windows 11
  • Python 3.13
  • yt-dlp 2025.08.27
  • SpotDL (editable install from main branch)

Tests performed:

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the CONTRIBUTING document
  • I have added tests to cover my changes
  • All new and existing tests passed

@Pobitro-B Pobitro-B changed the title migrate to yt-dlp from pytube migrate to yt-dlp from pytube / hacktoberfest Oct 6, 2025
@Pobitro-B
Copy link
Author

Increased the number of results fetched from 5 to 10 for test_youtube.py
Please review and share if any further changes are needed.

@Silverarmor Silverarmor changed the base branch from master to dev October 8, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

migrate away from pytube

1 participant