
    nzhM                         S SK JrJrJr  S SKJr  S SK7  S SKJr   " S S\5      r	 " S S\5      r
 " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      rg)    )AnyDictOptional)ChannelSearchCore)*)
SearchCorec                   f   ^  \ rS rSrSrSS\S\S\S\S\\   4
U 4S jjjrS	\	\\
4   4S
 jrSrU =r$ )Search   u
  Searches for videos, channels & playlists in YouTube.

Args:
    query (str): Sets the search query.
    limit (int, optional): Sets limit to the number of results. Defaults to 20.
    language (str, optional): Sets the result language. Defaults to 'en'.
    region (str, optional): Sets the result region. Defaults to 'US'.

Examples:
    Calling `result` method gives the search result.

    >>> search = Search('Watermelon Sugar', limit = 1)
    >>> result = await search.next()
    >>> print(result)
    {
        "result": [
            {
                "type": "video",
                "id": "E07s5ZYygMg",
                "title": "Harry Styles - Watermelon Sugar (Official Video)",
                "publishedTime": "6 months ago",
                "duration": "3:09",
                "viewCount": {
                    "text": "162,235,006 views",
                    "short": "162M views"
                },
                "thumbnails": [
                    {
                        "url": "https://i.ytimg.com/vi/E07s5ZYygMg/hq720.jpg?sqp=-oaymwEjCOgCEMoBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLAOWBTE1SDrtrDQ1aWNzpDZ7YiMIw",
                        "width": 360,
                        "height": 202
                    },
                    {
                        "url": "https://i.ytimg.com/vi/E07s5ZYygMg/hq720.jpg?sqp=-oaymwEXCNAFEJQDSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLD7U54pGZLPKTuMP-J3kpm4LIDPVg",
                        "width": 720,
                        "height": 404
                    }
                ],
                "descriptionSnippet": [
                    {
                        "text": "This video is dedicated to touching. Listen to Harry Styles' new album 'Fine Line' now: https://HStyles.lnk.to/FineLineAY Follow ..."
                    }
                ],
                "channel": {
                    "name": "Harry Styles",
                    "id": "UCZFWPqqPkFlNwIxcpsLOwew",
                    "thumbnails": [
                        {
                            "url": "https://yt3.ggpht.com/a-/AOh14GgNUvHxwlnz4RpHamcGnZF1px13VHj01TPksw=s68-c-k-c0x00ffffff-no-rj-mo",
                            "width": 68,
                            "height": 68
                        }
                    ],
                    "link": "https://www.youtube.com/channel/UCZFWPqqPkFlNwIxcpsLOwew"
                },
                "accessibility": {
                    "title": "Harry Styles - Watermelon Sugar (Official Video) by Harry Styles 6 months ago 3 minutes, 9 seconds 162,235,006 views",
                    "duration": "3 minutes, 9 seconds"
                },
                "link": "https://www.youtube.com/watch?v=E07s5ZYygMg",
                "shelfTitle": null
            }
        ]
    }
querylimitlanguageregiontimeoutc                 8   > SU l         [        TU ]	  XX4S U5        g N)TTT
searchModesuper__init__selfr   r   r   r   r   	__class__s         _/home/james-whalen/.local/lib/python3.13/site-packages/youtubesearchpython/__future__/search.pyr   Search.__init__J   s    ,xwG    returnc                 >   #    U R                  5       I S h  vN $  N7fN
_nextAsyncr   s    r   nextSearch.nextN        __&&&&   r      enUSN__name__
__module____qualname____firstlineno____doc__strintr   r   r   r   r#   __static_attributes____classcell__r   s   @r   r
   r
      s_    @BHc H# Hc HRU Hgopsgt H H'DcN ' 'r   r
   c                   f   ^  \ rS rSrSrSS\S\S\S\S\\   4
U 4S jjjrS	\	\\
4   4S
 jrSrU =r$ )VideosSearchR   u
  Searches for videos in YouTube.

Args:
    query (str): Sets the search query.
    limit (int, optional): Sets limit to the number of results. Defaults to 20.
    language (str, optional): Sets the result language. Defaults to 'en'.
    region (str, optional): Sets the result region. Defaults to 'US'.

Examples:
    Calling `result` method gives the search result.

    >>> search = VideosSearch('Watermelon Sugar', limit = 1)
    >>> result = await search.next()
    >>> print(result)
    {
        "result": [
            {
                "type": "video",
                "id": "E07s5ZYygMg",
                "title": "Harry Styles - Watermelon Sugar (Official Video)",
                "publishedTime": "6 months ago",
                "duration": "3:09",
                "viewCount": {
                    "text": "162,235,006 views",
                    "short": "162M views"
                },
                "thumbnails": [
                    {
                        "url": "https://i.ytimg.com/vi/E07s5ZYygMg/hq720.jpg?sqp=-oaymwEjCOgCEMoBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLAOWBTE1SDrtrDQ1aWNzpDZ7YiMIw",
                        "width": 360,
                        "height": 202
                    },
                    {
                        "url": "https://i.ytimg.com/vi/E07s5ZYygMg/hq720.jpg?sqp=-oaymwEXCNAFEJQDSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLD7U54pGZLPKTuMP-J3kpm4LIDPVg",
                        "width": 720,
                        "height": 404
                    }
                ],
                "descriptionSnippet": [
                    {
                        "text": "This video is dedicated to touching. Listen to Harry Styles' new album 'Fine Line' now: https://HStyles.lnk.to/FineLineAY Follow ..."
                    }
                ],
                "channel": {
                    "name": "Harry Styles",
                    "id": "UCZFWPqqPkFlNwIxcpsLOwew",
                    "thumbnails": [
                        {
                            "url": "https://yt3.ggpht.com/a-/AOh14GgNUvHxwlnz4RpHamcGnZF1px13VHj01TPksw=s68-c-k-c0x00ffffff-no-rj-mo",
                            "width": 68,
                            "height": 68
                        }
                    ],
                    "link": "https://www.youtube.com/channel/UCZFWPqqPkFlNwIxcpsLOwew"
                },
                "accessibility": {
                    "title": "Harry Styles - Watermelon Sugar (Official Video) by Harry Styles 6 months ago 3 minutes, 9 seconds 162,235,006 views",
                    "duration": "3 minutes, 9 seconds"
                },
                "link": "https://www.youtube.com/watch?v=E07s5ZYygMg",
                "shelfTitle": null
            }
        ]
    }
r   r   r   r   r   c                 T   > SU l         [        TU ]	  XX4[        R                  U5        g )N)TFF)r   r   r   
SearchModevideosr   s         r   r   VideosSearch.__init__   s#    .x9J9JGTr   r   c                 >   #    U R                  5       I S h  vN $  N7fr   r    r"   s    r   r#   VideosSearch.next   r%   r&   r'   r(   r,   r6   s   @r   r8   r8   R   s_    @BUc U# Uc URU Ugopsgt U U'DcN ' 'r   r8   c                   f   ^  \ rS rSrSrSS\S\S\S\S\\   4
U 4S jjjrS	\	\\
4   4S
 jrSrU =r$ )ChannelsSearch   a  Searches for channels in YouTube.

Args:
    query (str): Sets the search query.
    limit (int, optional): Sets limit to the number of results. Defaults to 20.
    language (str, optional): Sets the result language. Defaults to 'en'.
    region (str, optional): Sets the result region. Defaults to 'US'.

Examples:
    Calling `result` method gives the search result.

    >>> search = ChannelsSearch('Harry Styles', limit = 1)
    >>> result = await search.next()
    >>> print(result)
    {
        "result": [
            {
                "type": "channel",
                "id": "UCZFWPqqPkFlNwIxcpsLOwew",
                "title": "Harry Styles",
                "thumbnails": [
                    {
                        "url": "https://yt3.ggpht.com/ytc/AAUvwnhR81ocC_KalYEk5ItnJcfMBqaiIpuM1B0lJyg4Rw=s88-c-k-c0x00ffffff-no-rj-mo",
                        "width": 88,
                        "height": 88
                    },
                    {
                        "url": "https://yt3.ggpht.com/ytc/AAUvwnhR81ocC_KalYEk5ItnJcfMBqaiIpuM1B0lJyg4Rw=s176-c-k-c0x00ffffff-no-rj-mo",
                        "width": 176,
                        "height": 176
                    }
                ],
                "videoCount": "7",
                "descriptionSnippet": null,
                "subscribers": "9.25M subscribers",
                "link": "https://www.youtube.com/channel/UCZFWPqqPkFlNwIxcpsLOwew"
            }
        ]
    }
r   r   r   r   r   c                 T   > SU l         [        TU ]	  XX4[        R                  U5        g )N)FTF)r   r   r   r;   channelsr   s         r   r   ChannelsSearch.__init__   s#    .x9L9LgVr   r   c                 >   #    U R                  5       I S h  vN $  N7fr   r    r"   s    r   r#   ChannelsSearch.next   r%   r&   r'   r(   r,   r6   s   @r   rA   rA      s^    'PWc W# Wc WRU Wgopsgt W W'DcN ' 'r   rA   c                   f   ^  \ rS rSrSrSS\S\S\S\S\\   4
U 4S jjjrS	\	\\
4   4S
 jrSrU =r$ )PlaylistsSearch   a  Searches for playlists in YouTube.

Args:
    query (str): Sets the search query.
    limit (int, optional): Sets limit to the number of results. Defaults to 20.
    language (str, optional): Sets the result language. Defaults to 'en'.
    region (str, optional): Sets the result region. Defaults to 'US'.

Examples:
    Calling `result` method gives the search result.

    >>> search = PlaylistsSearch('Harry Styles', limit = 1)
    >>> result = await search.next()
    >>> print(result)
    {
        "result": [
            {
                "type": "playlist",
                "id": "PL-Rt4gIwHnyvxpEl-9Le0ePztR7WxGDGV",
                "title": "fine line harry styles full album lyrics",
                "videoCount": "12",
                "channel": {
                    "name": "ourmemoriestonight",
                    "id": "UCZCmb5a8LE9LMxW9I3-BFjA",
                    "link": "https://www.youtube.com/channel/UCZCmb5a8LE9LMxW9I3-BFjA"
                },
                "thumbnails": [
                    {
                        "url": "https://i.ytimg.com/vi/raTh8Mu5oyM/hqdefault.jpg?sqp=-oaymwEWCKgBEF5IWvKriqkDCQgBFQAAiEIYAQ==&rs=AOn4CLCdCfOQYMrPImHMObdrMcNimKi1PA",
                        "width": 168,
                        "height": 94
                    },
                    {
                        "url": "https://i.ytimg.com/vi/raTh8Mu5oyM/hqdefault.jpg?sqp=-oaymwEWCMQBEG5IWvKriqkDCQgBFQAAiEIYAQ==&rs=AOn4CLDsKmyGH8bkmt9MzZqIoXI4UaduBw",
                        "width": 196,
                        "height": 110
                    },
                    {
                        "url": "https://i.ytimg.com/vi/raTh8Mu5oyM/hqdefault.jpg?sqp=-oaymwEXCPYBEIoBSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLD9v7S0KeHLBLr0bF-LrRjYVycUFA",
                        "width": 246,
                        "height": 138
                    },
                    {
                        "url": "https://i.ytimg.com/vi/raTh8Mu5oyM/hqdefault.jpg?sqp=-oaymwEXCNACELwBSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLAIzQIVxZsC0PfvLOt-v9UWJ-109Q",
                        "width": 336,
                        "height": 188
                    }
                ],
                "link": "https://www.youtube.com/playlist?list=PL-Rt4gIwHnyvxpEl-9Le0ePztR7WxGDGV"
            }
        ]
    }
r   r   r   r   r   c                 T   > SU l         [        TU ]	  XX4[        R                  U5        g )N)FFT)r   r   r   r;   	playlistsr   s         r   r   PlaylistsSearch.__init__  s#    .x9M9MwWr   r   c                 >   #    U R                  5       I S h  vN $  N7fr   r    r"   s    r   r#   PlaylistsSearch.next  r%   r&   r'   r(   r,   r6   s   @r   rI   rI      s^    4jXc X# Xc XRU Xgopsgt X X'DcN ' 'r   rI   c                   j   ^  \ rS rSrSrSS\S\S\S\S\S\\   4U 4S	 jjjrS
\	\\
4   4S jrSrU =r$ )CustomSearchi
  u[  Performs custom search in YouTube with search filters or sorting orders. 
Few of the predefined filters and sorting orders are:

    1 - SearchMode.videos
    2 - VideoUploadDateFilter.lastHour
    3 - VideoDurationFilter.long
    4 - VideoSortOrder.viewCount

There are many other to use.
The value of `sp` parameter in the YouTube search query can be used as a search filter e.g. 
`EgQIBRAB` from https://www.youtube.com/results?search_query=NoCopyrightSounds&sp=EgQIBRAB can be passed as `searchPreferences`, to get videos, which are uploaded this year.

Args:
    query (str): Sets the search query.
    searchPreferences (str): Sets the `sp` query parameter in the YouTube search request.
    limit (int, optional): Sets limit to the number of results. Defaults to 20.
    language (str, optional): Sets the result language. Defaults to 'en'.
    region (str, optional): Sets the result region. Defaults to 'US'.

Examples:
    Calling `result` method gives the search result.

    >>> search = CustomSearch('Harry Styles', VideoSortOrder.viewCount, limit = 1)
    >>> result = await search.next()
    >>> print(result)
    {
        "result": [
            {
                "type": "video",
                "id": "QJO3ROT-A4E",
                "title": "One Direction - What Makes You Beautiful (Official Video)",
                "publishedTime": "9 years ago",
                "duration": "3:27",
                "viewCount": {
                    "text": "1,212,146,802 views",
                    "short": "1.2B views"
                },
                "thumbnails": [
                    {
                        "url": "https://i.ytimg.com/vi/QJO3ROT-A4E/hq720.jpg?sqp=-oaymwEjCOgCEMoBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLDeFKrH99gmpnvKyG4czdd__YRDkw",
                        "width": 360,
                        "height": 202
                    },
                    {
                        "url": "https://i.ytimg.com/vi/QJO3ROT-A4E/hq720.jpg?sqp=-oaymwEXCNAFEJQDSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLBJ_wUjsRFXGsbvRpwYpSLlsGmbkw",
                        "width": 720,
                        "height": 404
                    }
                ],
                "descriptionSnippet": [
                    {
                        "text": "One Direction – What Makes You Beautiful (Official Video) Follow on Spotify - https://1D.lnk.to/Spotify Listen on Apple Music ..."
                    }
                ],
                "channel": {
                    "name": "One Direction",
                    "id": "UCb2HGwORFBo94DmRx4oLzow",
                    "thumbnails": [
                        {
                            "url": "https://yt3.ggpht.com/a-/AOh14Gj3SMvtIAvVNUrHWFTJFubPN7qozzPl5gFkoA=s68-c-k-c0x00ffffff-no-rj-mo",
                            "width": 68,
                            "height": 68
                        }
                    ],
                    "link": "https://www.youtube.com/channel/UCb2HGwORFBo94DmRx4oLzow"
                },
                "accessibility": {
                    "title": "One Direction - What Makes You Beautiful (Official Video) by One Direction 9 years ago 3 minutes, 27 seconds 1,212,146,802 views",
                    "duration": "3 minutes, 27 seconds"
                },
                "link": "https://www.youtube.com/watch?v=QJO3ROT-A4E",
                "shelfTitle": null
            }
        ]
    }
r   searchPreferencesr   r   r   r   c                 6   > SU l         [        TU ]	  XXEX&5        g r   r   )r   r   rR   r   r   r   r   r   s          r   r   CustomSearch.__init__W  s    ,x9JTr   r   c                 >   #    U R                  5       I S h  vN $  N7fr   r    r"   s    r   r#   CustomSearch.next[  r%   r&   r'   r(   r,   r6   s   @r   rQ   rQ   
  st    KXUc Uc U# UVY Ujm U  @H  IL  @M U U'DcN ' 'r   rQ   c                   R   ^  \ rS rSrSrSS\S\S\S\S\S\\   4U 4S	 jjjrS
r	U =r
$ )ChannelSearchi^  ux  Searches for videos in specific channel in YouTube.

    Args:
        query (str): Sets the search query.
        browseId (str): Channel ID
        language (str, optional): Sets the result language. Defaults to 'en'.
        region (str, optional): Sets the result region. Defaults to 'US'.

    Examples:
        Calling `result` method gives the search result.

        >>> search = ChannelSearch('Watermelon Sugar', "UCZFWPqqPkFlNwIxcpsLOwew")
        >>> result = await search.next()
        >>> print(result)
        {
            "result": [
                {
                    "id": "WMcIfZuRuU8",
                    "thumbnails": {
                        "normal": [
                            {
                                "url": "https://i.ytimg.com/vi/WMcIfZuRuU8/hqdefault.jpg?sqp=-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLClFg6C1r5NfTQy7TYUq6X5qHUmPA",
                                "width": 168,
                                "height": 94
                            },
                            {
                                "url": "https://i.ytimg.com/vi/WMcIfZuRuU8/hqdefault.jpg?sqp=-oaymwEbCMQBEG5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLAoOyftwY0jLV4geWb5hejULYp3Zw",
                                "width": 196,
                                "height": 110
                            },
                            {
                                "url": "https://i.ytimg.com/vi/WMcIfZuRuU8/hqdefault.jpg?sqp=-oaymwEcCPYBEIoBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLCdqkhn7JDwLvRtTNx3jq-olz7k-Q",
                                "width": 246,
                                "height": 138
                            },
                            {
                                "url": "https://i.ytimg.com/vi/WMcIfZuRuU8/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLAhYedsqBFKI0Ra2qzIv9cVoZhfKQ",
                                "width": 336,
                                "height": 188
                            }
                        ],
                        "rich": null
                    },
                    "title": "Harry Styles – Watermelon Sugar (Lost Tour Visual)",
                    "descriptionSnippet": "This video is dedicated to touching.
Listen to Harry Styles’ new album ‘Fine Line’ now: https://HStyles.lnk.to/FineLineAY 

Follow Harry Styles:
Facebook: https://HarryStyles.lnk.to/followFI...",
                    "uri": "/watch?v=WMcIfZuRuU8",
                    "views": {
                        "precise": "3,888,287 views",
                        "simple": "3.8M views",
                        "approximate": "3.8 million views"
                    },
                    "duration": {
                        "simpleText": "2:55",
                        "text": "2 minutes, 55 seconds"
                    },
                    "published": "10 months ago",
                    "channel": {
                        "name": "Harry Styles",
                        "thumbnails": [
                            {
                                "url": "https://yt3.ggpht.com/ytc/AAUvwnhR81ocC_KalYEk5ItnJcfMBqaiIpuM1B0lJyg4Rw=s88-c-k-c0x00ffffff-no-rj",
                                "width": 68,
                                "height": 68
                            }
                        ]
                    },
                    "type": "video"
                },
            ]
        }
    r   browseIdr   r   rR   r   c                 (   > [         TU ]  XXEX&5        g r   )r   r   )r   r   rY   r   r   rR   r   r   s          r   r   ChannelSearch.__init__  s    &XWr    )r*   r+   zEgZzZWFyY2g%3DN)r-   r.   r/   r0   r1   r2   r   r3   r   r4   r5   r6   s   @r   rX   rX   ^  s[    FPXc XS XC XPS Xor X  QY  Z]  Q^ X Xr   rX   N)typingr   r   r   &youtubesearchpython.core.channelsearchr   "youtubesearchpython.core.constantsyoutubesearchpython.core.searchr   r
   r8   rA   rI   rQ   rX   r\   r   r   <module>ra      sl    & & D 0 6G'Z G'TG': G'T.'Z .'b;'j ;'zR': R'hJX% JXr   