youtube_helper.branding module

YouTube Helper — branding companion module.

Engagement / channel / comments / subtitles helpers for personal-branding workflows that do not require Google Data API or Vimeo API keys.

These functions complement youtube_helper.main (download utilities) with public-metadata extraction useful to score a creator’s track record:

  • channel-level snapshot (subscribers, total views, video count, title)

  • channel video list (paginated, with normalised engagement metadata)

  • single video engagement signals (views / likes / comments)

  • auto-subtitle download (returns a {lang: path} dict)

  • comments sample (cookies-from-browser optional for restricted threads)

All work for YouTube, Vimeo, DailyMotion, Twitch VOD, and any other site yt-dlp supports, with one homogeneous return shape.

Anti-API rationale

Most “live engagement” numbers a personal-brand tool needs (view_count, like_count, comment_count, channel_follower_count, duration, upload_date, tags, description, thumbnail) are present in the public yt-dlp metadata for unrestricted videos. No OAuth, no client_id, no quota. The Data API only becomes necessary for per-video retention curves (Analytics API) and comments at scale (the public commentThreads endpoint).

Author: - Warith HARCHAOUI, https://linkedin.com/in/warith-harchaoui

youtube_helper.branding.channel_info(url, verbose=False)[source]

Return one normalised dict describing the channel / creator page.

Works with YouTube channel URLs (/@handle, /channel/UC…), Vimeo user pages, DailyMotion creators. Pulls subscriber count, channel title, description, total view count when available.

Parameters:
Return type:

dict[str, Any]

youtube_helper.branding.channel_videos(url, max_videos=200, include_shorts=True, include_lives=False, verbose=False)[source]

List videos of a channel / creator page with per-video engagement metadata.

For YouTube channels, walks the uploads playlist; for Vimeo / DailyMotion, walks the user page. Each entry is normalised to the same engagement schema (id, url, title, duration_seconds, view_count, like_count, comment_count, upload_date, kind, …).

Two-pass strategy: a fast flat listing first (1 call), then per-video metadata fetch (1 call per video). The second pass is what makes view_count / like_count reliable — extract_flat returns IDs and sometimes view_count, but rarely likes / comments.

Parameters:
Return type:

list[dict[str, Any]]

youtube_helper.branding.engagement_batch(urls, verbose=False)[source]

Map a list of URLs to normalised engagement dicts, one per URL.

Tolerant: bad URLs / unavailable videos are reported as {“url”: …, “_error”: “…”} rather than raising.

Parameters:
Return type:

list[dict[str, Any]]

youtube_helper.branding.ensure_recent_ytdlp(min_version=None)[source]

Return the installed yt-dlp version. Warn if older than min_version.

YouTube changes its signature scheme roughly every quarter; an outdated yt-dlp is the #1 cause of failures. Callers that mind freshness can surface a warning early.

Parameters:

min_version (str | None)

Return type:

str

youtube_helper.branding.is_short(meta)[source]

Heuristic — true if the entry looks like a Short / vertical clip.

Looks at duration (≤ 60s), webpage_url (/shorts/), and #Shorts in title.

Parameters:

meta (dict[str, Any])

Return type:

bool

youtube_helper.branding.video_comments(url, max_count=100, cookies_from_browser=None, verbose=False)[source]

Fetch comments via yt-dlp’s getcomments.

YouTube increasingly requires browser cookies for comment scraping. If cookies_from_browser is set (e.g. “firefox”, “chrome”, “safari”), yt-dlp will pull cookies from that browser’s profile. On macOS this is the only reliable way to get YouTube comments today.

Returns a list of normalised comment dicts: id, parent, author, text, like_count, timestamp.

Parameters:
  • url (str)

  • max_count (int)

  • cookies_from_browser (str | None)

  • verbose (bool)

Return type:

list[dict[str, Any]]

youtube_helper.branding.video_engagement(url, verbose=False)[source]

Single-video engagement snapshot. Returns the normalised dict shape.

Parameters:
Return type:

dict[str, Any]

youtube_helper.branding.video_subtitles(url, output_dir, langs=('fr', 'en'), auto_only=True, verbose=False)[source]

Download auto-generated (or manual) subtitles into output_dir.

Returns a dict mapping language → absolute path of the saved .vtt file. Languages that aren’t available are silently skipped.

Parameters:
Return type:

dict[str, str]