|
| 1 | +# y2mp3 v4.0.0 β Development Plan |
| 2 | + |
| 3 | +## Project |
| 4 | +Full rewrite of [y2mp3](https://github.com/moshfeu/y2mp3) β replacing the old |
| 5 | +Webpack/React 16/MobX/ytdl-core stack with Electron-Vite + React 18 + Tailwind CSS + |
| 6 | +Shadcn/ui + yt-dlp. |
| 7 | + |
| 8 | +**Branch:** `feat/electron-vite-rewrite` |
| 9 | +**Working folder:** `/Users/moshef/Documents/projects/y2mp3` |
| 10 | +**Node version:** Must use Node v20 (`fnm use 20`). Node v24 + Yarn v1 has an EBADF bug. |
| 11 | +**Registry:** `~/.yarnrc` points to Wix Artifactory β **VPN required for `yarn install`**. |
| 12 | +Before pushing to GitHub, sanitize yarn.lock: |
| 13 | +```bash |
| 14 | +sed -i '' 's|https://npm.dev.wixpress.com/api/npm/npm-repos/|https://registry.yarnpkg.com/|g' yarn.lock |
| 15 | +``` |
| 16 | + |
| 17 | +## Run / Build |
| 18 | +```bash |
| 19 | +fnm use 20 |
| 20 | +yarn dev # Electron + Vite dev server |
| 21 | +yarn build # Production build (outputs to out/) |
| 22 | +yarn dist:mac # Package as .dmg |
| 23 | +``` |
| 24 | + |
| 25 | +## Current Status |
| 26 | +The app is fully functional for single video downloads. Core features are done: |
| 27 | +- β
Electron-Vite + React 18 + TypeScript scaffold |
| 28 | +- β
Tailwind CSS + Shadcn/ui components |
| 29 | +- β
yt-dlp backend (checkDependencies, getVideoInfo, downloadAudio) |
| 30 | +- β
Download form with live step-by-step log and progress bar |
| 31 | +- β
Download history with search and reveal in Finder |
| 32 | +- β
Settings panel (output path, format, quality, theme) |
| 33 | +- β
Light/dark/system theme toggle |
| 34 | +- β
Playlist backend (isPlaylistUrl, getPlaylistInfo, per-item callbacks) |
| 35 | +- π² Playlist support UI (next task β see Phase 11 below) |
| 36 | +- π² QA / thorough testing |
| 37 | +- π² Packaging for distribution |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## Key Technical Notes |
| 42 | + |
| 43 | +### Electron-Vite + `"type": "module"` |
| 44 | +`package.json` has `"type": "module"` β preload builds to `out/preload/index.mjs`. |
| 45 | +`electron/main.ts` references `index.mjs` (not `.js`). |
| 46 | + |
| 47 | +### yt-dlp PATH in Electron |
| 48 | +Electron's `exec()` doesn't inherit the shell PATH on macOS. `EXEC_ENV` in |
| 49 | +`electron/download.ts` adds explicit paths: `/opt/homebrew/bin`, `/usr/local/bin`, |
| 50 | +`~/.pyenv/shims`, `~/.local/bin`. |
| 51 | + |
| 52 | +### electron-store v8 (ESM-only) |
| 53 | +Main process uses dynamic import: `const { default: Store } = await import('electron-store')` |
| 54 | + |
| 55 | +### yt-dlp info fetch |
| 56 | +Uses `--print` with specific fields (NOT `-j`) to avoid maxBuffer overflow: |
| 57 | +``` |
| 58 | +yt-dlp --print "%(id)s\n%(title)s\n%(uploader)s\n%(duration)s\n%(thumbnail)s" --no-playlist URL |
| 59 | +``` |
| 60 | + |
| 61 | +### Playlist detection |
| 62 | +`isPlaylistUrl(url)` returns true for `youtube.com/playlist?list=...`. |
| 63 | +`watch?v=...&list=...` is currently treated as single video (user chose a specific video). |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## Phase 11: Playlist Support UI (remaining work) |
| 68 | + |
| 69 | +Backend is fully implemented in `electron/download.ts` and `electron/main.ts`. |
| 70 | +All that remains is updating `src/components/DownloadForm.tsx`. |
| 71 | + |
| 72 | +### IPC events already wired up (backend β renderer) |
| 73 | +- `download-item-start` β `{ index, title }` |
| 74 | +- `download-item-done` β `{ index, filepath, filename, filesize }` |
| 75 | +- `download-item-error` β `{ index, title, error }` |
| 76 | + |
| 77 | +Preload (`electron/preload.ts`) already exposes: |
| 78 | +- `window.electronAPI.onItemStart(cb)` |
| 79 | +- `window.electronAPI.onItemDone(cb)` |
| 80 | + |
| 81 | +### 11.1 Detect playlist URL (`playlist-detection`) |
| 82 | +In `DownloadForm.tsx`: when `getVideoInfo` returns `result.playlist`, switch UI to |
| 83 | +playlist mode instead of showing single-video card. |
| 84 | + |
| 85 | +### 11.2 Playlist preview card (`playlist-preview-ui`) |
| 86 | +- Show playlist title and total count |
| 87 | +- Scrollable list of first 10 entries (index + title); "...and N more" if > 10 |
| 88 | +- Download button label: `"Download Playlist (N videos)"` |
| 89 | + |
| 90 | +### 11.3 Playlist download progress UX (`playlist-download-ux`) |
| 91 | +- Header: `"Downloading 3 / 42 β Song Title"` |
| 92 | +- Compact entry list with status icons: |
| 93 | + - `Β·` pending, `β³` active, `β` done, `β` failed |
| 94 | +- Per-item progress bar under the currently active entry |
| 95 | +- Subscribe to `onItemStart` / `onItemDone` events |
| 96 | + |
| 97 | +### 11.4 Mixed URL handling (`playlist-mixed-url`) |
| 98 | +When URL has both `?v=` and `&list=`, offer a choice: |
| 99 | +- "Download this video only" |
| 100 | +- "Download full playlist" |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## Remaining Tasks |
| 105 | + |
| 106 | +| # | Task | Status | |
| 107 | +|---|------|--------| |
| 108 | +| 1 | Detect playlist URL in DownloadForm | π² pending | |
| 109 | +| 2 | Build playlist preview card UI | π² pending (depends on 1) | |
| 110 | +| 3 | Playlist download progress UX | π² pending (depends on 2) | |
| 111 | +| 4 | Handle `watch?v=...&list=...` URLs | π² pending | |
| 112 | +| 5 | QA β test all flows | π² pending | |
| 113 | +| 6 | Package for distribution (dmg/exe/AppImage) | π² pending | |
| 114 | + |
| 115 | +--- |
| 116 | + |
| 117 | +## File Map |
| 118 | + |
| 119 | +| File | Purpose | |
| 120 | +|------|---------| |
| 121 | +| `electron/main.ts` | IPC handlers, store management | |
| 122 | +| `electron/download.ts` | yt-dlp wrapper (all download/info logic) | |
| 123 | +| `electron/preload.ts` | contextBridge β ElectronAPI exposed to renderer | |
| 124 | +| `src/types/index.ts` | All shared types (PlaylistInfo, DownloadProgress, etc.) | |
| 125 | +| `src/App.tsx` | Tab nav, settings/history loading, theme | |
| 126 | +| `src/components/DownloadForm.tsx` | Main download UI β **primary file for playlist UI work** | |
| 127 | +| `src/components/DownloadHistory.tsx` | History list with search | |
| 128 | +| `src/components/SettingsPanel.tsx` | Settings form | |
| 129 | +| `src/components/ui/` | Shadcn components | |
0 commit comments