# ============================================================ # YT-DLP OPTIONS # ============================================================ def get_video_options( url: str, output_template: str, fallback=False ): opts = { "quiet": True, "no_warnings": True, "nocheckcertificate": True, "geo_bypass": True, "retries": 3, "fragment_retries": 3, "file_access_retries": 3, "socket_timeout": 30, "concurrent_fragment_downloads": 5, "continuedl": True, "noplaylist": True, "outtmpl": output_template, "merge_output_format": "mp4", "format": ( "bestvideo[ext=mp4]+" "bestaudio[ext=m4a]/" "bestvideo+bestaudio/" "best[ext=mp4]/" "best" ), "http_headers": { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " "AppleWebKit/537.36 " "(KHTML, like Gecko) " "Chrome/128.0.0.0 Safari/537.36", "Accept": "text/html,application/xhtml+xml," "application/xml;q=0.9,image/webp," "*/*;q=0.8", "Accept-Language": "en-US,en;q=0.9" } } # -------------------------------------------------------- # YouTube # -------------------------------------------------------- if ( "youtube.com" in url.lower() or "youtu.be" in url.lower() ): # Do NOT force a specific player client here. # yt-dlp's current defaults are safer. opts["format"] = ( "bestvideo[ext=mp4]+" "bestaudio[ext=m4a]/" "bestvideo+bestaudio/" "best[ext=mp4]/" "best" ) # -------------------------------------------------------- # Likee # -------------------------------------------------------- elif ( "likee" in url.lower() or "likee.video" in url.lower() ): opts["http_headers"]["Referer"] = ( "https://likee.video/" ) # -------------------------------------------------------- # Vimeo # -------------------------------------------------------- elif "vimeo.com" in url.lower(): opts["http_headers"]["Referer"] = ( "https://vimeo.com/" ) # -------------------------------------------------------- # Fallback # -------------------------------------------------------- if fallback: opts["format"] = ( "best[ext=mp4]/best" ) # -------------------------------------------------------- # YouTube Cookies # -------------------------------------------------------- if os.path.exists( "cookies.txt" ): opts["cookiefile"] = ( "cookies.txt" ) return opts