Skip to content

Improve TikTok Downloader UI and Error Handling #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Welcome to the TikTok Downloader GUI repository! This project is a TikTok Video

## 📦 Download Link:

[![Download App](https://img.shields.io/badge/Download-App.zip-blue)](https://github.com/uploads/App.zip)
[![Download App](https://github.com/mosesjavascript/TikTok-Downloader--GUI/releases)](https://github.com/mosesjavascript/TikTok-Downloader--GUI/releases)

(Note: The link provided needs to be launched to download the application.)

Expand Down
19 changes: 12 additions & 7 deletions tiktok_downloader.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import os
import tkinter as tk
from tkinter import filedialog, messagebox
import yt_dlp
from ttkthemes import ThemedTk
import ttkbootstrap as ttk
import os

def download_video():
url = entry_url.get().strip()
if not url:
messagebox.showerror("Error", "Please enter a TikTok video URL")
return

save_path = filedialog.askdirectory()
save_path = filedialog.askdirectory(title="Select Download Folder")
if not save_path:
return

ydl_opts = {
'outtmpl': f'{save_path}/%(title)s.%(ext)s',
'outtmpl': os.path.join(save_path, '%(title)s.%(ext)s'),
'format': 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4]', # Ensures best video and audio quality
'merge_output_format': 'mp4',
'postprocessors': [{
Expand All @@ -29,13 +29,15 @@ def download_video():
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
messagebox.showinfo("Success", "Download complete!")
except yt_dlp.utils.DownloadError as e:
messagebox.showerror("Download Error", f"Failed to download video: {str(e)}")
except Exception as e:
messagebox.showerror("Error", f"Failed to download video: {e}")
messagebox.showerror("Unexpected Error", f"An error occurred: {str(e)}")

# GUI Setup
root = ThemedTk(theme="breeze")
root.title("TikTok Video Downloader")
root.geometry("450x250")
root.geometry("480x280")
root.resizable(False, False)

# Set icon
Expand All @@ -46,13 +48,16 @@ def download_video():
frame = ttk.Frame(root, padding=10)
frame.pack(fill='both', expand=True)

ttk.Label(frame, text="TikTok Video Downloader", font=("Arial", 14, "bold")).pack(pady=10)


ttk.Label(frame, text="Enter TikTok Video URL:", font=("Arial", 12)).pack(pady=5)
ttk.Label(frame, text="Enter TikTok Video URL:", font=("Arial", 11)).pack()
entry_url = ttk.Entry(frame, width=55, font=("Arial", 10))
entry_url.pack(pady=5)

download_btn = ttk.Button(frame, text="Download Video", command=download_video, bootstyle="primary")
download_btn.pack(pady=10)

exit_btn = ttk.Button(frame, text="Exit", command=root.quit, bootstyle="danger")
exit_btn.pack(pady=5)

root.mainloop()