Skip to content

Commit

Permalink
[#47] Add example for filtering a search using params
Browse files Browse the repository at this point in the history
  • Loading branch information
tombulled committed Nov 13, 2023
1 parent 0243e86 commit 8a64cbc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/filter-search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from innertube import InnerTube

PARAMS_TYPE_VIDEO = "EgIQAQ%3D%3D"
PARAMS_TYPE_CHANNEL = "EgIQAg%3D%3D"
PARAMS_TYPE_PLAYLIST = "EgIQAw%3D%3D"
PARAMS_TYPE_FILM = "EgIQBA%3D%3D"

client = InnerTube("WEB", "2.20230920.00.00")

data = client.search("arctic monkeys", params=PARAMS_TYPE_PLAYLIST)

items = data["contents"]["twoColumnSearchResultsRenderer"]["primaryContents"][
"sectionListRenderer"
]["contents"][0]["itemSectionRenderer"]["contents"]

for item in items:
playlist = item["playlistRenderer"]

playlist_id = playlist["playlistId"]
playlist_title = playlist["title"]["simpleText"]
playlist_video_count = playlist["videoCount"]

print(f"[{playlist_id}] {playlist_title} ({playlist_video_count} videos)")

0 comments on commit 8a64cbc

Please sign in to comment.