

import os

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

_UpperCamelCase			       =			{'''UserAgent''': UserAgent().random}
_UpperCamelCase			       =			'''https://www.mywaifulist.moe/random'''
def 						UpperCamelCase_(			snake_case__:  str  ,    snake_case__:  str   )       -> None:
 UpperCAmelCase__							=				requests.get(snake_case__  ,    headers=snake_case__   )
 with open(snake_case__  ,    'wb'   ) as file:
  file.write(image.content   )
def 						UpperCamelCase_(			)       -> tuple[str, str, str]:
 UpperCAmelCase__							=				BeautifulSoup(requests.get(snake_case__  ,    headers=snake_case__   ).text  ,    'html.parser'   )
 UpperCAmelCase__							=				soup.find('meta'  ,    attrs={'property': 'og:title'}   ).attrs['content']
 UpperCAmelCase__							=				soup.find('meta'  ,    attrs={'property': 'og:image'}   ).attrs['content']
 UpperCAmelCase__							=				soup.find('p'  ,    id='description'   ).get_text()
 UpperCAmelCase__				,    UpperCAmelCase__							=				os.path.splitext(os.path.basename(snake_case__   )   )
 UpperCAmelCase__							=				title.strip().replace(' '  ,    '_'   )
 UpperCAmelCase__							=				f"{image_title}{image_extension}"
 save_image(snake_case__  ,    snake_case__   )
 return (title, description, image_title)


if __name__ == "__main__":
 _UpperCamelCase       ,				_UpperCamelCase       ,				_UpperCamelCase			       =			random_anime_character()
 print(F"""{title}\n\n{desc}\n\nImage saved : {image_title}""")






def 						UpperCamelCase_(			snake_case__:  list   )       -> list:
 UpperCAmelCase__							=				len(snake_case__   )

 # Set the gap value to be decreased by a factor of 1.3
 # after each iteration
 UpperCAmelCase__							=				1.3

 # Continue sorting until the gap is 1
 while gap > 1:
  # Decrease the gap value
  UpperCAmelCase__							=				int(gap / shrink   )

  # Sort the elements using insertion sort
  for i in range(snake_case__  ,    len(snake_case__   )   ):
   UpperCAmelCase__							=				collection[i]
   UpperCAmelCase__							=				i
   while j >= gap and collection[j - gap] > temp:
    UpperCAmelCase__							=				collection[j - gap]
    j -= gap
   UpperCAmelCase__							=				temp

 return collection


if __name__ == "__main__":
 import doctest

 doctest.testmod()



