Search
******

YTMusic.search(query: str, filter: str | None = None, scope: str | None = None, limit: int = 20, ignore_spelling: bool = False) -> list[dict[str, Any]]

   Search YouTube music Returns results within the provided category.

   Parameters:
      * **query** ("str") -- Query string, i.e. 'Oasis Wonderwall'

      * **filter** ("str" | "None") -- Filter for item types. Allowed
        values: "songs", "videos", "albums", "artists", "playlists",
        "community_playlists", "featured_playlists", "uploads".
        Default: Default search, including all types of items.

      * **scope** ("str" | "None") -- Search scope. Allowed values:
        "library", "uploads". Default: Search the public YouTube Music
        catalogue. Changing scope from the default will reduce the
        number of settable filters. Setting a filter that is not
        permitted will throw an exception. For uploads, no filter can
        be set. For library, community_playlists and
        featured_playlists filter cannot be set.

      * **limit** ("int") -- Number of search results to return
        Default: 20

      * **ignore_spelling** ("bool") -- Whether to ignore YTM spelling
        suggestions. If True, the exact search term will be searched
        for, and will not be corrected. This does not have any effect
        when the filter is set to "uploads". Default: False, will use
        YTM's default behavior of autocorrecting the search.

   Return type:
      "list"["dict"["str", "Any"]]

   Returns:
      List of results depending on filter. resultType specifies the
      type of item (important for default search). albums, artists and
      playlists additionally contain a browseId, corresponding to
      albumId, channelId and playlistId (browseId=`VL`+playlistId)

      Example list for default search with one result per resultType
      for brevity. Normally there are 3 results per resultType and an
      additional "thumbnails" key:

         [
           {
             "category": "Top result",
             "resultType": "video",
             "videoId": "vU05Eksc_iM",
             "title": "Wonderwall",
             "artists": [
               {
                 "name": "Oasis",
                 "id": "UCmMUZbaYdNH0bEd1PAlAqsA"
               }
             ],
             "views": "1.4M",
             "videoType": "MUSIC_VIDEO_TYPE_OMV",
             "duration": "4:38",
             "duration_seconds": 278
           },
           {
             "category": "Songs",
             "resultType": "song",
             "videoId": "ZrOKjDZOtkA",
             "title": "Wonderwall",
             "artists": [
               {
                 "name": "Oasis",
                 "id": "UCmMUZbaYdNH0bEd1PAlAqsA"
               }
             ],
             "album": {
               "name": "(What's The Story) Morning Glory? (Remastered)",
               "id": "MPREb_9nqEki4ZDpp"
             },
             "duration": "4:19",
             "duration_seconds": 259
             "isExplicit": false,
             "feedbackTokens": {
               "add": null,
               "remove": null
             }
           },
           {
             "category": "Albums",
             "resultType": "album",
             "browseId": "MPREb_IInSY5QXXrW",
             "playlistId": "OLAK5uy_kunInnOpcKECWIBQGB0Qj6ZjquxDvfckg",
             "title": "(What's The Story) Morning Glory?",
             "type": "Album",
             "artist": "Oasis",
             "year": "1995",
             "isExplicit": false
           },
           {
             "category": "Community playlists",
             "resultType": "playlist",
             "browseId": "VLPLK1PkWQlWtnNfovRdGWpKffO1Wdi2kvDx",
             "title": "Wonderwall - Oasis",
             "author": "Tate Henderson",
             "itemCount": "174"
           },
           {
             "category": "Videos",
             "resultType": "video",
             "videoId": "bx1Bh8ZvH84",
             "title": "Wonderwall",
             "artists": [
               {
                 "name": "Oasis",
                 "id": "UCmMUZbaYdNH0bEd1PAlAqsA"
               }
             ],
             "views": "386M",
             "duration": "4:38",
             "duration_seconds": 278
           },
           {
             "category": "Artists",
             "resultType": "artist",
             "browseId": "UCmMUZbaYdNH0bEd1PAlAqsA",
             "artist": "Oasis",
             "shuffleId": "RDAOkjHYJjL1a3xspEyVkhHAsg",
             "radioId": "RDEMkjHYJjL1a3xspEyVkhHAsg"
           },
           {
             "category": "Profiles",
             "resultType": "profile",
             "title": "Taylor Swift Time",
             "name": "@TaylorSwiftTime",
             "browseId": "UCSCRK7XlVQ6fBdEl00kX6pQ",
             "thumbnails": ...
           }
         ]

YTMusic.get_search_suggestions(query: str, detailed_runs: bool = False) -> list[str] | list[dict[str, Any]]

   Get Search Suggestions

   Parameters:
      * **query** ("str") -- Query string, i.e. 'faded'

      * **detailed_runs** ("bool") -- Whether to return detailed runs
        of each suggestion. If True, it returns the query that the
        user typed and the remaining suggestion along with the
        complete text (like many search services usually bold the text
        typed by the user). Default: False, returns the list of search
        suggestions in plain text.

   Return type:
      "list"["str"] | "list"["dict"["str", "Any"]]

   Returns:
      A list of search suggestions. If "detailed_runs" is False, it
      returns plain text suggestions.
         If "detailed_runs" is True, it returns a list of dictionaries
         with detailed information.

      Example response when "query" is 'fade' and "detailed_runs" is
      set to "False":

         [
           "faded",
           "faded alan walker lyrics",
           "faded alan walker",
           "faded remix",
           "faded song",
           "faded lyrics",
           "faded instrumental"
         ]

      Example response when "detailed_runs" is set to "True":

         [
           {
             "text": "faded",
             "runs": [
               {
                 "text": "fade",
                 "bold": true
               },
               {
                 "text": "d"
               }
             ],
             "fromHistory": true,
             "feedbackToken": "AEEJK..."
           },
           {
             "text": "faded alan walker lyrics",
             "runs": [
               {
                 "text": "fade",
                 "bold": true
               },
               {
                 "text": "d alan walker lyrics"
               }
             ],
             "fromHistory": false,
             "feedbackToken": None
           },
           {
             "text": "faded alan walker",
             "runs": [
               {
                 "text": "fade",
                 "bold": true
               },
               {
                 "text": "d alan walker"
               }
             ],
             "fromHistory": false,
             "feedbackToken": None
           },
           ...
         ]

YTMusic.remove_search_suggestions(suggestions: list[dict[str, Any]], indices: list[int] | None = None) -> bool

   Remove search suggestion from the user search history.

   Parameters:
      * **suggestions** ("list"["dict"["str", "Any"]]) -- The
        dictionary obtained from the "get_search_suggestions()" (with
        detailed_runs=True)`

      * **indices** ("list"["int"] | "None") -- Optional. The indices
        of the suggestions to be removed. Default: remove all
        suggestions.

   Return type:
      "bool"

   Returns:
      True if the operation was successful, False otherwise.

      Example usage:

         # Removing suggestion number 0
         suggestions = ytmusic.get_search_suggestions(query="fade", detailed_runs=True)
         success = ytmusic.remove_search_suggestions(suggestions=suggestions, indices=[0])
         if success:
             print("Suggestion removed successfully")
         else:
             print("Failed to remove suggestion")
