



import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
       import torch

if is_vision_available():
       from PIL import Image

       from transformers import GLPNImageProcessor


class 			UpperCAmelCase__    (		unittest.TestCase					):



  """simple docstring"""






  def __init__(				self:			Tuple				,				__lowerCAmelCase:			int				,				__lowerCAmelCase:			List[Any]=7				,				__lowerCAmelCase:			Dict=3				,				__lowerCAmelCase:			Optional[int]=18				,				__lowerCAmelCase:			List[str]=30				,				__lowerCAmelCase:			Any=400				,				__lowerCAmelCase:			str=True				,				__lowerCAmelCase:			Optional[Any]=32				,				__lowerCAmelCase:			List[Any]=True				,				) -> Union[str, Any]:




    '''simple docstring'''




    __UpperCAmelCase						    =       parent
    __UpperCAmelCase						    =       batch_size
    __UpperCAmelCase						    =       num_channels
    __UpperCAmelCase						    =       image_size
    __UpperCAmelCase						    =       min_resolution
    __UpperCAmelCase						    =       max_resolution
    __UpperCAmelCase						    =       do_resize
    __UpperCAmelCase						    =       size_divisor
    __UpperCAmelCase						    =       do_rescale






  def 	_UpperCAmelCase				(				self:			Tuple   ) -> Dict:




    '''simple docstring'''




    return {
        "do_resize": self.do_resize,
        "size_divisor": self.size_divisor,
        "do_rescale": self.do_rescale,
    }






@require_torch
@require_vision
class 			UpperCAmelCase__    (		snake_case		,	unittest.TestCase					):



  """simple docstring"""






  lowerCAmelCase__		:	List[str]    		= GLPNImageProcessor if is_vision_available() else None






  def 	_UpperCAmelCase				(				self:			str   ) -> Optional[Any]:




    '''simple docstring'''




    __UpperCAmelCase						    =       GLPNImageProcessingTester(self   )






  @property
  def 	_UpperCAmelCase				(				self:			int   ) -> List[Any]:




    '''simple docstring'''




    return self.image_processor_tester.prepare_image_processor_dict()






  def 	_UpperCAmelCase				(				self:			Tuple   ) -> str:




    '''simple docstring'''




    __UpperCAmelCase						    =       self.image_processing_class(**self.image_processor_dict   )
    self.assertTrue(hasattr(A__				,				"do_resize"   )   )
    self.assertTrue(hasattr(A__				,				"size_divisor"   )   )
    self.assertTrue(hasattr(A__				,				"resample"   )   )
    self.assertTrue(hasattr(A__				,				"do_rescale"   )   )






  def 	_UpperCAmelCase				(				self:			Tuple   ) -> Tuple:




    '''simple docstring'''




    pass






  def 	_UpperCAmelCase				(				self:			int   ) -> Union[str, Any]:




    '''simple docstring'''




    __UpperCAmelCase						    =       self.image_processing_class(**self.image_processor_dict   )
    # create random PIL images
    __UpperCAmelCase						    =       prepare_image_inputs(self.image_processor_tester				,				equal_resolution=A__   )
    for image in image_inputs:
      self.assertIsInstance(A__				,				Image.Image   )

    # Test not batched input (GLPNImageProcessor doesn't support batching)
    __UpperCAmelCase						    =       image_processing(image_inputs[0]				,				return_tensors="pt"   ).pixel_values
    self.assertTrue(encoded_images.shape[-1] % self.image_processor_tester.size_divisor == 0   )
    self.assertTrue(encoded_images.shape[-2] % self.image_processor_tester.size_divisor == 0   )






  def 	_UpperCAmelCase				(				self:			int   ) -> Union[str, Any]:




    '''simple docstring'''




    __UpperCAmelCase						    =       self.image_processing_class(**self.image_processor_dict   )
    # create random numpy tensors
    __UpperCAmelCase						    =       prepare_image_inputs(self.image_processor_tester				,				equal_resolution=A__				,				numpify=A__   )
    for image in image_inputs:
      self.assertIsInstance(A__				,				np.ndarray   )

    # Test not batched input (GLPNImageProcessor doesn't support batching)
    __UpperCAmelCase						    =       image_processing(image_inputs[0]				,				return_tensors="pt"   ).pixel_values
    self.assertTrue(encoded_images.shape[-1] % self.image_processor_tester.size_divisor == 0   )
    self.assertTrue(encoded_images.shape[-2] % self.image_processor_tester.size_divisor == 0   )






  def 	_UpperCAmelCase				(				self:			Tuple   ) -> Dict:




    '''simple docstring'''




    __UpperCAmelCase						    =       self.image_processing_class(**self.image_processor_dict   )
    # create random PyTorch tensors
    __UpperCAmelCase						    =       prepare_image_inputs(self.image_processor_tester				,				equal_resolution=A__				,				torchify=A__   )
    for image in image_inputs:
      self.assertIsInstance(A__				,				torch.Tensor   )

    # Test not batched input (GLPNImageProcessor doesn't support batching)
    __UpperCAmelCase						    =       image_processing(image_inputs[0]				,				return_tensors="pt"   ).pixel_values
    self.assertTrue(encoded_images.shape[-1] % self.image_processor_tester.size_divisor == 0   )
    self.assertTrue(encoded_images.shape[-2] % self.image_processor_tester.size_divisor == 0   )




from datetime import datetime

import requests




def       __lowerCAmelCase      (						A_   : str					)    ->  bytes:
  __UpperCAmelCase						    =       "https://downloadgram.net/wp-json/wppress/video-downloader/video?url="
  __UpperCAmelCase						    =       requests.get(base_url + url					).json()[0]["urls"][0]["src"]
  return requests.get(A_					).content


if __name__ == "__main__":
       a_							=      input("""Enter Video/IGTV url: """).strip()
       a_							=      F"{datetime.now():%Y-%m-%d_%H:%M:%S}.mp4"
       with open(file_name, """wb""") as fp:
              fp.write(download_video(url))
       print(F"Done. Video saved to disk as {file_name}.")



