LDownloader/ui/tabs/kick_tab.py

671 lines
29 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import tkinter as tk
from tkinter import ttk, filedialog, messagebox
from ui.theme import (
BG, SURFACE, SURFACE_LIGHT, SURFACE_HOVER, ENTRY_BG, BORDER,
ACCENT, ACCENT_LIGHT, ACCENT_MUTED, TEXT, SUBTEXT, MUTED, SUCCESS, WARNING, ERROR,
FONT_HERO, FONT_TITLE, FONT_SUBTITLE, FONT_REGULAR, FONT_BOLD, FONT_SMALL, FONT_SMALL_BOLD
)
from ui.components import (
Card, PillButton, PillChip, ModernEntry, SegmentedPill, VideoPreviewCard, ScrollableFrame
)
from core.config import config
from core.metadata import fetch_video_metadata
from core.dependencies import resolve_cookies_args
from core.kick import parse_kick_input, fetch_kick_channel_Async
KICK_GREEN = "#53FC18"
KICK_GREEN_DARK = "#173311"
class KickTab(tk.Frame):
"""
Kick.com Özel İndirme & Kanal Keşif Sekmesi:
- Canlı Yayın (Live Stream) Kaydedici & İzleyici
- Geçmiş Yayınlar (VODs) Tarayıcısı & İndiricisi (Kesit / Clip alma destekli)
- Klipler (Clips) Tarayıcısı & Tek/Toplu İndiricisi
"""
def __init__(self, parent, on_download_requested=None, on_batch_requested=None, on_open_settings=None, **kwargs):
super().__init__(parent, bg=BG, **kwargs)
self.on_download_requested = on_download_requested
self.on_batch_requested = on_batch_requested
self.on_open_settings = on_open_settings
self.current_metadata = None
self.channel_data = None
self._vods = []
self._clips = []
self._metadata_url = ""
self._request_id = 0
self._after_id = None
self._mode = "vods" # "live", "vods", "clips"
self._build_ui()
def _build_ui(self):
self.scroll_container = ScrollableFrame(self)
self.scroll_container.pack(fill="both", expand=True)
scroll_frame = self.scroll_container.inner
# ── 1. Üst Kick Başlık & Bilgi Kartı ────────────────────────
banner = tk.Frame(
scroll_frame, bg=SURFACE_LIGHT, padx=18, pady=12,
highlightthickness=1, highlightbackground=BORDER
)
banner.pack(fill="x", padx=32, pady=(16, 0))
badge_k = tk.Label(
banner, text=" KICK ", bg=KICK_GREEN, fg="#090C10",
font=FONT_SMALL_BOLD, padx=6, pady=2
)
badge_k.pack(side="left", padx=(0, 12))
tk.Label(
banner,
text="Kick Canlı Yayın, VOD (Yayın Tekrarı) ve Klip İndirici — Kanal adı (örn: elraenn, xqc) veya doğrudan Kick URL'si girin.",
bg=SURFACE_LIGHT, fg=TEXT, font=FONT_SMALL_BOLD, anchor="w"
).pack(side="left", fill="x", expand=True)
# ── 2. Ana Arama & Bağlantı Kartı ────────────────────────────
main_card = Card(scroll_frame, padx=24, pady=18)
main_card.pack(fill="x", padx=32, pady=(12, 12))
self.main_card = main_card
hdr_row = tk.Frame(main_card, bg=SURFACE)
hdr_row.pack(fill="x")
tk.Label(
hdr_row, text="Kick Kanal Adı veya Medya Bağlantısı (Canlı / VOD / Clip)",
bg=SURFACE, fg=TEXT, font=FONT_BOLD
).pack(side="left")
self.lbl_status = tk.Label(hdr_row, text="", bg=SURFACE, fg=ACCENT_LIGHT, font=FONT_SMALL_BOLD)
self.lbl_status.pack(side="right")
input_row = tk.Frame(main_card, bg=SURFACE)
input_row.pack(fill="x", pady=(8, 12))
self.url_var = tk.StringVar()
self.url_entry = ModernEntry(
input_row,
textvariable=self.url_var,
placeholder="Kanal adı (örn: elraenn, xqc) veya https://kick.com/... bağlantısı yapıştırın",
on_change=self._on_input_changed
)
self.url_entry.pack(side="left", fill="x", expand=True, ipady=6)
self.url_entry.bind("<Return>", lambda e: self._trigger_lookup())
PillButton(
input_row, text="🔍 Kanalı / Linki Sorgula", command=self._trigger_lookup,
small=True, style="primary"
).pack(side="left", padx=(8, 0))
PillButton(
input_row, text="Yapıştır", command=self._paste_clipboard,
small=True, style="secondary"
).pack(side="left", padx=(6, 0))
PillButton(
input_row, text="✕", command=self._clear_all,
small=True, style="ghost"
).pack(side="left", padx=(6, 0))
# ── Kanal Özet Barı (Kanal sorgulandığında görünür) ──────────
self.channel_bar = tk.Frame(
main_card, bg=SURFACE_LIGHT, padx=14, pady=10,
highlightthickness=1, highlightbackground=BORDER
)
self.lbl_ch_name = tk.Label(self.channel_bar, text="", bg=SURFACE_LIGHT, fg=TEXT, font=FONT_BOLD)
self.lbl_ch_name.pack(side="left")
self.lbl_live_badge = tk.Label(
self.channel_bar, text="", bg=SURFACE_LIGHT, fg=SUBTEXT,
font=FONT_SMALL_BOLD, padx=8, pady=2
)
self.lbl_live_badge.pack(side="left", padx=(10, 0))
self.lbl_ch_stats = tk.Label(self.channel_bar, text="", bg=SURFACE_LIGHT, fg=SUBTEXT, font=FONT_SMALL)
self.lbl_ch_stats.pack(side="right")
# ── Tekil URL Önizleme Kartı (Doğrudan VOD/Clip linki yapıştırıldığında) ──
self.preview_card = VideoPreviewCard(main_card)
# ── 3. Alt Mod Seçici (Canlı Yayın | VOD Geçmiş Yayınlar | Klipler) ──
mode_row = tk.Frame(main_card, bg=SURFACE)
mode_row.pack(fill="x", pady=(4, 12))
self.mode_seg = SegmentedPill(
mode_row,
items=[
("vods", "📼 VOD (Geçmiş Yayınlar)"),
("clips", "✂️ Klipler (Clips)"),
("live", "🔴 Canlı Yayın Kaydı"),
],
default_val="vods",
on_change=self._on_mode_switched
)
self.mode_seg.pack(side="left")
self.btn_Download_selected_batch = PillButton(
mode_row, text="⬇ Seçilenleri İndir", command=self._on_download_selected_items,
small=True, style="secondary"
)
self.btn_Download_selected_batch.pack(side="right")
# ── 4. Dinamik İçerik Alanı (Tablo veya Canlı Yayın Paneli) ───
self.dynamic_frame = tk.Frame(main_card, bg=SURFACE)
self.dynamic_frame.pack(fill="both", expand=True, pady=(0, 14))
# 4A. VOD & Klip Listesi (Treeview)
self.table_container = tk.Frame(self.dynamic_frame, bg=SURFACE)
self.table_container.pack(fill="both", expand=True)
columns = ("type", "title", "duration", "views", "date")
self.tree = ttk.Treeview(
self.table_container, columns=columns, show="headings",
selectmode="extended", height=6
)
self.tree.heading("type", text="Tür / Kategori")
self.tree.heading("title", text="Yayın / Klip Başlığı (Çift tıkla -> Seç)")
self.tree.heading("duration", text="Süre")
self.tree.heading("views", text="İzlenme")
self.tree.heading("date", text="Tarih")
self.tree.column("type", width=130, anchor="center", stretch=False)
self.tree.column("title", width=410, anchor="w")
self.tree.column("duration", width=85, anchor="center", stretch=False)
self.tree.column("views", width=90, anchor="center", stretch=False)
self.tree.column("date", width=130, anchor="center", stretch=False)
sb = ttk.Scrollbar(self.table_container, orient="vertical", command=self.tree.yview, style="Vertical.TScrollbar")
self.tree.configure(yscrollcommand=sb.set)
self.tree.pack(side="left", fill="both", expand=True)
sb.pack(side="right", fill="y")
self.tree.bind("<<TreeviewSelect>>", self._on_tree_selected)
self.tree.bind("<Double-1>", lambda e: self._on_start_click())
# 4B. Canlı Yayın Özel Kontrol Paneli
self.live_panel = tk.Frame(
self.dynamic_frame, bg=SURFACE_LIGHT, padx=16, pady=14,
highlightthickness=1, highlightbackground=BORDER
)
self.lbl_live_title = tk.Label(
self.live_panel, text="Canlı Yayın Kayıt Modu",
bg=SURFACE_LIGHT, fg=TEXT, font=FONT_BOLD, anchor="w"
)
self.lbl_live_title.pack(fill="x")
self.lbl_live_sub = tk.Label(
self.live_panel,
text="Kanal canlı yayındayken kaydı başlatabilirsiniz. Kaydı durdurduğunuzda (İptal Et) o ana kadar olan kısım MP4/MKV olarak kaydedilir.",
bg=SURFACE_LIGHT, fg=SUBTEXT, font=FONT_SMALL, anchor="w", justify="left", wraplength=760
)
self.lbl_live_sub.pack(fill="x", pady=(4, 10))
live_chips = tk.Frame(self.live_panel, bg=SURFACE_LIGHT)
live_chips.pack(fill="x")
self.chip_wait_live = PillChip(
live_chips, text="⏳ Yayın Açılmasını Bekle (Çevrimdışıysa)",
initial_value=False
)
self.chip_wait_live.pack(side="left", padx=(0, 10))
self.chip_live_from_start = PillChip(
live_chips, text="⏮ Yayını Baştan İndir (DVR Destekliyorsa)",
initial_value=False
)
self.chip_live_from_start.pack(side="left")
# İnce Ayraç
tk.Frame(main_card, bg=BORDER, height=1).pack(fill="x", pady=(0, 14))
# ── 5. Format, Kalite ve Kesit Ayarları ─────────────────────
fmt_row = tk.Frame(main_card, bg=SURFACE)
fmt_row.pack(fill="x", pady=(0, 12))
self.media_seg = SegmentedPill(
fmt_row,
items=[("video", "🎬 Video"), ("audio", "🎵 Ses")],
default_val="video",
on_change=self._on_media_type_changed
)
self.media_seg.pack(side="left")
self.video_opts_frame = tk.Frame(fmt_row, bg=SURFACE)
self.video_opts_frame.pack(side="left", padx=(16, 0))
tk.Label(self.video_opts_frame, text="Format:", bg=SURFACE, fg=SUBTEXT, font=FONT_REGULAR).pack(side="left")
self.video_ext_var = tk.StringVar(value=config.get("video_format", "mp4"))
self.video_ext_cb = ttk.Combobox(
self.video_opts_frame, textvariable=self.video_ext_var,
values=["mp4", "mkv", "webm"], state="readonly", width=7, font=FONT_REGULAR
)
self.video_ext_cb.pack(side="left", padx=(6, 14))
tk.Label(self.video_opts_frame, text="Kalite:", bg=SURFACE, fg=SUBTEXT, font=FONT_REGULAR).pack(side="left")
self.res_var = tk.StringVar(value=config.get("video_quality", "Best Quality (En İyi)"))
self.res_cb = ttk.Combobox(
self.video_opts_frame, textvariable=self.res_var,
values=["Best Quality (En İyi)", "1080p (FHD)", "720p (HD)", "480p", "360p", "160p"],
state="readonly", width=20, font=FONT_REGULAR
)
self.res_cb.pack(side="left", padx=(6, 0))
self.audio_opts_frame = tk.Frame(fmt_row, bg=SURFACE)
tk.Label(self.audio_opts_frame, text="Format:", bg=SURFACE, fg=SUBTEXT, font=FONT_REGULAR).pack(side="left")
self.audio_ext_var = tk.StringVar(value=config.get("audio_format", "mp3"))
self.audio_ext_cb = ttk.Combobox(
self.audio_opts_frame, textvariable=self.audio_ext_var,
values=["mp3", "m4a", "flac", "wav", "opus"], state="readonly", width=7, font=FONT_REGULAR
)
self.audio_ext_cb.pack(side="left", padx=(6, 14))
tk.Label(self.audio_opts_frame, text="Kalite:", bg=SURFACE, fg=SUBTEXT, font=FONT_REGULAR).pack(side="left")
self.audio_qual_var = tk.StringVar(value=config.get("audio_quality", "Best Quality (En İyi)"))
self.audio_qual_cb = ttk.Combobox(
self.audio_opts_frame, textvariable=self.audio_qual_var,
values=["Best Quality (En İyi)", "320 kbps", "256 kbps", "192 kbps", "128 kbps"],
state="readonly", width=18, font=FONT_REGULAR
)
self.audio_qual_cb.pack(side="left", padx=(6, 0))
self.chip_turbo = PillChip(
fmt_row, text="⚡ Hızlı HLS İndirme",
initial_value=True,
on_toggle=lambda v: config.set("concurrent_fragments", 6 if v else 1)
)
self.chip_turbo.pack(side="right")
# VOD Kesit / Zaman Aralığı Satırı
clip_row = tk.Frame(main_card, bg=SURFACE)
clip_row.pack(fill="x", pady=(0, 12))
tk.Label(
clip_row, text="✂️ VOD Kesit İndir (Opsiyonel):",
bg=SURFACE, fg=SUBTEXT, font=FONT_SMALL_BOLD
).pack(side="left")
self.clip_start_var = tk.StringVar()
self.clip_start_entry = ModernEntry(clip_row, textvariable=self.clip_start_var, width=9, placeholder="00:10:00")
self.clip_start_entry.pack(side="left", padx=(8, 4), ipady=2)
tk.Label(clip_row, text="—", bg=SURFACE, fg=SUBTEXT, font=FONT_SMALL).pack(side="left")
self.clip_end_var = tk.StringVar()
self.clip_end_entry = ModernEntry(clip_row, textvariable=self.clip_end_var, width=9, placeholder="00:25:30")
self.clip_end_entry.pack(side="left", padx=(4, 8), ipady=2)
PillButton(clip_row, text="Sıfırla", command=self._clear_clip_range, small=True, style="ghost").pack(side="left")
tk.Label(
clip_row, text="(Uzun VOD yayınlarının sadece istediğiniz dakikalarını indirir)",
bg=SURFACE, fg=MUTED, font=FONT_SMALL
).pack(side="left", padx=(8, 0))
# Kayıt Yeri
dir_row = tk.Frame(main_card, bg=SURFACE)
dir_row.pack(fill="x")
tk.Label(dir_row, text="Kayıt Yeri:", bg=SURFACE, fg=SUBTEXT, font=FONT_REGULAR).pack(side="left", padx=(0, 10))
self.dir_var = tk.StringVar(value=config.get("download_dir"))
ModernEntry(dir_row, textvariable=self.dir_var).pack(side="left", fill="x", expand=True, ipady=4)
PillButton(dir_row, text="📂 Değiştir", command=self._choose_dir, small=True).pack(side="left", padx=(8, 0))
# ── 6. Ana İndirme Butonu ────────────────────────────────────
self.btn_download = PillButton(
scroll_frame,
text="⬇ Kick İçeriğini İndir",
command=self._on_start_click,
style="primary"
)
self.btn_download.pack(fill="x", padx=32, pady=(0, 20), ipady=4)
# ── Etkileşim & Yardımcı Metotlar ────────────────────────────────
def _on_media_type_changed(self, media_type):
if media_type == "video":
self.audio_opts_frame.pack_forget()
self.video_opts_frame.pack(side="left", padx=(16, 0))
else:
self.video_opts_frame.pack_forget()
self.audio_opts_frame.pack(side="left", padx=(16, 0))
def _on_mode_switched(self, mode_key):
self._mode = mode_key
if mode_key == "live":
self.table_container.pack_forget()
self.live_panel.pack(fill="x")
self.btn_Download_selected_batch.pack_forget()
self.btn_download.config(text="🔴 Canlı Yayını Kaydetmeye Başla")
else:
self.live_panel.pack_forget()
self.table_container.pack(fill="both", expand=True)
self.btn_Download_selected_batch.pack(side="right")
self._populate_tree()
if mode_key == "vods":
self.btn_download.config(text="⬇ Seçili VOD Yayınını İndir")
else:
self.btn_download.config(text="⬇ Seçili Klibi İndir")
def _paste_clipboard(self):
try:
clip = self.clipboard_get().strip()
if clip:
self.url_entry.set_text(clip)
self._trigger_lookup()
except Exception:
pass
def _clear_clip_range(self):
self.clip_start_entry.set_text("")
self.clip_end_entry.set_text("")
def _clear_all(self):
self.url_entry.delete(0, "end")
self.url_entry._apply_placeholder()
self.preview_card.pack_forget()
self.channel_bar.pack_forget()
self.lbl_status.config(text="", fg=ACCENT_LIGHT)
self.current_metadata = None
self.channel_data = None
self._vods = []
self._clips = []
self._metadata_url = ""
self._request_id += 1
for item in self.tree.get_children():
self.tree.delete(item)
if self._after_id:
try:
self.after_cancel(self._after_id)
except Exception:
pass
self._after_id = None
def _choose_dir(self):
d = filedialog.askdirectory(initialdir=self.dir_var.get() or config.get("download_dir"))
if d:
self.dir_var.set(d)
config.set("download_dir", d)
def _on_input_changed(self, text):
clean = (text or "").strip()
if clean == self._metadata_url:
return
self._metadata_url = clean
if self._after_id:
try:
self.after_cancel(self._after_id)
except Exception:
pass
self._after_id = None
if len(clean) >= 3:
self._after_id = self.after(550, self._trigger_lookup)
def _get_safe_cookies_args(self):
try:
return resolve_cookies_args(
config.get("cookies_mode", "none"),
config.get("cookies_browser", "chrome"),
config.get("cookies_path", "")
)
except Exception:
return []
def _trigger_lookup(self):
if self._after_id:
try:
self.after_cancel(self._after_id)
except Exception:
pass
self._after_id = None
raw = self.url_entry.get_clean_text()
parsed = parse_kick_input(raw)
ptype = parsed["type"]
if ptype == "empty":
return
self._request_id += 1
req_id = self._request_id
# Eğer doğrudan VOD veya Clip URL'si girildiyse hem önizleme çek hem de kanalı arka planda listele
if ptype in ("vod", "clip"):
self.lbl_status.config(text="⏳ Kick medya bilgileri alınıyor...", fg=ACCENT_LIGHT)
fetch_video_metadata(
parsed["url"],
cookies_args=self._get_safe_cookies_args(),
proxy=config.get("proxy", ""),
callback=lambda meta: self.after(0, self._on_direct_meta_loaded, meta, req_id),
error_callback=lambda err: self.after(0, self._on_lookup_error, err, req_id)
)
if parsed.get("channel"):
fetch_kick_channel_Async(
parsed["channel"],
proxy=config.get("proxy", ""),
callback=lambda ch: self.after(0, self._on_channel_loaded, ch, req_id, False)
)
elif ptype == "channel":
self.lbl_status.config(text=f"⏳ '{parsed['channel']}' kanalı taranıyor (Canlı / VOD / Klip)...", fg=ACCENT_LIGHT)
fetch_kick_channel_Async(
parsed["channel"],
proxy=config.get("proxy", ""),
callback=lambda ch: self.after(0, self._on_channel_loaded, ch, req_id, True),
error_callback=lambda err: self.after(0, self._on_lookup_error, err, req_id)
)
else:
self.lbl_status.config(text="⏳ Bağlantı inceleniyor...", fg=ACCENT_LIGHT)
fetch_video_metadata(
parsed["url"],
cookies_args=self._get_safe_cookies_args(),
proxy=config.get("proxy", ""),
callback=lambda meta: self.after(0, self._on_direct_meta_loaded, meta, req_id),
error_callback=lambda err: self.after(0, self._on_lookup_error, err, req_id)
)
def _on_direct_meta_loaded(self, metadata, req_id):
if req_id != self._request_id:
return
self.current_metadata = metadata
self.lbl_status.config(text="✅ Medya hazır", fg=SUCCESS)
self.preview_card.update_metadata(metadata)
self.preview_card.pack(fill="x", pady=(0, 12), before=self.mode_seg.master)
if metadata.get("resolutions"):
self.res_cb.config(values=metadata["resolutions"])
self.res_var.set(metadata["resolutions"][0])
def _on_channel_loaded(self, ch_data, req_id, auto_switch_mode=True):
if req_id != self._request_id:
return
self.channel_data = ch_data
self._vods = ch_data.get("vods") or []
self._clips = ch_data.get("clips") or []
username = ch_data.get("username") or ch_data.get("slug")
followers = ch_data.get("followers") or 0
is_live = ch_data.get("is_live", False)
live_info = ch_data.get("live_info")
self.lbl_ch_name.config(text=f"🟢 {username} (kick.com/{ch_data.get('slug')})")
if is_live and live_info:
self.lbl_live_badge.config(
text=f"🔴 CANLI YAYINDA · {live_info.get('viewers', 0):,} İzleyici · {live_info.get('category', '')}",
bg=ERROR, fg="#ffffff"
)
self.lbl_live_title.config(text=f"🔴 Şu An Canlı: {live_info.get('title', '')}")
else:
self.lbl_live_badge.config(text="⚫ Çevrimdışı", bg=SURFACE, fg=SUBTEXT)
self.lbl_live_title.config(text=f"⚫ {username} şu anda çevrimdışı (Yayın açılmasını bekleyebilirsiniz)")
self.lbl_ch_stats.config(
text=f"👥 {followers:,} Takipçi | 📼 {len(self._vods)} VOD | ✂️ {len(self._clips)} Klip"
)
self.channel_bar.pack(fill="x", pady=(0, 12), before=self.mode_seg.master)
self.lbl_status.config(
text=f"✅ {len(self._vods)} VOD ve {len(self._clips)} Klip yüklendi",
fg=SUCCESS
)
self._populate_tree()
if auto_switch_mode:
if is_live and not self._vods:
self.mode_seg.select("live")
elif self._mode == "vods" and not self._vods and self._clips:
self.mode_seg.select("clips")
def _on_lookup_error(self, err, req_id):
if req_id != self._request_id:
return
self.lbl_status.config(text="⚠️ Kanal veya medya bilgisi alınamadı", fg=WARNING)
def _populate_tree(self):
for item in self.tree.get_children():
self.tree.delete(item)
if self._mode == "vods":
for idx, v in enumerate(self._vods):
tag_label = "🔴 Canlı VOD" if v.get("is_live") else f"📼 {v.get('category', 'VOD')}"
views_str = f"{v.get('views', 0):,}"
self.tree.insert(
"", "end", iid=f"vod_{idx}",
values=(tag_label, v.get("title", "—"), v.get("duration", "—"), views_str, v.get("date", "—"))
)
elif self._mode == "clips":
for idx, c in enumerate(self._clips):
cat = c.get("category") or "Klip"
views_str = f"👁 {c.get('views', 0):,}"
self.tree.insert(
"", "end", iid=f"clip_{idx}",
values=(f"✂️ {cat}", c.get("title", "—"), c.get("duration", "—"), views_str, c.get("date", "—"))
)
def _on_tree_selected(self, event=None):
sel = self.tree.selection()
if not sel:
return
first_iid = sel[0]
item_obj = self._resolve_tree_iid(first_iid)
if not item_obj:
return
if len(sel) > 1:
self.btn_download.config(text=f"⬇ Seçili {len(sel)} Öğeyi Sırayla İndir")
else:
title_short = (item_obj.get("title") or "İçerik")[:48]
self.btn_download.config(text=f"⬇ İndir: {title_short}")
def _resolve_tree_iid(self, iid: str):
if iid.startswith("vod_"):
idx = int(iid.split("_", 1)[1])
if 0 <= idx < len(self._vods):
return self._vods[idx]
elif iid.startswith("clip_"):
idx = int(iid.split("_", 1)[1])
if 0 <= idx < len(self._clips):
return self._clips[idx]
return None
def _build_common_options(self, is_live=False, title=None):
media_type = self.media_seg.get()
return {
"mode": "single",
"media_type": media_type,
"format": self.video_ext_var.get() if media_type == "video" else self.audio_ext_var.get(),
"quality": self.res_var.get() if media_type == "video" else self.audio_qual_var.get(),
"embed_subtitles": False,
"embed_thumbnail": config.get("embed_thumbnail", True) and not is_live,
"concurrent_fragments": 6 if self.chip_turbo.get() else 1,
"add_metadata": config.get("add_metadata", True),
"speed_limit": config.get("speed_limit", ""),
"ignore_errors": True,
"sponsorblock_remove": False,
"use_download_archive": False,
"clip_start": "" if is_live else self.clip_start_entry.get_clean_text(),
"clip_end": "" if is_live else self.clip_end_entry.get_clean_text(),
"is_live": is_live,
"wait_for_video": self.chip_wait_live.get() if is_live else False,
"live_from_start": self.chip_live_from_start.get() if is_live else False,
"title": title,
}
def _on_download_selected_items(self):
sel = self.tree.selection()
if not sel:
messagebox.showinfo("Bilgi", "Lütfen listeden en az bir VOD veya Klip seçin.", parent=self)
return
self._trigger_tree_download(sel)
def _trigger_tree_download(self, sel_iids):
out_dir = self.dir_var.get().strip() or config.get("download_dir")
config.set("download_dir", out_dir)
selected_items = [self._resolve_tree_iid(iid) for iid in sel_iids]
selected_items = [it for it in selected_items if it and it.get("url")]
if not selected_items:
return
if len(selected_items) == 1:
it = selected_items[0]
opts = self._build_common_options(is_live=False, title=it.get("title"))
if self.on_download_requested:
self.on_download_requested(it["url"], out_dir, opts)
else:
# Çoklu seçim -> Toplu indirme motoruna ilet
opts = self._build_common_options(is_live=False)
opts["mode"] = "batch"
pending = [
{"idx": i + 1, "url": it["url"], "status": "⏳ Bekliyor"}
for i, it in enumerate(selected_items)
]
if self.on_batch_requested:
self.on_batch_requested(pending, out_dir, opts, lambda idx, st: None)
def _on_start_click(self):
out_dir = self.dir_var.get().strip() or config.get("download_dir")
config.set("download_dir", out_dir)
# 1. Eğer tabloda seçili öğe(ler) varsa ve Canlı modda değilsek onu indir
sel = self.tree.selection()
if self._mode in ("vods", "clips") and sel:
self._trigger_tree_download(sel)
return
# 2. Canlı yayın modundaysak veya doğrudan URL girildiyse
raw = self.url_entry.get_clean_text()
parsed = parse_kick_input(raw)
if parsed["type"] == "empty":
messagebox.showwarning(
"Uyarı",
"Lütfen bir Kick kanal adı (örn: elraenn, xqc) veya Kick VOD/Clip bağlantısı girin.",
parent=self
)
return
if self._mode == "live" or parsed["type"] == "channel":
target_url = self.channel_data.get("channel_url") if self.channel_data else parsed["url"]
live_title = None
if self.channel_data and self.channel_data.get("live_info"):
live_title = self.channel_data["live_info"].get("title")
elif self.channel_data:
live_title = f"{self.channel_data.get('username', 'Kick')} Canlı Yayın"
# Eğer kullanıcı VOD/Clips sekmesindeyken kanal adı yazıp doğrudan İndir'e bastıysa ve listede VOD varsa ilkini seçebilir veya canlı yayın kaydı başlatabilir
if self._mode in ("vods", "clips") and not sel and (self._vods or self._clips):
messagebox.showinfo(
"Seçim Yapın",
"Kanal içerikleri listelendi! Lütfen tablodan indirmek istediğiniz VOD veya Klibe tıklayın ya da '🔴 Canlı Yayın Kaydı' sekmesine geçin.",
parent=self
)
return
opts = self._build_common_options(is_live=True, title=live_title)
if self.on_download_requested:
self.on_download_requested(target_url, out_dir, opts)
return
# Doğrudan VOD veya Clip bağlantısı
title = self.current_metadata.get("title") if self.current_metadata else None
is_live = bool(self.current_metadata.get("is_live")) if self.current_metadata else False
opts = self._build_common_options(is_live=is_live, title=title)
if self.on_download_requested:
self.on_download_requested(parsed["url"], out_dir, opts)