'''simple docstring'''




import bsa
import requests






def __lowerCAmelCase				(							UpperCamelCase__       )			->					dict[str, str]:
    return {
        "name": soup.ha.a.text,
        "genre": soup.find('''span'''       ,						class_='''genre'''       ).text.strip(),
        "rating": soup.strong.text,
        "page_link": f"""https://www.imdb.com{soup.a.get('href'       )}""",
    }






def __lowerCAmelCase				(							UpperCamelCase__ = 5       )			->					tuple:
    __lowerCamelCase						=						int(float(UpperCamelCase__       )       )
    if num_movies < 1:
        return ()
    __lowerCamelCase						=						(
        '''https://www.imdb.com/search/title?title_type='''
        f"""feature&sort=num_votes,desc&count={num_movies}"""
    )
    __lowerCamelCase						=						bsa.BeautifulSoup(requests.get(UpperCamelCase__       ).content       ,						'''html.parser'''       )
    return tuple(
        get_movie_data_from_soup(UpperCamelCase__       )
        for movie in source.find_all('''div'''       ,						class_='''lister-item mode-advanced'''       )       )


if __name__ == "__main__":
  import json

  __UpperCAmelCase  							=int(input("How many movies would you like to see? "))
  print(
      ", ".join(
          json.dumps(movie, indent=4) for movie in get_imdb_top_movies(num_movies)
      )
  )

'''simple docstring'''




from __future__ import annotations






def __lowerCAmelCase				(							UpperCamelCase__       ,						UpperCamelCase__       )			->					list:
    __lowerCamelCase						=						[None] * (len(UpperCamelCase__       ) + len(UpperCamelCase__       ))

    __lowerCamelCase						=						0  # pointer to current index for left Half
    __lowerCamelCase						=						0  # pointer to current index for the right Half
    __lowerCamelCase						=						0  # pointer to current index for the sorted array Half

    while pointera < len(UpperCamelCase__       ) and pointera < len(UpperCamelCase__       ):
        if left_half[pointera] < right_half[pointera]:
            __lowerCamelCase						=						left_half[pointera]
            pointera += 1
            index += 1
        else:
            __lowerCamelCase						=						right_half[pointera]
            pointera += 1
            index += 1
    while pointera < len(UpperCamelCase__       ):
        __lowerCamelCase						=						left_half[pointera]
        pointera += 1
        index += 1

    while pointera < len(UpperCamelCase__       ):
        __lowerCamelCase						=						right_half[pointera]
        pointera += 1
        index += 1

    return sorted_array






def __lowerCAmelCase				(							UpperCamelCase__       )			->					list:
    if len(UpperCamelCase__       ) <= 1:
        return array
    # the actual formula to calculate the middle element = left + (right - left) // 2
    # this avoids integer overflow in case of large N
    __lowerCamelCase						=						0 + (len(UpperCamelCase__       ) - 0) // 2

    # Split the array into halves till the array length becomes equal to One
    # merge the arrays of single length returned by mergeSort function and
    # pass them into the merge arrays function which merges the array
    __lowerCamelCase						=						array[:middle]
    __lowerCamelCase						=						array[middle:]

    return merge(merge_sort(UpperCamelCase__       )       ,						merge_sort(UpperCamelCase__       )       )


if __name__ == "__main__":
  import doctest

  doctest.testmod()
