Free tools (no login), linked from nav and footer via /tools: - /youtube-transcript-generator: reads the captions a video already has on YouTube (free_tools.py, yt-dlp over the flat-rate static proxies only, never the per-GB proxy, never the GPU). Per-IP limits, global daily cap, 24 h cache, honest "no captions" answer with a CTA to the clip generator. Copy / TXT / SRT export in the browser. - /youtube-tag-generator: tags, 10 titles or a description from a brief, one Gemini text call, rules taken from YouTube's own docs (sourced on the page). - /video-aspect-ratio-converter: 16:9 to 9:16 in the browser with mediabunny and WebCodecs (blur / crop / bars), nothing uploaded. Tool pages keep the form in the static HTML; the behaviour is a Vite entry (dashboard/tools) that vite-plugin-seo resolves by name. New pages /auto-clip and /youtube-automation with real, blurred screenshots of the Autopilot tab and the connect-an-agent card, Autopilot rules from cloud/autopilot.py, plan prices from the billing API and aggregate usage from the ledger (dated). SEO fixes: titles/metas for /how-openshorts-works, /podcast-to-shorts, /mcp and /free-ai-clip-generator (brand queries at pos 1-2 with <1% CTR); a free AI clipper / free clipping website section and FAQ, and contextual "free AI clip generator" anchors from sibling pages and the homepage. Attribution: static pages now write the same first-touch os_attrib key the app writes, so the signup is credited to the page the visit started on (7,481 of 7,481 signups in 30 days said "/"). Signup, CheckoutStarted and Subscribed carry landing_path / referrer_host / utm props in OpenPanel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
112 lines
4.6 KiB
JavaScript
112 lines
4.6 KiB
JavaScript
/* YouTube tag, title and description generator (/youtube-tag-generator).
|
|
*
|
|
* One form, three modes. The brief goes to our API, which makes one Gemini
|
|
* text call per click (rate-limited per IP); rendering and copying are local.
|
|
*/
|
|
import { API_URL, $, el, track, setStatus, copyText, apiError } from './common.js'
|
|
|
|
const TOOL = 'youtube-metadata'
|
|
const form = $('md-form')
|
|
const status = $('md-status')
|
|
const out = $('md-out')
|
|
const submit = $('md-go')
|
|
const LABELS = { tags: 'Generate tags', titles: 'Generate titles', description: 'Generate description' }
|
|
|
|
const mode = () => form.querySelector('input[name="mode"]:checked')?.value || 'tags'
|
|
|
|
function syncMode() {
|
|
submit.textContent = LABELS[mode()]
|
|
}
|
|
|
|
// Deep links: /youtube-tag-generator#titles opens the titles mode.
|
|
const fromHash = (window.location.hash || '').replace('#', '')
|
|
if (LABELS[fromHash]) {
|
|
const radio = form.querySelector(`input[name="mode"][value="${fromHash}"]`)
|
|
if (radio) radio.checked = true
|
|
}
|
|
syncMode()
|
|
form.querySelectorAll('input[name="mode"]').forEach((r) => r.addEventListener('change', () => {
|
|
syncMode()
|
|
history.replaceState(null, '', `#${mode()}`)
|
|
}))
|
|
|
|
function renderTags(data) {
|
|
const joined = data.tags.join(', ')
|
|
out.replaceChildren(
|
|
el('div', { class: 'out-head' },
|
|
el('span', { text: `${data.tags.length} tags · ${data.characters} of 500 characters` }),
|
|
el('button', { type: 'button', class: 'btn-ghost', onclick: (e) => copyText(joined, e.currentTarget), text: 'Copy all' })),
|
|
el('div', { class: 'chips' }, ...data.tags.map((t) =>
|
|
el('button', { type: 'button', class: 'chip', title: 'Copy this tag', onclick: (e) => copyText(t, e.currentTarget), text: t }))),
|
|
el('p', { class: 'tool-hint', text: 'Paste "Copy all" into the Tags field in YouTube Studio (Details, Show more). Remove any tag that does not describe your video.' }),
|
|
)
|
|
}
|
|
|
|
function renderTitles(data) {
|
|
out.replaceChildren(
|
|
el('div', { class: 'out-head' }, el('span', { text: `${data.titles.length} titles. Click one to copy it.` })),
|
|
el('ol', { class: 'title-list' }, ...data.titles.map((t) => el('li', {},
|
|
el('button', { type: 'button', class: 'title-opt', onclick: (e) => copyText(t.title, e.currentTarget.querySelector('.cp')) },
|
|
el('span', { class: 'tt', text: t.title }),
|
|
el('span', { class: 'meta', text: `${t.title.length} chars${t.angle ? ` · ${t.angle}` : ''}` }),
|
|
el('span', { class: 'cp', text: 'Copy' }))))),
|
|
)
|
|
}
|
|
|
|
function renderDescription(data) {
|
|
const ta = el('textarea', { class: 'desc-out', rows: '14', 'aria-label': 'Generated description' })
|
|
ta.value = data.description
|
|
out.replaceChildren(
|
|
el('div', { class: 'out-head' },
|
|
el('span', { text: `${data.description.length} of 5,000 characters. Edit it here, then copy.` }),
|
|
el('button', { type: 'button', class: 'btn-ghost', onclick: (e) => copyText(ta.value, e.currentTarget), text: 'Copy' })),
|
|
ta,
|
|
)
|
|
}
|
|
|
|
form.addEventListener('submit', async (e) => {
|
|
e.preventDefault()
|
|
const m = mode()
|
|
const topic = $('md-topic').value.trim()
|
|
if (topic.length < 15) {
|
|
setStatus(status, 'Describe the video in at least a sentence: what happens in it and who it is for.', 'error')
|
|
return
|
|
}
|
|
submit.disabled = true
|
|
setStatus(status, 'Writing...', 'busy')
|
|
try {
|
|
const res = await fetch(`${API_URL}/api/tools/youtube-metadata`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ mode: m, topic, keyword: $('md-keyword').value.trim() }),
|
|
})
|
|
if (!res.ok) {
|
|
const err = await apiError(res)
|
|
track('tool_used', { tool: TOOL, mode: m, ok: false, code: err.code })
|
|
setStatus(status, err.message, 'error')
|
|
return
|
|
}
|
|
const data = await res.json()
|
|
track('tool_used', { tool: TOOL, mode: m, ok: true })
|
|
setStatus(status, '', '')
|
|
if (m === 'tags') renderTags(data)
|
|
else if (m === 'titles') renderTitles(data)
|
|
else renderDescription(data)
|
|
out.hidden = false
|
|
$('md-cta').hidden = false
|
|
} catch (_) {
|
|
track('tool_used', { tool: TOOL, mode: m, ok: false, code: 'network' })
|
|
setStatus(status, 'Could not reach the generator. Check your connection and try again.', 'error')
|
|
} finally {
|
|
submit.disabled = false
|
|
}
|
|
})
|
|
|
|
document.querySelectorAll('[data-example-topic]').forEach((b) => b.addEventListener('click', () => {
|
|
$('md-topic').value = b.dataset.exampleTopic
|
|
$('md-keyword').value = b.dataset.exampleKeyword || ''
|
|
window.scrollTo({ top: 0, behavior: 'smooth' })
|
|
$('md-topic').focus()
|
|
}))
|
|
|
|
$('md-cta-btn')?.addEventListener('click', () => track('tool_cta_click', { tool: TOOL }))
|