Skip to content

Commit

Permalink
fix/channel_playlist_parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Sep 4, 2024
1 parent d9c5c27 commit cbcaf20
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions examples/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
from tutubo.models import *


def search(query, parse=False, max_res=50, live=False):
def search(query, parse=False, max_res=50):
res = {
'channels': [],
'playlists': [],
'mix': [],
'related_queries': [],
'related_videos': [],
'videos': [],
'live': []
'videos': []
}
for v in search_yt(query, parse=parse, max_res=max_res, as_dict=False):
if isinstance(v, YoutubeMixPreview):
Expand All @@ -23,17 +22,13 @@ def search(query, parse=False, max_res=50, live=False):
res["playlists"].append(v.as_dict)
elif isinstance(v, RelatedVideoPreview) or isinstance(v, RelatedVideo):
res["related_videos"].append(v.as_dict)
elif isinstance(v, VideoPreview):
if v.is_live:
res["live"].append(v.as_dict)
else:
res["videos"].append(v.as_dict)
else:
res["videos"].append(v.as_dict)
return res


from pprint import pprint

res = search("Shout TV live", parse=False, max_res=50)
res = search("rob zombie", parse=False, max_res=50)

pprint(res)
"""
Expand Down

0 comments on commit cbcaf20

Please sign in to comment.