# -*- coding: utf-8 -*- """Generate CapCut-safe English SRT + YouTube titles/descriptions per folder. CapCut 朗读 rules: 1 line/cue, cue duration >= speech time, no overlapping cues. """ from __future__ import annotations import json import re from pathlib import Path ROOT = Path(__file__).resolve().parent # ~2.4 words/sec for clear US male TTS + buffers WPS = 2.4 MIN_CUE = 1.5 GAP = 0.28 # silence between cues — prevents double-voice LEAD = 0.6 # start after video begins def ts(sec: float) -> str: if sec < 0: sec = 0 h = int(sec // 3600) m = int((sec % 3600) // 60) s = int(sec % 60) ms = int(round((sec - int(sec)) * 1000)) if ms >= 1000: ms = 0 s += 1 return f"{h:02d}:{m:02d}:{s:02d},{ms:03d}" def speech_dur(text: str) -> float: words = len(re.findall(r"[A-Za-z0-9']+", text)) return max(MIN_CUE, words / WPS + 0.45) def build_srt(lines: list[str], total: float) -> str: """Pack lines across [LEAD, total-0.5] with no overlap.""" end_limit = max(LEAD + 5, total - 0.4) usable = end_limit - LEAD # estimate total speech need need = sum(speech_dur(x) + GAP for x in lines) - GAP # if too long, trim lines from middle-ish (keep hook + close) while need > usable * 0.98 and len(lines) > 8: # drop every other mid line mid = lines[2:-2] if not mid: break drop = mid[len(mid) // 2] lines = lines[:2] + [x for x in mid if x is not drop] + lines[-2:] need = sum(speech_dur(x) + GAP for x in lines) - GAP # stretch gaps across the full runtime (more lines => denser talk) base = sum(speech_dur(x) for x in lines) gaps_n = max(1, len(lines) - 1) spare = usable - base gap = max(GAP, spare / gaps_n) if spare > 0 else GAP * 0.5 cues = [] t = LEAD for i, text in enumerate(lines, 1): d = speech_dur(text) if t + d > end_limit: # compress remaining into leftover left = end_limit - t if left < 1.2: break d = left start, end = t, t + d cues.append((i, start, end, text.strip())) t = end + gap if t >= end_limit: break # if we finished early with leftover lines, force-fit last closing line near end if lines and cues and cues[-1][3] != lines[-1]: close = lines[-1] d = min(speech_dur(close), 4.0) start = max(cues[-1][2] + 0.2, end_limit - d - 0.1) if start + 1.0 < end_limit and start >= cues[-1][2]: cues.append((len(cues) + 1, start, min(start + d, end_limit), close)) out = [] for i, start, end, text in cues: # hard guarantee no overlap / single line text = text.replace("\n", " ").strip() out.append(f"{i}\n{ts(start)} --> {ts(end)}\n{text}\n") return "\n".join(out).rstrip() + "\n" # Content packs keyed by identifying video stem present in folder PACKS = { "citywalk": { "match": ("034248", "041246", "041500"), "slug": "citywalk", "title_file": "YT_TITLES.txt", "srt_file": "YT_CAPTIONS_EN.srt", "titles": [ "I Walked Alone Through China's Busiest Food Street (Everything Smelled Amazing)", "POV: Night Market City Walk in China — Real Street Food, Real Life", "Alone in China: Following Neon Lights to $2 Street Food", "This Chinese Food Street Hit Different at Golden Hour", "Living Alone in China — City Walk Where Locals Actually Eat", ], "description": """Walking alone through a real Chinese food street — lanterns, scooters, Guangdong rice rolls, and the kind of neon that makes you forget your phone battery. No tourist map. Just POV city walking, street food signs glowing, and everyday people living their night. If you're building a YouTube life around China: film what you smell first. The algorithm loves honest hunger. 📍 Real local food street | scooters | night snacks | alone in China lifestyle #AloneInChina #ChineseStreetFood #NightMarket #ChinaVlog #CityWalk #FoodTour #RealLifeInChina #StreetFood #POV""", "lines": [ "Tonight I'm walking alone through a Chinese food street.", "No guide. No plan. Just neon and hunger.", "The sky is soft grey, but the stalls already glow.", "Those red lanterns mean one thing — snacks everywhere.", "Scooters slide past like this is normal Tuesday traffic.", "Listen to that hum — engines, oil, people talking fast.", "Look at that sign — Guangdong steamed rice rolls.", "Fresh cut. Hot steam. Instant appetite.", "This is where locals eat after work, not tourists.", "I'm filming everything because this is my YouTube life in China.", "One person. One camera. Real streets.", "Every stall smells different — sweet, spicy, greasy, perfect.", "A girl checks her phone while the food window glows behind her.", "That backpack rig? Someone else is also recording their night.", "In China, street food is not a show. It's dinner.", "I keep walking because every corner looks like a thumbnail.", "Skewers on the left. Cold drinks on the right.", "Luckin Coffee on one side. Smoke and skewers on the other.", "This contrast is modern China in one block.", "A vendor flips something in the pan and the whole alley smells richer.", "If you want views, film what Americans can't smell through a screen.", "Cheap bites. Loud signs. Soft evening light.", "I'm alone here, but the street never feels empty.", "Someone laughs behind me. Someone orders without looking up.", "That's the secret of living in China for YouTube.", "Walk slow. Taste later. Let the city talk first.", "Neon characters blink like they're begging for a close-up.", "I pass a snack photo board and almost break character.", "Don't sprint the street — linger on the details.", "Plastic stools. Tiny tables. Big flavor.", "This is daily life dressed up as content.", "My battery is dropping, but my curiosity is not.", "Subscribe if you want more real nights like this.", "Save this walk for when you miss China energy.", "Comment what you'd order first from these stalls.", "Next stop — whatever smells strongest.", "I'll keep filming until the lanterns own the whole block.", "A couple shares one skewer like it's a tiny date.", "Oil pops in a wok and everyone turns for half a second.", "I catch a neon reflection in a puddle — free cinematography.", "Don't blink past the side stalls. That's where the gems hide.", "Cold drink in one hand. Hot snack in the other. Balance.", "This street teaches you more than any China guidebook.", "I adjust the framing and keep drifting forward.", "If the algorithm asks what this video is — it's hunger with legs.", "Alone in China, one food street at a time.", "Thanks for walking with me tonight.", "One last pan of skewers before I cut.", "If you're still here, hit subscribe for the next night walk.", "China after dark never really ends — we just stop filming.", ], }, "nm1": { "match": ("041738", "041845"), "slug": "nightmarket", "titles": [ "Chinese Night Market Under $3 — Potstickers, Stinky Tofu, Lemon Tea", "I Tried the Loudest Street Food Block in My Chinese City", "Alone in China: Night Market Foods Locals Queue For", "Stinky Tofu vs Potstickers — Which Would You Pick?", "Real China Night Market POV (No Tourist Filter)", ], "description": """Night market run in a real Chinese city — fresh meat potstickers, stinky tofu smoke, grilled squid, hand-shaken lemon tea, and Wuhan-style doupi glowing on the menu board. Filmed alone, walking stall to stall. This is how I document daily life for YouTube while living in China. Prices start around pocket change. Flavor does not. #NightMarket #ChineseStreetFood #StinkyTofu #AloneInChina #ChinaFood #StreetFoodTour #RealLifeChina""", "lines": [ "Night market mode — let's go.", "The lights are already warmer than the sky.", "First stall hits me with fresh meat potstickers.", "Eight for pocket money. Twelve if you're starving.", "That pan sound alone could sell the video.", "Across the street — stinky tofu smoke in the air.", "Yeah, it smells wild. Yeah, people still line up.", "In China, bold smell usually means bold flavor.", "Grilled squid signs are calling my name.", "Char marks. Chili dust. Instant hunger.", "This is not fancy dining. This is China after dark.", "I'm alone, but every stall feels like a conversation.", "Vendors shout. Customers point. Money moves fast.", "Hand-shaken lemon tea with a cartoon bear logo.", "Sweet cold drink versus hot fried snacks — dangerous combo.", "Sanxian doupi — crispy outside, soft inside, very Wuhan energy.", "I film the glow because neon sells the feeling.", "Look at the menu boards — photos do half the selling.", "If you run a China YouTube channel, night markets are free cinema.", "Real faces. Real steam. Real prices.", "A kid walks past with a skewer bigger than his patience.", "I keep moving before I order everything.", "This whole block is a content goldmine.", "Stay for the smoke trails — they look unreal on camera.", "Tonight's mission: eat local, film honest, stay curious.", "Tell me in the comments — potstickers or stinky tofu first?", ], }, "nm2": { "match": ("042529",), "slug": "nightmarket2", "titles": [ "2 Minutes Inside a Chinese Night Market (Sensory Overload)", "Follow Me Through Neon Street Food Stalls in China", "Alone in China — Short Night Market Walk, Big Appetite", "What a Real Chinese Snack Street Sounds Like at Night", "POV: You're Hungry in China and Every Sign Looks Good", ], "description": """A tight night-market walk — glowing carts, snack photos on every panel, vendors moving fast, and me filming alone through the noise. Short clip. Full atmosphere. Built for people who love China street food and honest POV life content. #ChineseNightMarket #StreetFood #AloneInChina #ChinaVlog #FoodPOV""", "lines": [ "Short walk. Maximum snack energy.", "The stalls light up like a video game map.", "Warm bulbs. Cold air. Instant appetite.", "Every photo on these boards looks illegal levels of good.", "Fried, grilled, steamed — all in one glance.", "Vendors move fast — China night service speed.", "I'm filming alone so you can walk with me.", "No talking head. Just POV through the neon.", "Listen — scooters, oil, chatter, sizzling pans.", "This is the sound of a real Chinese evening.", "Someone orders three things without slowing down.", "I don't need a script when the street writes one.", "Find the brightest sign. That's usually the move.", "Steam hits the lens and makes everything cinematic.", "Living in China means dinner can start on the sidewalk.", "Plastic bags swing. Chopsticks click. Night begins.", "For YouTube, moments like this beat studio talking heads.", "Watch the colors — red signs, gold light, dark street.", "Stay to the end — the glow only gets better.", "If you're hungry, you're already late.", "Save this for late-night cravings.", "Next clip, I might actually stop and eat.", ], }, "nm3": { "match": ("044816", "045155", "045353"), "slug": "nightmarket3", "titles": [ "Xinfeng Food Street at Night — Malatang Steam and Neon Chaos", "I Got Lost in China's Snack Street (In the Best Way)", "Alone in China: BBQ, Grilled Fish, and Girls Ordering Malatang", "This Chinese Food Street Looks Like a Movie at Dusk", "8 Minutes of Pure China Night Market Energy", ], "description": """Long walk through Xinfeng Road Food Street — malatang steam clouds, red lantern arches, Wanzhou grilled fish specials, BBQ smoke, squid-and-chips stalls, and locals crowding the counters. I'm alone with a camera, building a YouTube life out of real Chinese nights like this. Watch for the faces, the steam, and the signs — that's the story. #FoodStreet #Malatang #ChineseBBQ #NightMarketChina #AloneInChina #StreetFood #ChinaVlog""", "lines": [ "This food street hits different when the sky turns blue-grey.", "Red lanterns. Metal arches. Steam like a special effect.", "That cloud is malatang — spicy, numbing, dangerous.", "Broth bubbling. Chili oil shining. Instant ASMR.", "Girls gather at the counter like it's a weekend ritual.", "I'm not staging this. China's just cinematic.", "Xinfeng Food Street — written right on the stall signs.", "I read the menu boards the way some people read maps.", "Squid, potato chips, chicken strips — sweet sour spicy.", "One stall. Three flavor moods. Zero hesitation.", "Wanzhou grilled fish on special for pocket-friendly money.", "BBQ neon in the back. Smoke in the front.", "The air tastes like peppercorn before I even order.", "Every few steps, another reason to stop filming and eat.", "I keep recording because this is my job and my life here.", "Alone in China doesn't mean lonely — it means free.", "Watch how locals order without overthinking.", "Point. Pay. Wait for steam. Live.", "A vendor lifts the lid and the whole lane gets warmer.", "If your YouTube niche is real China, film nights like this.", "Faces in the crowd tell better stories than stock B-roll.", "The street gets tighter. The lights get louder.", "I follow the brightest red tent like a moth.", "Lanterns overhead make every walk feel like a trailer.", "Someone laughs. Someone films. Someone eats with chopsticks mid-walk.", "This is the China Americans ask me about in comments.", "Not skyscraper flex. Sidewalk flavor.", "Scooters squeeze through like they own the snack lane.", "I slow down at the malatang counter just to watch the steam.", "Grilled fish. Skewers. Cold drinks. Full sensory stack.", "My camera loves the red light more than I planned.", "I stay until my battery and my willpower both drop.", "If you're building a China channel, nights like this are inventory.", "Save this walk for when you need China energy.", "Like if the steam got you hungry through the screen.", "Comment your spice level — mild, brave, or malatang chaos.", "Next time — I actually sit down and finish a full bowl.", "Until then, I'll keep walking the brightest street I find.", "A steam cloud drifts across a red lantern and looks unreal.", "I pass the same BBQ light twice and still want it.", "Crowds thicken near the best smelling corner. Always.", "This is research, dinner, and content in one walk.", "Keep watching — the street still has more glow left.", "Thanks for staying through the chaos with me.", ], }, "street": { "match": ("032711", "032958", "033518"), "slug": "street", "titles": [ "10 Minutes Walking China's Real Streets (No Tourist Edit)", "Alone in China POV — Cake Shops, Sidewalk Snacks, City Girls", "What Daily Life Looks Like on a Normal Chinese Street", "I Filmed My Neighborhood Walk for YouTube — This Is China", "Street Level China: Power Banks, Scooters, and Snack Carts", ], "description": """A long street-level walk through everyday China — shop windows, sidewalk snack carts, shared power-bank stations, cake signs, scooters, and real people living their afternoon. This is the kind of footage I use to grow a YouTube channel about life alone in China: less flex, more truth. #AloneInChina #ChinaStreet #RealLifeChina #CityWalk #ChinaVlog #DailyLife""", "lines": [ "Starting a long street walk through my Chinese city.", "No landmark checklist. Just life at eye level.", "Cloudy sky, busy sidewalk, perfect for POV.", "Yellow power-bank stations — peak modern China detail.", "Even the street furniture looks like modern life.", "Two girls pause by a cake shop window.", "Glasses, backpacks, casual fit — real, not styled for TV.", "She glances past the lens like the camera isn't special.", "Behind them, a snack cart is already working.", "This is the China that never trends until you film it right.", "I walk slower so the microphone catches the city.", "Scooters, plastic bags, soft conversations.", "A delivery rider cuts through like it's choreography.", "Living alone here taught me to notice small scenes.", "A pink hoodie cuts through the grey weather.", "Shop glass reflects faces, bikes, and afternoon light.", "Twenty-four hour supermarket glow on the right.", "When it's cloudy, neon does the storytelling.", "Cake signs. Snack smoke. Phone chargers. Whole ecosystem.", "I'm building YouTube videos from walks like this.", "Americans love beauty and food — China has both on every block.", "But the real hook is honesty.", "Don't fake a travel show. Show your Tuesday.", "Street food smoke mixes with traffic air.", "Someone buys a snack without slowing their conversation.", "I keep the camera steady and my curiosity louder.", "Every shop sign is a potential title.", "Every face is a reminder this place is alive.", "Watch the crosswalk — people move with quiet purpose.", "No tourist map. No forced smile. Just neighborhood pace.", "If you want to grow a China channel, walk more than you talk.", "Ten minutes on the street beats ten tips on a desk.", "I pass another cake window and almost stop for sugar.", "These ordinary blocks are my content library.", "Stay with me — there's more city ahead.", "The longer you walk, the more China opens up.", "Like if this felt more real than a travel brochure.", "Comment where you want me to walk next.", "This is alone in China, one sidewalk at a time.", "I'll keep filming until the street runs out of stories.", "A scooter beeps once and vanishes into the block.", "Sidewalk chalk, shop stickers, random flyers — texture everywhere.", "I film a snack cart long enough to smell it through memory.", "Grey weather makes the warm signs hit harder.", "Two friends argue about which cake to buy. Peak content.", "I don't need landmarks when the neighborhood is the story.", "Power lines, shop awnings, soft chatter — city ASMR.", "Another girl walks past with earbuds and zero rush.", "This pace is why I film China from the ground.", "If you made it this far, you're built for long POV walks.", "One more block. One more detail. Then we wrap.", "Thanks for walking the ordinary streets with me.", "I catch one more cake-shop window before the light fades.", "A snack cart lid opens and the block smells sweeter.", "People wait at a light like it's just another Tuesday.", "That is the vibe — calm city, quiet stories.", "My footsteps stay soft so the street can talk louder.", "Shop shutters, open doors, half-finished conversations.", "I pan past a phone charger stand again on purpose.", "Tiny details stack into a real China portrait.", "If this helped you feel the sidewalk, mission complete.", "Subscribe for more unfiltered neighborhood walks.", "See you on the next block.", ], }, "canteen": { "match": ("042937", "044719"), "slug": "canteen", "titles": [ "Chinese Noodle Counter POV — Green Onion, Chili, Pure Comfort", "I Ate Noodles Like a Local (Alone in China Food Ritual)", "Lanzhou Beef Noodles Energy — Simple Bowl, Serious Flavor", "Food Street + Noodle Shop: My Favorite Alone Dinner in China", "Watch Me Build a Bowl in a Real Chinese Eatery", ], "description": """Noodle-shop POV in China — chopped green onion, cilantro, pickled beans, fried soy crunch, chopsticks ready, then back out toward the food-street arch and milk-tea lights. A quiet alone-in-China dinner ritual. Soft, real, and very rewatchable. #ChineseNoodles #AloneInChina #FoodPOV #BeefNoodles #RealLifeChina #ChinaFood""", "lines": [ "Noodle time. This is my comfort ritual in China.", "Walk in. Sit down. Build the bowl.", "Green onion first — always.", "Bright, fresh, and already making me hungry.", "Cilantro if you can handle it. I can.", "Pickled beans with chili for that sour kick.", "Crunchy fried soy on top — texture matters.", "Layer by layer, the bowl gets louder.", "Chopsticks wrapped and ready. No ceremony needed.", "This counter looks simple. The bowl will not be.", "Hot broth hits and the whole table softens.", "Outside, Xinjiu Road Food Street lights are waking up.", "Milk tea glow. Phone repair LED. Beef noodle sign.", "China stacks daily life and dinner on the same sidewalk.", "I film the toppings because close-ups convert viewers.", "But I stay for the steam and the quiet focus.", "Slurp once and the day resets a little.", "Eating alone here feels normal, not sad.", "That's a cultural flex people underestimate.", "Locals finish fast. Flavor doesn't need a speech.", "For YouTube, food ASMR plus real streets is a lethal combo.", "Listen to the kitchen — chop, pour, clink, done.", "I finish the bowl like a local — fast, grateful, gone.", "Back outside, the alley already smells like round two.", "If you cook at home tonight, still watch this. Flavor is contagious.", "Comment your noodle order — mild, spicy, or no cilantro.", "Save this for the next lonely dinner craving.", "Alone in China never tasted this comforting.", ], }, "bike": { "match": ("042040", "042141"), "slug": "bike", "titles": [ "E-Bike POV Through a Chinese Neighborhood (Qujiang Road)", "Riding Alone in China — Balloons, Fruit Trucks, Noodle Signs", "3 Minutes of Real China Street Traffic From the Seat", "Alone in China: Scooter Life Is the Real Public Transit", "Follow My Ride Past Local Shops and Snack Streets", ], "description": """E-bike / scooter POV along Qujiang Road — balloon sellers, fresh-fruit trucks, specialty noodle signs, scooters with winter wind shields, and the soft chaos of a Chinese neighborhood. Short ride. High authenticity. Perfect B-roll energy for an alone-in-China channel. #ChinaScooter #EbikePOV #AloneInChina #RealLifeChina #ChinaVlog #Qujiang""", "lines": [ "Engine soft. City loud. Let's ride.", "Qujiang Road — local speed, local rules.", "Handlebars steady. Neighborhood rolling past.", "Balloon cluster on the left like a moving cartoon.", "Fresh fruit truck parked like a sidewalk grocery.", "Oranges, apples, instant snack temptation.", "Specialty noodle signs keep tempting me to stop.", "In China, scooters are not hobbies. They're arteries.", "Wind shield blankets. Delivery bags. Everyday armor.", "Someone overtakes me like this road is a highway.", "I'm filming from the ride because motion sells reality.", "Alone doesn't mean isolated — the street shares the frame.", "Watch the crosswalk stripes pull us forward.", "Shop lights smear into soft streaks as we pass.", "This is how I scout content between bigger shoots.", "If it looks ordinary, zoom with your attention.", "A fruit seller waves people over without raising his voice.", "Ordinary China is the niche.", "Balloons bounce. Scooters weave. Life keeps moving.", "I almost stop for noodles twice in one block.", "Stay on the ride — the details keep stacking.", "Ride ending soon — appetite starting now.", "Like if scooter POV feels more real than car tours.", "Next time maybe I hop off for that fruit truck.", "Alone in China, even the commute is content.", ], }, } def resolve_folder(match_tokens: tuple[str, ...]) -> Path | None: for d in ROOT.iterdir(): if not d.is_dir() or d.name.startswith("_"): continue names = " ".join(p.name for p in d.glob("*.mp4")) if any(tok in names for tok in match_tokens): return d return None def write_titles(folder: Path, pack: dict) -> None: lines = [] lines.append("=== YOUTUBE TITLES (pick 1) ===") for i, t in enumerate(pack["titles"], 1): lines.append(f"{i}. {t}") lines.append("") lines.append("=== DESCRIPTION ===") lines.append(pack["description"].strip()) lines.append("") lines.append("=== TAGS ===") lines.append( "alone in china, chinese street food, night market, china vlog, real life china, " "city walk, food tour, pov china, street food china, living in china, youtube growth" ) (folder / "YT_TITLES.txt").write_text("\n".join(lines) + "\n", encoding="utf-8") def main() -> None: probe = json.loads((ROOT / "_meta_probe.json").read_text(encoding="utf-8")) # map folder path -> duration via video match summary = [] for key, pack in PACKS.items(): folder = resolve_folder(pack["match"]) if not folder: print("MISSING folder for", key) continue # duration from probe by matching any video file dur = None for pname, info in probe.items(): vids = " ".join(v["file"] for v in info["videos"]) if any(tok in vids for tok in pack["match"]): dur = float(info["total_duration"]) break if dur is None: print("NO DUR", key) continue srt = build_srt(list(pack["lines"]), dur) srt_path = folder / "YT_CAPTIONS_EN.srt" srt_path.write_text(srt, encoding="utf-8") write_titles(folder, pack) # cue count cues = srt.count(" --> ") last_end = re.findall(r"--> (\d{2}:\d{2}:\d{2},\d{3})", srt)[-1] summary.append(f"{folder.name}: {dur:.1f}s | cues={cues} | last={last_end} | SRT+TITLES OK") print(summary[-1]) (ROOT / "_gen_summary.txt").write_text("\n".join(summary) + "\n", encoding="utf-8") print("ALL DONE") if __name__ == "__main__": main()