diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 91262fd..48703b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,6 +23,12 @@ Thanks for helping. Bug reports, ideas and pull requests are all welcome. Look for issues labelled [`good first issue`](https://github.com/AbdulSamad94/clipsmith/labels/good%20first%20issue). Items on the README roadmap are fair game too; comment on the issue first so two people don't build the same thing. +## UI and design changes + +The whole page is one file, `static/index.html`: plain HTML, CSS and JavaScript, no build step. Edit it and reload the browser. + +For any change to how the page looks or works, include **screenshots or a short screen recording** in the pull request (desktop and phone width), so it can be judged without running it. Keep it accessible: visible labels on every control, a visible keyboard focus ring, buttons at least 44px tall, text contrast of at least 4.5:1, and no information shown by color alone. + ## Tests ``` diff --git a/README.md b/README.md index 32149d3..c30a7ae 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Paste a YouTube link. Clipsmith finds the best 30–60 second moments, crops the 2. **Picks the moments** that open strong, stand on their own and end on a complete thought, and gives each a viral score, a title, an on-screen hook, a caption and hashtags. 3. **Reframes** to 9:16, following the speaker's face. Wide shots get the full frame over a blurred background instead. 4. **Captions** every word as it's spoken, in one of three styles. -5. **Exports** MP4s you can download and upload to YouTube Shorts, TikTok or Reels. +5. **Exports** MP4s you can download, or post and schedule straight to YouTube. ## Install @@ -81,7 +81,16 @@ cd clipsmith - **Windows:** double-click `run.bat` - **macOS / Linux:** `./run.sh` -Then open **http://127.0.0.1:8765**, paste a YouTube link and click **Get clips**. +Then open **http://127.0.0.1:8765**, paste a YouTube link (or drop in a video file) and click **Get clips**. + +## Using it + +- **Clip settings:** pick the number of clips, the clip length and the aspect ratio (9:16, 1:1 or 16:9). Choose a caption style and framing, and switch the opening hook text and pause/"uh" removal on or off. +- **Focus (optional):** describe what the clips should be about, or limit them to part of the video with **From** and **To** (like `12:30`). +- **Progress:** each video shows three steps (get the video, pick the best moments, cut and caption) with what's happening right now. Finished clips appear while the rest are still rendering. +- **Your clips:** each clip shows its rank, length, score, the hook it opens with and why it was picked. **Download** it, **Post to YouTube**, or open the **⋯** menu to copy the caption, post again or delete the clip. Fold any clip into one line with the arrow; posted clips fold by themselves. Older videos start folded too. + +The page works with a keyboard and a screen reader: every control has a label and a visible focus ring, and progress and upload changes are announced. ## How long it takes @@ -108,18 +117,18 @@ On a machine with more RAM or a GPU, try a bigger local model for better picks, - The small local model sometimes gets facts or numbers wrong in titles. **Check titles before posting.** - Face tracking is basic (OpenCV). Fast camera cuts can make the crop lag. -- No direct posting to YouTube yet; you download the MP4 and upload it yourself. +- Posting is built in for YouTube only; for TikTok and Reels, download the MP4 and upload it yourself. ## Roadmap -- [ ] Filler word and silence removal -- [ ] "Prompt to clip": describe the moment you want +- [x] Filler word and silence removal +- [x] "Prompt to clip": describe the moment you want +- [x] Post and schedule directly to YouTube - [ ] Edit clip start/end and caption text before export - [ ] Keyword and emoji highlights in captions - [ ] Brand template (logo, fonts, colours) -- [x] Post and schedule directly to YouTube -Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) and the [`good first issue`](https://github.com/AbdulSamad94/clipsmith/labels/good%20first%20issue) label. If Clipsmith saves you money, a ⭐ helps other people find it. +Contributions are welcome! **Designers especially:** UI/UX ideas are wanted, see [issue #24](https://github.com/AbdulSamad94/clipsmith/issues/24). See [CONTRIBUTING.md](CONTRIBUTING.md) and the [`good first issue`](https://github.com/AbdulSamad94/clipsmith/labels/good%20first%20issue) label. If Clipsmith saves you money, a ⭐ helps other people find it. ## Use responsibly diff --git a/app/main.py b/app/main.py index 845f747..7f6f081 100644 --- a/app/main.py +++ b/app/main.py @@ -355,10 +355,12 @@ async def upload_job( def download_zip(job_id: str) -> FileResponse: with _lock: job = _jobs.get(job_id) + # Copy the list: a clip can be deleted while the zip is being built. + clips = list(job.get("clips") or []) if job else [] if not job: raise HTTPException(404, "Job not found.") d = _job_dir(job_id) - files = [d / Path(c["video"]).name for c in job.get("clips") or []] + files = [d / Path(c["video"]).name for c in clips] files = [f for f in files if f.is_file()] if not files: raise HTTPException(409, "This video has no finished clips yet.") @@ -369,7 +371,10 @@ def download_zip(job_id: str) -> FileResponse: try: with zipfile.ZipFile(tmp, "w", zipfile.ZIP_STORED) as z: for f in files: - z.write(f, f.name) + try: + z.write(f, f.name) + except FileNotFoundError: + continue # deleted from another tab while zipping except BaseException: os.unlink(tmp) raise @@ -408,6 +413,29 @@ def delete_job(job_id: str) -> dict: return {"ok": True} +@app.delete("/api/jobs/{job_id}/clips/{index}") +def delete_clip(job_id: str, index: int) -> dict: + with _lock: + job = _jobs.get(job_id) + if not job: + raise HTTPException(404, "Job not found.") + clips = job.get("clips") or [] + if not 0 <= index < len(clips): + raise HTTPException(404, "Clip not found.") + if job["status"] in ("queued", "running"): + raise HTTPException(409, "This video is still processing.") + # Uploads find their clip by position, so removing one would point them at the wrong clip. + if any((c.get("youtube") or {}).get("status") in ("queued", "uploading") for c in clips): + raise HTTPException(409, "A clip from this video is being posted to YouTube. Wait for it to finish.") + clip = clips.pop(index) + _save(job) + d = _job_dir(job_id) + for url in (clip.get("video"), clip.get("thumb")): + if url: + (d / Path(url).name).unlink(missing_ok=True) + return {"ok": True} + + # ---------- YouTube ---------- class PublishRequest(BaseModel): @@ -419,6 +447,9 @@ class PublishRequest(BaseModel): made_for_kids: bool = False notify_subscribers: bool = True add_source_link: bool = False + # The clip's video path when the dialog opened. Clips are addressed by position, so if one + # was deleted meanwhile this catches a post landing on a different clip. + clip_video: str | None = None @app.get("/api/youtube") @@ -453,6 +484,8 @@ def publish_clip(job_id: str, index: int, req: PublishRequest) -> dict: if not job or not 0 <= index < len(clips): raise HTTPException(404, "Clip not found.") clip = clips[index] + if req.clip_video is not None and req.clip_video != clip.get("video"): + raise HTTPException(409, "This clip changed since you opened it (another clip was deleted). Reload the page and try again.") if (clip.get("youtube") or {}).get("status") in ("queued", "uploading"): raise HTTPException(409, "This clip is already being posted.") source_url = job.get("url") if req.add_source_link and _YT.match(job.get("url") or "") else None diff --git a/docs/ss-mobile.png b/docs/ss-mobile.png new file mode 100644 index 0000000..b8a7c9d Binary files /dev/null and b/docs/ss-mobile.png differ diff --git a/docs/ss.png b/docs/ss.png index ff9ea02..68a2fd1 100644 Binary files a/docs/ss.png and b/docs/ss.png differ diff --git a/docs/youtube-setup.md b/docs/youtube-setup.md index c35517a..21c1f7e 100644 --- a/docs/youtube-setup.md +++ b/docs/youtube-setup.md @@ -75,6 +75,8 @@ Click **Post to YouTube** on any clip. The title, description and hashtags are p - **Add the full video link**: puts a link to the original video between the description and the hashtags (only for clips made from a YouTube link). - Vertical or square videos up to 3 minutes are treated as **Shorts** by YouTube automatically. +While a clip uploads, an **uploads tray** in the bottom-right corner shows its progress (minimize it with the arrow). Keep Clipsmith open until it finishes. Once a clip is posted, its card folds into one line with an **Open on YouTube** link; use the arrow to open it again. To post the same clip again, use the **⋯** menu on the clip. If an upload fails, the clip shows the reason and a **Try again** button. + ## Limits - Google allows **100 uploads per day** per Google Cloud project. diff --git a/static/index.html b/static/index.html index 93501a2..33c5f8d 100644 --- a/static/index.html +++ b/static/index.html @@ -4,16 +4,31 @@ Clipsmith — YouTube to Shorts + + + +
-
Clipsmith
+
Clipsmith
- -
Checking…
+ +
Checking…
+

One long video in.
A batch of Shorts out.

Paste a YouTube link. The best one-minute moments come back cut, reframed to vertical and captioned, ranked by how likely they are to hold a viewer.

-
+ +
- +
-
-
-
-
-
-
-
-
-
+ +
+ +
Upload a video fileDrop it here or click to browse · MP4, MOV, MKV, WebM
+ + +
+ +
+

Clip settings

+
+
+ Number of clips +
+ + + + +
+
+
+ Clip length in seconds +
+ + + + +
+
+
+ Aspect ratio +
+ + + +
+
+
+ + +
+
+
-
-
- - + +
+
+
+ +
+
+ +
+

Focus (optional)

-
+
-
-
+
+
-
+

Only look for clips between these times, like 12:30 or 1:02:03. Leave empty to use the whole video.

+
+ -
-
+
+
+
+ + +
- +
-

Post to YouTube

-
+

Post to YouTube

+
-
-
+
+
+

Separate them with spaces.

-
+
-
+
- -
+ +
Audience (YouTube requires an answer) -
+ -
+
@@ -204,6 +542,7 @@

Post to YouTube