
    nzh
M                         S SK 7  S SKJr  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)    )*)
SearchCore)ChannelSearchCorec                   V   ^  \ rS rSrSrSS\S\S\S\S\4
U 4S jjjrS	\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)
    >>> print(search.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                    > SU l         [        TU ]	  XX4S U5        U R                  5         U R                  " U R                   6   g N)TTT
searchModesuper__init__sync_create_getComponentsselfr	   r
   r   r   r   	__class__s         T/home/james-whalen/.local/lib/python3.13/site-packages/youtubesearchpython/search.pyr   Search.__init__G   s;    ,xwGT__-    returnc                 "    U R                  5       $ N_nextr   s    r   nextSearch.nextM       zz|r   r      enUSN__name__
__module____qualname____firstlineno____doc__strintr   boolr"   __static_attributes____classcell__r   s   @r   r   r      I    ?@.c .# .c .RU .gj . .d  r   r   c                   V   ^  \ rS rSrSrSS\S\S\S\S\4
U 4S jjjrS	\4S
 jr	Sr
U =r$ )VideosSearchP   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)
    >>> print(search.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                    > SU l         [        TU ]	  XX4[        R                  U5        U R                  5         U R                  " U R                   6   g )N)TFF)r   r   r   
SearchModevideosr   r   r   s         r   r   VideosSearch.__init__   sA    .x9J9JGTT__-r   r   c                 "    U R                  5       $ r   r   r!   s    r   r"   VideosSearch.next   r$   r   r%   r&   r*   r5   s   @r   r8   r8   P   r6   r   r8   c                   V   ^  \ rS rSrSrSS\S\S\S\S\4
U 4S jjjrS	\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)
    >>> print(search.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                    > SU l         [        TU ]	  XX4[        R                  U5        U R                  5         U R                  " U R                   6   g )N)FTF)r   r   r   r;   channelsr   r   r   s         r   r   ChannelsSearch.__init__   sA    .x9L9LgVT__-r   r   c                 "    U R                  5       $ r   r   r!   s    r   r"   ChannelsSearch.next   r$   r   r%   r&   r*   r5   s   @r   rA   rA      sI    &N.c .# .c .RU .gj . .d  r   rA   c                   V   ^  \ rS rSrSrSS\S\S\S\S\4
U 4S jjjrS	\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)
    >>> print(search.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                    > SU l         [        TU ]	  XX4[        R                  U5        U R                  5         U R                  " U R                   6   g )N)FFT)r   r   r   r;   	playlistsr   r   r   s         r   r   PlaylistsSearch.__init__  sA    .x9M9MwWT__-r   r   c                 "    U R                  5       $ r   r   r!   s    r   r"   PlaylistsSearch.next  r$   r   r%   r&   r*   r5   s   @r   rI   rI      sI    3h.c .# .c .RU .gj . .d  r   rI   c                   L   ^  \ 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")
        >>> print(search.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   searchPreferencesr   c                 H   > [         TU ]  XXEX&5        U R                  5         g r   )r   r   r   )r   r	   rR   r   r   rS   r   r   s          r   r   ChannelSearch.__init__T  s     &XWr    )r(   r)   zEgZzZWFyY2g%3DN)
r+   r,   r-   r.   r/   r0   r1   r   r3   r4   r5   s   @r   rQ   rQ     sE    ENc S C PS or   QT  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Sr	U =r
$ )CustomSearchiY  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)
    >>> print(search.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	   rS   r
   r   r   r   c                    > SU l         [        TU ]	  XXEX&5        U R                  5         U R                  " U R                   6   g r   r   )r   r	   rS   r
   r   r   r   r   s          r   r   CustomSearch.__init__  s:    ,x9JTT__-r   c                 $    U R                  5         g r   r   r!   s    r   r"   CustomSearch.next  s    

r   r%   r&   )r+   r,   r-   r.   r/   r0   r1   r   r"   r3   r4   r5   s   @r   rX   rX   Y  sO    JV.c .c .# .VY .jm .  @C . . r   rX   N)"youtubesearchpython.core.constantsyoutubesearchpython.core.searchr   &youtubesearchpython.core.channelsearchr   r   r8   rA   rI   rQ   rX   rV   r   r   <module>r`      sd    0 6 DHZ HTH: HV/Z /d<j <~J% JZS: Sr   