Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Filter livestreams #171

Closed
Bluepengie opened this issue Apr 14, 2022 · 5 comments
Closed

Filter livestreams #171

Bluepengie opened this issue Apr 14, 2022 · 5 comments

Comments

@Bluepengie
Copy link

Could you add a way to filter whether a search returns a livestream or not? When searching, I don't want any livestream results.

@dscrofts
Copy link

Livestream results don't have a duration, so you can filter the results as follows:

from youtubesearchpython import *

search = VideosSearch("whatever")
results = search.result()["result"]

results_without_livestreams = [r for r in results if r["duration"]]

@Bluepengie
Copy link
Author

Works perfect. Thanks!

@mytja
Copy link
Collaborator

mytja commented Apr 15, 2022

We've recently added livestream filter:
#168

You can use it within CustomSearch by using SearchMode.livestreams as a filter. I haven't tested this myself, if it doesn't work, please comment here.

@dscrofts
Copy link

We've recently added livestream filter: #168

You can use it within CustomSearch by using SearchMode.livestreams as a filter. I haven't tested this myself, if it doesn't work, please comment here.

@mytja I tested it out and it seems to be working great. However it doesn't appear there is a way to issue a query and exclude live streams from the (video) result set. I can't find a way to do this through the regular YouTube interface anyway, and some Googling shows that people recommend filtering out results manually, e.g. YouTube Data API: Exclude livestreams from Search.list result set.

@mytja
Copy link
Collaborator

mytja commented Apr 15, 2022

I tested it out and it seems to be working great

So glad it's working for you. 💙

I can't find a way to do this through the regular YouTube interface anyway

If it isn't available in YouTube web app, we sadly cannot do anything...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants