# This file is part of Senator Sperma # Licensed under the GPL-3.0 License # Copyright (C) 2026 Salmonik @ salmonik@tuta.io # https://codeberg.org/salmonik/senator-sperma def clean_url_for_ytdlp(url: str) -> str: """Clean URL by removing everything after the first '&'. This prevents yt-dlp from interpreting additional query parameters (like &list=...) as playlist URLs. Example: Input: https://www.youtube.com/watch?v=lPGipwoJiOM&list=RDlPGipwoJiOM& Output: https://www.youtube.com/watch?v=lPGipwoJiOM """ # Find the first '&' and truncate first_ampersand = url.find('&') if first_ampersand != -1: return url[:first_ampersand] return url