feat: organize nextcloud clips folder structure under date/title_id subfolders

This commit is contained in:
Renato
2026-07-02 19:54:16 +02:00
parent 174b992335
commit 1ecb8d32c8
+16 -4
View File
@@ -206,18 +206,30 @@ async def process_queue(bot):
log.info(f"[queue] Job done. Queue size now: {queue.qsize()}")
def get_yt_id(url: str) -> str:
"""Extract YouTube video ID from URL."""
match = re.search(r"(?:v=|\/shorts\/|\/embed\/|\/v\/|youtu\.be\/)([a-zA-Z0-9_-]{11})", url)
return match.group(1) if match else "unknown"
# ─── Main video processor ─────────────────────────────────────────────────────
async def process_video(bot, url: str):
log.info(f"[process] ===== Starting process_video =====")
log.info(f"[process] URL: {url}")
# 1. Get title
# 1. Extract video ID and Get title
yt_id = get_yt_id(url)
title = await get_video_title(url)
log.info(f"[process] Video title: {title!r}")
log.info(f"[process] Video ID: {yt_id}, Title: {title!r}")
safe = re.sub(r'[<>:"/\\|?*#\s]+', "_", title)[:80] or "video"
folder = f"{safe}_{datetime.now():%Y-%m-%d}"
safe_title = re.sub(r'[<>:"/\\|?*#\s]+', "_", title)[:60].strip("_") or "video"
title_folder = f"{safe_title}_{yt_id}"
date_folder = datetime.now().strftime("%Y-%m-%d")
# Target folder: YYYY-MM-DD/title_id
folder = f"{date_folder}/{title_folder}"
target = f"{NEXTCLOUD_BASE}/{folder}"
os.makedirs(target, exist_ok=True)
log.info(f"[process] Nextcloud target folder: {target}")