Certainly! To create a Python application using PyQt6 that allows you to download TikTok videos using yt-dlp.exe, follow these steps:
Here's a complete example of a PyQt6 application that downloads TikTok videos using yt-dlp.exe:
python
import sys
import subprocess
from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QLabel, QLineEdit, QPushButton, QVBoxLayout, QMessageBox
class TikTokDownloader(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("TikTok Video Downloader")
self.setGeometry(100, 100, 400, 200)
self.initUI()
def initUI(self):
self.central_widget = QWidget()
self.setCentralWidget(self.central_widget)
self.layout = QVBoxLayout(self.central_widget)
self.label = QLabel("Enter TikTok Video URL:")
self.layout.addWidget(self.label)
self.url_input = QLineEdit()
self.layout.addWidget(self.url_input)
self.download_button = QPushButton("Download Video")
self.download_button.clicked.connect(self.download_video)
self.layout.addWidget(self.download_button)
def download_video(self):
url = self.url_input.text()
if not url:
QMessageBox.warning(self, "Error", "Please enter a valid URL.")
return
try:
result = subprocess.run(
["yt-dlp.exe", url],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
if result.returncode == 0:
QMessageBox.information(self, "Success", "Video downloaded successfully!")
else:
QMessageBox.warning(self, "Error", f"Failed to download video: {result.stderr}")
except Exception as e:
QMessageBox.warning(self, "Error", f"An error occurred: {str(e)}")
if __name__ == "__main__":
app = QApplication(sys.argv)
window = TikTokDownloader()
window.show()
sys.exit(app.exec())
This will open a simple GUI where you can enter a TikTok video URL and download the video using yt-dlp.exe.