
    iC                     v    d dl Z d dlZd dlZd dlmZ  e              e j        dd          Zdededz  fdZdS )    N)load_dotenvDOWNLOAD_PATHz./downloadsurlreturnc                    t          j        t          d           t          t	          j                              }t           j                            t          | d          ddd}	 t          j	        |          5 }|
                    | d          }|                    |          }|cddd           S # 1 swxY w Y   dS # t          $ r Y dS w xY w)z
    Download media from URL using yt-dlp.
    Saves file with a UUID name to avoid Arabic/special character issues.
    Returns the file path on success, or None on failure.
    T)exist_okz.%(ext)s)outtmplquietno_warnings)downloadN)osmakedirsr   struuiduuid4pathjoinyt_dlp	YoutubeDLextract_infoprepare_filename	Exception)r   	safe_nameydl_optsydlinfo	file_paths         1/var/www/html/my_media/telegram_bot/downloader.pyr   r      s#    K----DJLL!!I7<<)/E/E/EFF Hh'' 	3##C$#77D,,T22I	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	    tts6   )C =.B8+C 8B<<C ?B< C 
CC)	r   r   r   dotenvr   getenvr   r   r        r   <module>r#      s    				         	/=99# #*      r"   