
"""simple docstring"""


import os
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


_lowercase				 =					logging.get_logger(__name__)

_lowercase				 =					{"""vocab_file""": """spm_char.model"""}

_lowercase				 =					{
    """vocab_file""": {
        """microsoft/speecht5_asr""": """https://huggingface.co/microsoft/speecht5_asr/resolve/main/spm_char.model""",
        """microsoft/speecht5_tts""": """https://huggingface.co/microsoft/speecht5_tts/resolve/main/spm_char.model""",
        """microsoft/speecht5_vc""": """https://huggingface.co/microsoft/speecht5_vc/resolve/main/spm_char.model""",
    }
}

_lowercase				 =					{
    """microsoft/speecht5_asr""": 10_24,
    """microsoft/speecht5_tts""": 10_24,
    """microsoft/speecht5_vc""": 10_24,
}







class 					lowerCAmelCase_					(   SCREAMING_SNAKE_CASE_     ):



						'''simple docstring'''


						_lowerCamelCase:     List[Any]   =     VOCAB_FILES_NAMES
						_lowerCamelCase:     Tuple   =     PRETRAINED_VOCAB_FILES_MAP
						_lowerCamelCase:     Dict   =     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						_lowerCamelCase:     Optional[Any]   =     ['input_ids', 'attention_mask']


						def __init__(			self  :   List[str]	,A_  :   Any	,A_  :   List[str]="<s>"	,A_  :   Union[str, Any]="</s>"	,A_  :   Union[str, Any]="<unk>"	,A_  :   Tuple="<pad>"	,A_  :   Optional[Dict[str, Any]] = None	,**A_  :   List[str]	,)  -> Tuple:
							A     = {} if sp_model_kwargs is None else sp_model_kwargs

							super().__init__(
							    bos_token=A_	,eos_token=A_	,unk_token=A_	,pad_token=A_	,sp_model_kwargs=self.sp_model_kwargs	,**A_	,)

							A     = vocab_file

							A     = spm.SentencePieceProcessor(**self.sp_model_kwargs   )
							self.sp_model.Load(A_   )


						@property
						def     _SCREAMING_SNAKE_CASE   (			self  :   Any   )  -> Dict:
							return self.sp_model.get_piece_size()


						def     _SCREAMING_SNAKE_CASE   (			self  :   Tuple   )  -> List[str]:
							A     = {self.convert_ids_to_tokens(A_   ): i for i in range(self.vocab_size   )}
							vocab.update(self.added_tokens_encoder   )
							return vocab


						def __getstate__(			self  :   List[str]   )  -> str:
							A     = self.__dict__.copy()
							A     = None
							return state


						def __setstate__(			self  :   List[str]	,A_  :   Optional[Any]   )  -> Tuple:
							A     = d

							# for backward compatibility
							if not hasattr(self	,'sp_model_kwargs'   ):
								A     = {}

							A     = spm.SentencePieceProcessor(**self.sp_model_kwargs   )
							self.sp_model.Load(self.vocab_file   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   Dict	,A_  :   str   )  -> Optional[int]:
							return self.sp_model.encode(A_	,out_type=A_   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   int	,A_  :   Union[str, Any]   )  -> Union[str, Any]:
							return self.sp_model.piece_to_id(A_   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[int]	,A_  :   List[Any]   )  -> int:
							A     = self.sp_model.IdToPiece(A_   )
							return token


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[Any]	,A_  :   Union[str, Any]   )  -> Tuple:
							A     = []
							A     = ''
							for token in tokens:
								# make sure that special tokens are not decoded using sentencepiece model
								if token in self.all_special_tokens:
									out_string += self.sp_model.decode(A_   ) + token
									A     = []
								else:
									current_sub_tokens.append(A_   )
							out_string += self.sp_model.decode(A_   )
							return out_string.strip()


						def     _SCREAMING_SNAKE_CASE   (			self  :   Any	,A_  :   str	,A_  :   List[Any]=None   )  -> Union[str, Any]:


							if token_ids_a is None:
								return token_ids_a + [self.eos_token_id]
							# We don't expect to process pairs, but leave the pair logic for API consistency
							return token_ids_a + token_ids_a + [self.eos_token_id]


						def     _SCREAMING_SNAKE_CASE   (			self  :   Union[str, Any]	,A_  :   List[int]	,A_  :   Optional[List[int]] = None	,A_  :   bool = False   )  -> List[Any]:


							if already_has_special_tokens:
								return super().get_special_tokens_mask(
								    token_ids_a=A_	,token_ids_a=A_	,already_has_special_tokens=A_   )

							A     = [1]
							if token_ids_a is None:
								return ([0] * len(A_   )) + suffix_ones
							return ([0] * len(A_   )) + ([0] * len(A_   )) + suffix_ones




						def     _SCREAMING_SNAKE_CASE   (			self  :   List[Any]	,A_  :   str	,A_  :   Optional[str] = None   )  -> List[str]:


							if not os.path.isdir(A_   ):
								logger.error(F'Vocabulary path ({save_directory}) should be a directory'   )
								return
							A     = os.path.join(
							    A_	,(filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file']   )

							if os.path.abspath(self.vocab_file   ) != os.path.abspath(A_   ) and os.path.isfile(self.vocab_file   ):
								copyfile(self.vocab_file	,A_   )
							elif not os.path.isfile(self.vocab_file   ):
								with open(A_	,'wb'   ) as fi:
									A     = self.sp_model.serialized_model_proto()
									fi.write(A_   )

							return (out_vocab_file,)




from datetime import datetime

import requests

def        __a			(   __lowerCAmelCase   )     ->     bytes:
					SCREAMING_SNAKE_CASE							:     int						=				'https://downloadgram.net/wp-json/wppress/video-downloader/video?url='
					SCREAMING_SNAKE_CASE							:     Any						=				requests.get(base_url + url   ).json()[0]['urls'][0]['src']
					return requests.get(__lowerCAmelCase   ).content


if __name__ == "__main__":
			_lowerCamelCase    :		List[Any]		      =    input("""Enter Video/IGTV url: """).strip()
			_lowerCamelCase    :		int		      =    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}.""")