feat(kick): add dedicated Kick Live, VOD and Clips downloader & channel explorer tab (v3.5.0)
This commit is contained in:
parent
947feaa037
commit
80b0bf4fd2
10 changed files with 1018 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# LDownloader v3.4.0 🎬🎵
|
||||
# LDownloader v3.5.0 🎬🎵
|
||||
|
||||
[](LICENSE)
|
||||
[](https://github.com/LilDosto/LDownloader/releases)
|
||||
|
|
@ -45,6 +45,11 @@
|
|||
* Oynatma listelerini sıralı klasör yapısıyla (`Playlist Adı / 01 - Video.mp4`) kaydeder.
|
||||
* Başlangıç ve bitiş indeks aralığı belirleyebilir, hatalı/gizli videoları atlayarak indirmeye devam edebilirsiniz.
|
||||
|
||||
### 9. 🟢 Kick Canlı Yayın, VOD & Clips İndirici
|
||||
* **Kanal Tarayıcısı (Keşif Modu)**: Sadece yayıncının kanal adını (örn: `elraenn`, `xqc`) yazarak kanalın canlı yayın durumunu, tüm geçmiş yayınlarını (**VOD**) ve popüler kliplerini (**Clips**) uygulama içinden listeleyebilirsiniz.
|
||||
* **Canlı Yayın Kaydedici**: Devam eden canlı yayınları gerçek zamanlı olarak kaydeder, yayını baştan alma (DVR) ve çevrimdışı yayıncının yayına girmesini otomatik bekleme seçenekleri sunar.
|
||||
* **VOD Kesit Alma**: Saatler süren yayın tekrarlarının tamamını indirmek yerine yalnızca istediğiniz zaman aralığını (örn: `00:10:00` - `00:25:30`) kesip indirebilirsiniz.
|
||||
|
||||
---
|
||||
|
||||
## 📁 Proje Mimarisi
|
||||
|
|
@ -114,7 +119,7 @@ LDownloader'ı iki farklı şekilde kullanabilirsiniz:
|
|||
|
||||
Uygulamayı ve kurulum sihirbazını yerel olarak derlemek için:
|
||||
* `build_exe.bat` dosyasına çift tıklayın veya çalıştırın:
|
||||
* Derleme sonucunda `dist/` klasöründe hem taşınabilir `LDownloader.exe` hem de `LDownloader-v3.4.0-Setup.exe` üretilecektir.
|
||||
* Derleme sonucunda `dist/` klasöründe hem taşınabilir `LDownloader.exe` hem de `LDownloader-v3.5.0-Setup.exe` üretilecektir.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,16 @@ DIAGNOSTIC_RULES = [
|
|||
"keywords": ["failed to decrypt with dpapi", "dpapi"],
|
||||
"title": "🔐 Windows DPAPI Koruması",
|
||||
"solution": "Windows güvenlik koruması (DPAPI) nedeniyle tarayıcıdan doğrudan çerez çekilemedi. Çözüm: 1) Normal videolarda çerez gerekmez, Çerezleri 'Kapalı' yapabilirsiniz. 2) Yaş kısıtlamalı videolar için tarayıcınıza 'Get cookies.txt' eklentisi kurup dışa aktardığınız dosyayı yükleyin."
|
||||
},
|
||||
{
|
||||
"keywords": ["unable to download video subtitles", "http error 429", "too many requests"],
|
||||
"title": "⏳ Altyazı / İstek Kotası Aşıldı (HTTP 429)",
|
||||
"solution": "Sunucu çok fazla altyazı veya veri isteğini geçici olarak kısıtladı. 'Altyazı göm' seçeneğini kapatarak videoyu hemen indirebilir veya Ayarlar'dan çerez (cookies.txt) ekleyerek kotayı aşabilirsiniz."
|
||||
},
|
||||
{
|
||||
"keywords": ["the channel is not currently live", "usernotlive"],
|
||||
"title": "📡 Yayıncı Şu Anda Çevrimdışı",
|
||||
"solution": "Bu Kick/Twitch kanalı şu anda canlı yayında değil. Geçmiş yayınları (VOD) veya klipleri (Clips) sekmeden seçerek indirebilir ya da 'Yayın Açılmasını Bekle' seçeneğini aktif edebilirsiniz."
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,19 @@ class DownloadEngine:
|
|||
def _do_kill():
|
||||
try:
|
||||
if sys.platform == "win32":
|
||||
# Canlı yayın kaydında FFmpeg'in MP4 moov atomunu yazıp dosyayı sağlam kapatması için
|
||||
# önce nazik sonlandırma (/F olmadan) dene, 2.5sn içinde kapanmazsa /F ile zorla kapat.
|
||||
subprocess.run(
|
||||
["taskkill", "/T", "/PID", str(proc.pid)],
|
||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL
|
||||
)
|
||||
try:
|
||||
proc.wait(timeout=2.5)
|
||||
return
|
||||
except subprocess.TimeoutExpired:
|
||||
pass
|
||||
subprocess.run(
|
||||
["taskkill", "/F", "/T", "/PID", str(proc.pid)],
|
||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||
|
|
@ -52,7 +65,11 @@ class DownloadEngine:
|
|||
stderr=subprocess.DEVNULL
|
||||
)
|
||||
else:
|
||||
proc.kill()
|
||||
proc.terminate()
|
||||
try:
|
||||
proc.wait(timeout=2.5)
|
||||
except subprocess.TimeoutExpired:
|
||||
proc.kill()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
|
@ -361,6 +378,14 @@ def build_command(url, output_dir, options):
|
|||
if clip_section:
|
||||
cmd += ["--download-sections", clip_section]
|
||||
|
||||
# Canlı Yayın & HLS (Kick / Twitch / YouTube Live) seçenekleri
|
||||
if options.get("is_live"):
|
||||
cmd += ["--hls-use-mpegts", "--no-part"]
|
||||
if options.get("wait_for_video"):
|
||||
cmd += ["--wait-for-video", "15"]
|
||||
if options.get("live_from_start"):
|
||||
cmd.append("--live-from-start")
|
||||
|
||||
safe_output_dir = os.path.abspath(output_dir or os.getcwd())
|
||||
|
||||
# Playlist aralığı
|
||||
|
|
|
|||
216
core/kick.py
Normal file
216
core/kick.py
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
import re
|
||||
import threading
|
||||
from core.metadata import format_duration
|
||||
|
||||
_KICK_URL_RE = re.compile(
|
||||
r"^https?://(?:www\.)?kick\.com/"
|
||||
r"(?P<channel>[\w-]+)"
|
||||
r"(?:(?P<rest>/videos/[\da-f-]+|/clips/clip_[\w-]+|/?\?(?:[^#]+&)?clip=clip_[\w-]+))?",
|
||||
re.IGNORECASE
|
||||
)
|
||||
|
||||
|
||||
def parse_kick_input(raw_input: str) -> dict:
|
||||
"""
|
||||
Kullanıcı girdisini ayrıştırır:
|
||||
- Kanal adı (örn: 'elraenn', '@xqc', 'https://kick.com/xqc') -> {'type': 'channel', 'channel': 'xqc', 'url': 'https://kick.com/xqc'}
|
||||
- VOD URL -> {'type': 'vod', 'channel': '...', 'url': '...'}
|
||||
- Clip URL -> {'type': 'clip', 'channel': '...', 'url': '...'}
|
||||
"""
|
||||
text = (raw_input or "").strip()
|
||||
if not text:
|
||||
return {"type": "empty", "channel": "", "url": ""}
|
||||
|
||||
# Doğrudan URL kontrolü
|
||||
if text.startswith(("http://", "https://", "kick.com/", "www.kick.com/")):
|
||||
if not text.startswith(("http://", "https://")):
|
||||
text = "https://" + text
|
||||
|
||||
m = _KICK_URL_RE.match(text)
|
||||
if m:
|
||||
channel = m.group("channel").lower()
|
||||
rest = (m.group("rest") or "").lower()
|
||||
if "/videos/" in rest:
|
||||
return {"type": "vod", "channel": channel, "url": text}
|
||||
if "clip_" in rest:
|
||||
return {"type": "clip", "channel": channel, "url": text}
|
||||
if channel not in ("video", "categories", "search", "auth"):
|
||||
return {"type": "channel", "channel": channel, "url": f"https://kick.com/{channel}"}
|
||||
return {"type": "url", "channel": "", "url": text}
|
||||
|
||||
# Kanal kullanıcı adı (örn: 'xqc' veya '@xqc')
|
||||
slug = text.lstrip("@").strip("/").split("/")[0].strip()
|
||||
if re.match(r"^[\w-]+$", slug):
|
||||
return {"type": "channel", "channel": slug.lower(), "url": f"https://kick.com/{slug.lower()}"}
|
||||
|
||||
return {"type": "unknown", "channel": "", "url": text}
|
||||
|
||||
|
||||
def _kick_api_get(endpoint: str, proxy: str = None, timeout: int = 15):
|
||||
"""
|
||||
Kick API v2 endpoint'ine Cloudflare TLS parmak izi (impersonate) ile istek atar.
|
||||
Öncelikle curl_cffi kullanır, yoksa yt_dlp üzerinden fallback yapar.
|
||||
"""
|
||||
url = f"https://kick.com/api/{endpoint.lstrip('/')}"
|
||||
headers = {
|
||||
"Accept": "application/json, text/plain, */*",
|
||||
"Accept-Language": "tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7",
|
||||
"Referer": "https://kick.com/",
|
||||
}
|
||||
|
||||
# 1. Yöntem: curl_cffi (Chrome TLS Impersonation - Cloudflare Bypass)
|
||||
try:
|
||||
from curl_cffi import requests as creq
|
||||
proxies = {"http": proxy, "https": proxy} if proxy else None
|
||||
resp = creq.get(
|
||||
url,
|
||||
headers=headers,
|
||||
impersonate="chrome",
|
||||
proxies=proxies,
|
||||
timeout=timeout
|
||||
)
|
||||
if resp.status_code == 200:
|
||||
return resp.json()
|
||||
if resp.status_code == 404:
|
||||
raise ValueError("Kick kanalı veya içerik bulunamadı (404).")
|
||||
except ValueError:
|
||||
raise
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 2. Yöntem: yt_dlp içsel impersonate istemcisi
|
||||
import yt_dlp
|
||||
from yt_dlp.networking.impersonate import ImpersonateTarget
|
||||
ydl_opts = {
|
||||
"quiet": True,
|
||||
"no_warnings": True,
|
||||
"socket_timeout": timeout,
|
||||
"impersonate": ImpersonateTarget.from_str("chrome"),
|
||||
}
|
||||
if proxy:
|
||||
ydl_opts["proxy"] = proxy
|
||||
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
return ydl._download_json(url, endpoint, note=False, headers=headers)
|
||||
|
||||
|
||||
def fetch_kick_channel_Async(channel_slug: str, proxy: str = None, callback=None, error_callback=None):
|
||||
"""
|
||||
Kick kanalının canlı yayın durumunu, geçmiş yayınlarını (VODs) ve kliplerini (Clips)
|
||||
arka planda tek seferde çeker.
|
||||
"""
|
||||
slug = (channel_slug or "").strip().lstrip("@").lower()
|
||||
if not slug:
|
||||
if error_callback:
|
||||
error_callback("Geçerli bir Kick kanal adı girin.")
|
||||
return
|
||||
|
||||
def _worker():
|
||||
try:
|
||||
ch_data = _kick_api_get(f"v2/channels/{slug}", proxy=proxy)
|
||||
if not ch_data or not isinstance(ch_data, dict):
|
||||
raise ValueError(f"'{slug}' kanalı bulunamadı.")
|
||||
|
||||
user_obj = ch_data.get("user") or {}
|
||||
username = user_obj.get("username") or ch_data.get("slug") or slug
|
||||
followers = ch_data.get("followers_count") or 0
|
||||
avatar_url = user_obj.get("profile_pic") or ""
|
||||
|
||||
livestream = ch_data.get("livestream")
|
||||
is_live = bool(livestream and isinstance(livestream, dict))
|
||||
live_info = None
|
||||
if is_live:
|
||||
cats = livestream.get("categories") or []
|
||||
cat_name = cats[0].get("name", "Canlı Yayın") if cats and isinstance(cats[0], dict) else "Canlı Yayın"
|
||||
thumb_obj = livestream.get("thumbnail")
|
||||
thumb_url = thumb_obj.get("url") if isinstance(thumb_obj, dict) else (thumb_obj if isinstance(thumb_obj, str) else "")
|
||||
live_info = {
|
||||
"id": str(livestream.get("id") or slug),
|
||||
"title": livestream.get("session_title") or f"{username} Canlı Yayını",
|
||||
"viewers": livestream.get("viewer_count") or 0,
|
||||
"category": cat_name,
|
||||
"created_at": (livestream.get("created_at") or "")[:16].replace("T", " "),
|
||||
"thumbnail": thumb_url,
|
||||
"url": f"https://kick.com/{slug}",
|
||||
}
|
||||
|
||||
# 2. VOD (Geçmiş Yayınlar) çek
|
||||
vods_list = []
|
||||
try:
|
||||
raw_vods = _kick_api_get(f"v2/channels/{slug}/videos", proxy=proxy) or []
|
||||
if isinstance(raw_vods, list):
|
||||
for v in raw_vods:
|
||||
if not isinstance(v, dict):
|
||||
continue
|
||||
vid_obj = v.get("video") or {}
|
||||
uuid = vid_obj.get("uuid") or v.get("uuid")
|
||||
if not uuid:
|
||||
continue
|
||||
dur_ms = v.get("duration") or 0
|
||||
# Kick API VOD duration milisaniye cinsindendir
|
||||
dur_sec = dur_ms / 1000.0 if dur_ms > 36000 else dur_ms
|
||||
cats = v.get("categories") or []
|
||||
cat_name = cats[0].get("name", "—") if cats and isinstance(cats[0], dict) else "—"
|
||||
created_raw = (v.get("created_at") or v.get("start_time") or "")[:16].replace("T", " ")
|
||||
vods_list.append({
|
||||
"uuid": uuid,
|
||||
"title": v.get("session_title") or "İsimsiz Yayın Tekrarı (VOD)",
|
||||
"duration": format_duration(dur_sec),
|
||||
"views": v.get("views") or 0,
|
||||
"date": created_raw or "—",
|
||||
"category": cat_name,
|
||||
"is_live": bool(v.get("is_live")),
|
||||
"url": f"https://kick.com/{slug}/videos/{uuid}",
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 3. Klipleri (Clips) çek
|
||||
clips_list = []
|
||||
try:
|
||||
raw_clips_resp = _kick_api_get(f"v2/channels/{slug}/clips", proxy=proxy) or {}
|
||||
raw_clips = raw_clips_resp.get("clips") if isinstance(raw_clips_resp, dict) else []
|
||||
if isinstance(raw_clips, list):
|
||||
for c in raw_clips:
|
||||
if not isinstance(c, dict):
|
||||
continue
|
||||
clip_id = c.get("id")
|
||||
if not clip_id:
|
||||
continue
|
||||
cat_obj = c.get("category") or {}
|
||||
creator_obj = c.get("creator") or {}
|
||||
created_raw = (c.get("created_at") or "")[:16].replace("T", " ")
|
||||
clips_list.append({
|
||||
"id": clip_id,
|
||||
"title": c.get("title") or "İsimsiz Klip",
|
||||
"duration": format_duration(c.get("duration") or 0),
|
||||
"views": c.get("view_count") if c.get("view_count") is not None else (c.get("views") or 0),
|
||||
"likes": c.get("likes_count") if c.get("likes_count") is not None else (c.get("likes") or 0),
|
||||
"creator": creator_obj.get("username") or slug,
|
||||
"category": cat_obj.get("name") or "—",
|
||||
"date": created_raw or "—",
|
||||
"url": f"https://kick.com/{slug}/clips/{clip_id}",
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
result = {
|
||||
"slug": slug,
|
||||
"username": username,
|
||||
"followers": followers,
|
||||
"avatar_url": avatar_url,
|
||||
"is_live": is_live,
|
||||
"live_info": live_info,
|
||||
"vods": vods_list,
|
||||
"clips": clips_list,
|
||||
"channel_url": f"https://kick.com/{slug}",
|
||||
}
|
||||
|
||||
if callback:
|
||||
callback(result)
|
||||
|
||||
except Exception as ex:
|
||||
if error_callback:
|
||||
error_callback(str(ex))
|
||||
|
||||
threading.Thread(target=_worker, daemon=True).start()
|
||||
|
|
@ -57,7 +57,14 @@ def fetch_thumbnail_image(url, size=(160, 90)):
|
|||
if not url:
|
||||
return None
|
||||
try:
|
||||
resp = requests.get(url, timeout=10)
|
||||
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"}
|
||||
resp = requests.get(url, headers=headers, timeout=10)
|
||||
if resp.status_code != 200 and "kick.com" in url:
|
||||
try:
|
||||
from curl_cffi import requests as creq
|
||||
resp = creq.get(url, impersonate="chrome", timeout=10)
|
||||
except Exception:
|
||||
pass
|
||||
if resp.status_code == 200:
|
||||
img_data = resp.content
|
||||
img = Image.open(io.BytesIO(img_data))
|
||||
|
|
@ -134,7 +141,8 @@ def fetch_video_metadata(url: str, cookies_args: list = None, proxy: str = None,
|
|||
or info.get("channel")
|
||||
or "Bilinmeyen Kanal"
|
||||
)
|
||||
duration = format_duration(first_entry.get("duration") or info.get("duration"))
|
||||
is_live = bool(first_entry.get("is_live") or info.get("is_live"))
|
||||
duration = "🔴 CANLI YAYIN" if is_live else format_duration(first_entry.get("duration") or info.get("duration"))
|
||||
thumbnail_url = first_entry.get("thumbnail") or info.get("thumbnail")
|
||||
if not thumbnail_url:
|
||||
thumbs = first_entry.get("thumbnails") or info.get("thumbnails") or []
|
||||
|
|
@ -146,6 +154,7 @@ def fetch_video_metadata(url: str, cookies_args: list = None, proxy: str = None,
|
|||
|
||||
metadata = {
|
||||
"is_playlist": is_playlist,
|
||||
"is_live": is_live,
|
||||
"playlist_count": len(entries) if is_playlist else 1,
|
||||
"title": title,
|
||||
"uploader": uploader,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
; Inno Setup Kurulum Senaryosu - LDownloader
|
||||
#define MyAppName "LDownloader"
|
||||
#define MyAppVersion "3.4.0"
|
||||
#define MyAppVersion "3.5.0"
|
||||
#define MyAppPublisher "LilDosto"
|
||||
#define MyAppURL "https://github.com/LilDosto/LDownloader"
|
||||
#define MyAppExeName "LDownloader.exe"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from unittest.mock import patch
|
|||
|
||||
from core.dependencies import resolve_cookies_args
|
||||
from core.downloader import build_command, clip_section_range, playlist_items_range
|
||||
from core.kick import parse_kick_input
|
||||
|
||||
|
||||
class PlaylistItemsRangeTests(unittest.TestCase):
|
||||
|
|
@ -171,5 +172,47 @@ class CookieResolutionTests(unittest.TestCase):
|
|||
resolve_cookies_args("file", cookies_file="Seçilmedi")
|
||||
|
||||
|
||||
class KickSupportTests(unittest.TestCase):
|
||||
def test_parse_kick_channel_slug_and_urls(self):
|
||||
res_slug = parse_kick_input("xqc")
|
||||
self.assertEqual(res_slug["type"], "channel")
|
||||
self.assertEqual(res_slug["channel"], "xqc")
|
||||
self.assertEqual(res_slug["url"], "https://kick.com/xqc")
|
||||
|
||||
res_at = parse_kick_input("@Elraenn")
|
||||
self.assertEqual(res_at["type"], "channel")
|
||||
self.assertEqual(res_at["channel"], "elraenn")
|
||||
|
||||
res_vod = parse_kick_input("https://kick.com/xqc/videos/5c697a87-afce-4256-b01f-3c8fe71ef5cb")
|
||||
self.assertEqual(res_vod["type"], "vod")
|
||||
self.assertEqual(res_vod["channel"], "xqc")
|
||||
|
||||
res_clip = parse_kick_input("https://kick.com/spreen/clips/clip_01J8RGZRKHXHXXKJEHGRM932A5")
|
||||
self.assertEqual(res_clip["type"], "clip")
|
||||
self.assertEqual(res_clip["channel"], "spreen")
|
||||
|
||||
res_clip_q = parse_kick_input("https://kick.com/mxddy?clip=clip_01GYXVB5Y8PWAPWCWMSBCFB05X")
|
||||
self.assertEqual(res_clip_q["type"], "clip")
|
||||
self.assertEqual(res_clip_q["channel"], "mxddy")
|
||||
|
||||
@patch("core.downloader.get_ytdlp_cmd", return_value=["yt-dlp"])
|
||||
@patch("core.downloader.get_ffmpeg_dir", return_value=None)
|
||||
def test_live_stream_flags_are_applied(self, *_mocks):
|
||||
cmd = build_command(
|
||||
"https://kick.com/xqc",
|
||||
"C:\\Downloads",
|
||||
{
|
||||
"mode": "single",
|
||||
"is_live": True,
|
||||
"wait_for_video": True,
|
||||
"live_from_start": True,
|
||||
},
|
||||
)
|
||||
self.assertIn("--hls-use-mpegts", cmd)
|
||||
self.assertIn("--no-part", cmd)
|
||||
self.assertIn("--wait-for-video", cmd)
|
||||
self.assertIn("--live-from-start", cmd)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
31
ui/app.py
31
ui/app.py
|
|
@ -16,6 +16,7 @@ from ui.components import TabButton, PillButton, ContextualDownloadDrawer
|
|||
from ui.tabs.single_tab import SingleTab
|
||||
from ui.tabs.playlist_tab import PlaylistTab
|
||||
from ui.tabs.batch_tab import BatchTab
|
||||
from ui.tabs.kick_tab import KickTab
|
||||
from ui.tabs.history_tab import HistoryTab
|
||||
from ui.tabs.settings_tab import SettingsTab
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ from core.dependencies import get_ytdlp_status, get_ffmpeg_status, get_js_status
|
|||
class LDownloaderApp(tk.Tk):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.title("LDownloader v3.4.0")
|
||||
self.title("LDownloader v3.5.0")
|
||||
self.geometry("980x660")
|
||||
self.minsize(880, 580)
|
||||
self.configure(bg=BG)
|
||||
|
|
@ -110,7 +111,7 @@ class LDownloaderApp(tk.Tk):
|
|||
if self.logo_img:
|
||||
tk.Label(brand_frame, image=self.logo_img, bg=TAB_BG).pack(side="left", padx=(0, 8))
|
||||
|
||||
tk.Label(brand_frame, text="LDownloader v3.4.0", font=FONT_TITLE, bg=TAB_BG, fg=TEXT).pack(side="left")
|
||||
tk.Label(brand_frame, text="LDownloader v3.5.0", font=FONT_TITLE, bg=TAB_BG, fg=TEXT).pack(side="left")
|
||||
|
||||
# Orta: Sekmeler
|
||||
self.nav_buttons = {}
|
||||
|
|
@ -118,6 +119,7 @@ class LDownloaderApp(tk.Tk):
|
|||
("single", "▶", "Tekli"),
|
||||
("playlist", "≡", "Playlist"),
|
||||
("batch", "+", "Toplu"),
|
||||
("kick", "🟢", "Kick"),
|
||||
("history", "↺", "Geçmiş"),
|
||||
("settings", "⚙", "Ayarlar")
|
||||
]
|
||||
|
|
@ -187,6 +189,12 @@ class LDownloaderApp(tk.Tk):
|
|||
on_batch_requested=self.start_batch_download,
|
||||
on_open_settings=lambda: self.switch_tab("settings")
|
||||
),
|
||||
"kick": KickTab(
|
||||
self.content_container,
|
||||
on_download_requested=self.start_single_download,
|
||||
on_batch_requested=self.start_batch_download,
|
||||
on_open_settings=lambda: self.switch_tab("settings")
|
||||
),
|
||||
"history": HistoryTab(self.content_container),
|
||||
"settings": SettingsTab(self.content_container, on_dependency_updated=self._on_deps_updated)
|
||||
}
|
||||
|
|
@ -248,6 +256,15 @@ class LDownloaderApp(tk.Tk):
|
|||
"queue": [dict(item) for item in batch.queue],
|
||||
}
|
||||
|
||||
kick_tab = self.tabs.get("kick")
|
||||
if kick_tab:
|
||||
state["kick"] = {
|
||||
"url": kick_tab.url_entry.get_clean_text(),
|
||||
"dir": kick_tab.dir_var.get(),
|
||||
"mode": kick_tab.mode_seg.get(),
|
||||
"media": kick_tab.media_seg.get(),
|
||||
}
|
||||
|
||||
history_tab = self.tabs.get("history")
|
||||
if history_tab:
|
||||
state["history_search"] = history_tab.search_entry.get_clean_text()
|
||||
|
|
@ -320,6 +337,16 @@ class LDownloaderApp(tk.Tk):
|
|||
)
|
||||
batch.lbl_queue_count.config(text=f"Kuyruk · {len(batch.queue)} öğe")
|
||||
|
||||
kick_state = state.get("kick", {})
|
||||
kick_tab = self.tabs.get("kick")
|
||||
if kick_tab:
|
||||
kick_tab.dir_var.set(kick_state.get("dir", kick_tab.dir_var.get()))
|
||||
kick_tab.mode_seg.select(kick_state.get("mode", "vods"))
|
||||
kick_tab.media_seg.select(kick_state.get("media", "video"))
|
||||
if kick_state.get("url"):
|
||||
kick_tab._metadata_url = kick_state["url"]
|
||||
kick_tab.url_entry.set_text(kick_state["url"])
|
||||
|
||||
self.switch_tab(state.get("active_tab", "single"))
|
||||
if single_state.get("metadata") and single_state.get("url"):
|
||||
single._metadata_url = single_state["url"]
|
||||
|
|
|
|||
671
ui/tabs/kick_tab.py
Normal file
671
ui/tabs/kick_tab.py
Normal file
|
|
@ -0,0 +1,671 @@
|
|||
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)
|
||||
|
|
@ -27,7 +27,10 @@ a = Analysis(
|
|||
'core.diagnostics',
|
||||
'core.downloader',
|
||||
'core.history',
|
||||
'core.kick',
|
||||
'core.metadata',
|
||||
'curl_cffi',
|
||||
'curl_cffi.requests',
|
||||
'ui',
|
||||
'ui.theme',
|
||||
'ui.components',
|
||||
|
|
@ -36,6 +39,7 @@ a = Analysis(
|
|||
'ui.tabs.single_tab',
|
||||
'ui.tabs.playlist_tab',
|
||||
'ui.tabs.batch_tab',
|
||||
'ui.tabs.kick_tab',
|
||||
'ui.tabs.history_tab',
|
||||
'ui.tabs.settings_tab'
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue