Skip to content

Migrate to py yt search#1340

Open
nawar wants to merge 36 commits intomps-youtube:developfrom
nawar:migrate-to-py-yt-search
Open

Migrate to py yt search#1340
nawar wants to merge 36 commits intomps-youtube:developfrom
nawar:migrate-to-py-yt-search

Conversation

@nawar
Copy link

@nawar nawar commented Feb 23, 2026

Problem

The current dependency youtube-search-python has been archived since 2022 and is no longer maintained. This causes compatibility issues and prevents the library from being updated when YouTube changes their APIs.

Solution

Migrate to py-yt-search (https://github.com/AshokShau/py-yt-search), an actively maintained fork of the original library with:

  • Active development and bug fixes
  • Compatible API structure
  • Better error handling
  • Continued YouTube API support

Changes

  • requirements.txt & Pipfile: Replace youtube-search-python>=1.6.5 with py-yt-search>=0.5.7
  • mps_youtube/pafy.py: Implement async wrapper pattern using asyncio.run() to maintain synchronous API
  • Updated all search functions: search_videos(), channel_search(), playlist_search(), etc.
  • Comments API now uses yt-dlp (already a dependency) since py-yt-search lacks native comments support
  • Relaxed httpx version constraint for better compatibility

Backward Compatibility

Zero breaking changes - all function signatures remain identical
Synchronous API preserved - async implementation hidden behind wrappers
All existing code continues to work - no changes needed in command modules

Testing

  • Video search with pagination
  • Channel search
  • Playlist search
  • Search suggestions
  • Channel ID resolution
  • Application launches and plays music successfully

Migration Path

Users just need to:

pip install -r requirements.txt

iamtalhaasghar and others added 30 commits June 14, 2023 16:07
fix: no color support & suffle all bug fix
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
This adds the pip / pipx commands to upgrade all the dependencies. This makes directed actions like mps-youtube#1225 (comment) unnecessary.
* Update project URL

* Update __version__ in setup.py

This suppresses the update notifications

* help new: more accurate helptext

`help new` doesn't actually check whether there's a new version,
it shows the changelog for the latest release no matter what.
Update helptext to reflect this.
…rches to return all videos including optional filtering of search terms (mps-youtube#1282) (mps-youtube#1288)

* Updated the all_videos_from_channel function to return all videos from a channel, not just the first page of playlist results (previous method only returned up to 100 videos max).

* Updated the usersearch_id function to filter the returned videos by search term in the title or description. This restores the ability to search a user's videos.

Co-authored-by: Robert Hill <robert.hill@uphillsolutions.tech>
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
Signed-off-by: Rui Chen <rui@chenrui.dev>
…#1289)

demonstrate how to use existing mpv input bindings
iamtalhaasghar and others added 5 commits January 6, 2025 02:48
Automatically generated by python-semantic-release
* Add pyreadline3 backup import for readline

`readline` is unavailable on Windows. Without this fix, the following error occurs when attempting to launch yewtube:

```
  File "C:\Python313\Lib\site-packages\mps_youtube\commands\__init__.py", line 28, in command
    completer.add_cmd(command)
    ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'add_cmd'```

* Fix readline import handling in main.py

Handle ImportError for pyreadline3 and set has_readline flag.

---------

Co-authored-by: Talha Asghar <iamtalhaasghar@gmail.com>
- Replace youtube-search-python (archived since 2022) with actively maintained py-yt-search
- Implement synchronous wrappers using asyncio.run() to maintain backward compatibility
- Update all search/fetch functions: VideosSearch, ChannelsSearch, PlaylistsSearch, etc.
- Replace Comments API with yt-dlp (py-yt-search lacks comments support)
- Update Channel class usage for video/playlist fetching
- Relax httpx version constraint to >=0.23 for compatibility
- Tested: video search, channel search, playlist search, suggestions all working
- Zero breaking changes to public API
- Remove .venv-1/componenthandler.py from git tracking
- Update .gitignore to exclude all .venv* folders
@coderamm
Copy link

I don't see any progress on this repo, not sure if it's maintained. I forked your repo @nawar and it works for me. Do you want to instead merge the branches on your repo and maintain? If not, feel free to raise more PR on mine.

@coderamm coderamm mentioned this pull request Feb 27, 2026
@nawar
Copy link
Author

nawar commented Feb 27, 2026

@coderamm I can maintain for now. This would be the 3rd or 4th fork of this project since its inception 🤣

@iamtalhaasghar

This comment was marked as outdated.

@iamtalhaasghar
Copy link
Member

Update:
I just forked youtube-search-python and made a bug fix and its still working yewtube-search-python. Why not co-ordinate efforts to keep that library running?

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.

10 participants