# Changelog of YouTube Scraper (`badr_xba/youtube-data-scraper`) Actor

- **URL**: https://apify.com/badr_xba/youtube-data-scraper/changelog.md
- **Full Actor documentation**: https://apify.com/badr_xba/youtube-data-scraper.md

## Changelog

### 2.0 — two protections on top of 2.0.5 (2026-11-13)

- A run where YouTube refused everything now ends SUCCEEDED (status "Blocked by YouTube: ...", RUN_SUMMARY.status
  BLOCKED_BY_YOUTUBE, nothing charged); FAILED only with failRunOnError. Offline test, 50 videos all refused: the
  existing "3 refusals in a row" breaker keeps it to 106 attempts (~$0.017).
- With comments, 250 MB of memory per video read in parallel (was 200 MB): 4 at 1024 MB instead of 5. Measured on dev
  (10 videos x 500 comments): peak 498 MB of 1024.

### 2.0 — customer errors end SUCCEEDED (2026-11-12, local, not pushed)

- Customer errors no longer make the run FAILED: AI key missing / malformed (`missingApiKey`, `malformedApiKey`,
  `invalidAiSettings`) or refused by the provider (`invalidApiKey`, `apiKeyNoAccess`, `quotaExceeded`,
  `invalidModel`), no usable link (`NO_VALID_INPUT`), every link not found / private (`NO_RESULTS`). The run ends
  SUCCEEDED with the reason in the status message, `RUN_SUMMARY.status` (`FAILED_INPUT` / `NO_VALID_INPUT` /
  `NO_RESULTS`) and `FAILED_INPUTS`. The AI summary stays disabled while `ai-summary` is not priced (planned
  2026-11-27): the key is then not checked at all.
- New input `failRunOnError` (default `false`): `true` keeps the FAILED run for these errors (old behaviour).
- YouTube refusing every request stays FAILED (technical error, not the customer's).
- Input schema: `pattern` on `regionCode`, `language`, `transcriptLanguage`, `summaryLanguage`, `publishedAfter`,
  `aiModel`, so malformed values are refused before the run starts.
- `minMemoryMbytes: 512` in actor.json (real peaks 331-448 MB on 512 MB runs, 2.0.1-2.0.5; 256 MB would OOM).

### 2.0 — fixes of 2026-11-12 (local, not pushed)

Ported from youtube-ai-channel-analytics (same engine, validated on Apify on 2026-11-12: 9/10 videos with full
details instead of 0/10, a single video no longer hangs, a log line at least every 30 s).

- Player order: `web_safari` first (production run 3SLxV2VyjA2GUYNh2 only succeeded on attempt 4 with it), then
  default, tv, mweb; the player that last gave a full answer is tried first for the next videos. Retry window 90 s,
  at least 45 s per retry.
- "No title found in player responses" = partial data, not a refusal: the other players are still tried; if none
  gives the full data the video is written with `detailsLevel: "partial"` and `detailsNote` instead of
  `BLOCKED_BY_YOUTUBE`. Once the player breaker is open, each video still gets one attempt.
- Owner decision: rows with incomplete details (`partial`, or `listing` after a refusal in full mode) are written but
  never charged. Explicit pricing: default dataset without event. While `apify-default-dataset-item` is priced:
  `PARTIAL_ROWS_WHILE_SYNTHETIC` (`separate-dataset` = run dataset alias `partial-rows` + `PARTIAL_ROWS` record +
  Output tab link; `skip` = FAILED_INPUTS `PARTIAL_DETAILS`; `charge` = old behaviour). User-chosen list mode stays
  charged. New `RUN_SUMMARY` fields: `rowsByDetailsLevel`, `partialRowsNotCharged`, `partialRowsSkipped`,
  `partialRows`, `partialDetails`, `timeLimited`, `proxyTunnelFailures`, `datacenterProxyDisabled`.
- Reliability: one log line per attempt (route, attempt n, player, time left), "Still working" heartbeat every 30 s,
  30 s timeout on platform calls, per-item hard limit (EXTRACT_TIMEOUT + RETRY_WINDOW), run deadline from
  `ACTOR_TIMEOUT_AT` / `APIFY_TIMEOUT_AT` (no new work 30 s before, run SUCCEEDED, rest `TIME_LIMIT`), extractions in
  daemon threads, proxy tunnel failure = immediate retry with a new session (not a wasted attempt; datacenter route
  dropped after 6 tunnel failures without success).
- Local runs with `useApifyProxy: false` never use the Apify proxy (no datacenter fallback, no enhanced recovery).

### 2.0 (2026-11-11, local build, not published)

#### Added

- AI summary, key points and chapters per video with your own key (`aiSummary`, `aiProvider` claude / openai /
  gemini, secret `aiApiKey`, optional `aiModel`, `summaryLanguage`, `maxChapters`). Written from the YouTube caption
  track only (no audio or video download, no speech-to-text), through plain HTTPS calls. New row fields `aiSummary`,
  `aiKeyPoints`, `aiChapters`, `aiModel`, `aiProvider`, `aiTokens`, `aiSummaryLanguage`, `aiInputTruncated`,
  `aiError`. Chapters are validated (0..duration, ascending, snapped to a caption segment start).
- Wrong key / no access / empty account / unknown model: clean stop at the first error, run FAILED, `stoppedReason`
  in `RUN_SUMMARY`, key redacted from logs, results and report.
- `captionSource` (`manual` | `auto`) and the `allowAutoCaptions` switch (default on); `noCaptions` when no usable
  track.
- `includeTranscriptSegments`: `transcriptSegments` `[{start, end, text}]` + `availableCaptionLanguages`.
- Comments: `commentsSort` (top / newest), `includeReplies`, `maxRepliesPerComment` (default 5); comment rows get
  `isReply` and `parentCommentId`.
- Dataset view "Summaries"; RUN_SUMMARY `aiSummary` block and `commentsChargedAs`.

#### Reliability

- Up to 8 attempts per item within a 60 s window, each on a new proxy session (new IP) and another YouTube player,
  short jittered pause; 403 and consent pages count as refusals. `requestsByRoute` in `RUN_SUMMARY`.
- Enhanced recovery (src/recovery.py): 2 last attempts through the RESIDENTIAL proxy, only when the
  `enhanced-recovery` event is live (or, on an Actor without pricing, with the hidden `forceEnhancedRecoveryForTesting`),
  charged once per recovered item, capped by `maxEnhancedRecoveries` (default 20, 0 = off) and by the maximum cost;
  `RUN_SUMMARY.enhancedRecoveries` {used, charged, capReached, estimatedMB, ...}.

#### Billing (launch-safe)

- Two pricing states, switched by one pricing change (docs/LAUNCH_EVENTS.json). While the synthetic per-row event
  is priced: exactly today's billing (every row on it, summaries free unless `ai-summary` is live). Once it is
  removed: `video` per video/channel row, `comment` per comment/reply row, `ai-summary` per summary, each only when
  live (one log line per missing event). Never two events on one row; budget stop before a row that does not fit.
- `requirements-dev.txt` (pytest, pytest-asyncio, jsonschema) for the test suite.

### 2026-11-09 (review invitation)

- Successful runs that saved at least one result end their status message with one short, optional invitation to leave a Store review or open an issue (never on failed or empty runs); README section "Feedback and reviews". Output and billing unchanged.

### 2026-11-08 (visual kit 1.1.0)

#### Added

- YouTube's own search filters for *Search queries*: `searchUploadDate`, `searchDuration`, `searchFeatures`
  (all optional, default = normal search).
- Stable error `code` on every `FAILED_INPUTS` entry (`type` is kept) and `failuresByCode` in `RUN_SUMMARY`;
  codes documented in the README.
- Visual report (kit 1.1.0): live progress (sources done / given), warnings and failed inputs grouped by error
  code, data-quality panel, at most 3 images per result.

#### Fixed

- `engagementRate` and `likesPerThousandViews` are now empty instead of 0 when YouTube gives no like count
  (list mode, hidden likes); the report also shows older 0 % rows of that kind as unknown.
- The REPORT page is also written when the run crashes (final status FAILED instead of "Running").

### 2026-11-08

#### Added

- Comment rows: `authorThumbnail`, the comment author's profile picture exactly as YouTube returns it with the
  comment (`yt3.ggpht.com`, no extra request; `null` with `anonymizeComments`). The *Comments* view opens with it
  (image column) and the visual report's comment cards show it (initials when missing).

#### Added

- **Visual report** (`REPORT` record, Output tab → *Visual report*): 16:9 video cards with thumbnail, duration,
  Shorts / LIVE / Upcoming / Past live badges, channel name, verified badge and subscribers, views, likes,
  comments, engagement and performance against the channel; channel header cards; comment cards; key figures,
  charts, search, filters, sorting, table view, full-size viewer and CSV/JSON export of the filtered rows. Built
  by the shared `src/visual_kit.py` (v1.0.1) with this Actor's `src/report.py`. At most 2,000 rows are kept in
  memory for it; it is never billed and a report error is only logged as a warning.
- Dataset view *Channels* shows the channel picture (`thumbnailUrl`, image format).
- Output schema: *Visual report* link; key-value store schema: `REPORT` (text/html).

#### Fixed

- Video `thumbnailUrl` is normalized: `//host/…` becomes `https://host/…`, blank or non-http(s) values become
  `null`. Valid links are kept unchanged.

#### Tests

- `tests/test_report.py`: 13 tests on 4 real video rows and on rows mapped from the saved YouTube answers
  (image ownership, placeholders for listing rows, Shorts / Live badges, channel and comment rows, URL
  normalization, escaping, a 5,000-row synthetic set, export = embedded data, failure safety).

### 2026-11-07

#### Fixed

- Filters typed as text (`"minViews": "1000"`, `"maxAgeDays": "30"`) made every video fail with "Unexpected error" (string/number comparison); they are now converted.
- An unknown `lengthFilter` value rejected every video; it is now ignored with a warning.
- `publishedAfter`, `lengthFilter`, `regionCode`, `language`, `transcriptLanguage`, `subtitlesFormat` or `order` given as a non-text value no longer crash the run.
- `titleKeywords` / `excludeKeywords` given as one string are split instead of being read letter by letter.
- Switches sent as text by API clients (`"false"`, `"0"`, `"no"`) are read as off.
- A non-object `proxyConfiguration` is ignored with a warning instead of crashing.
- Dataset schema: `replyCount` was declared but never written (removed); `liveConcurrentViewers`, `recentVideosAnalyzed`, `publishedText` and `isByUploader` were written but not declared (added).
- Videos delivered with list data after a player refusal keep the channel average (`channelAverageViews`, `performanceVsChannel`) when channel details are on.

#### Improved

- Searches, channels, playlists and the videos you list run together (bounded by *Videos read in parallel*); with `maxItems` set, the previous priority order is kept.
- For videos found in a list, the channel figures are read at the same time as the video page instead of after it.
- Local measurement (1 video + search of 5, full details, channel details on, no proxy): 42.3 s → 26.7 s wall time (internal 32.5 s → 16.4 s), same 6 results and 11 requests.
- Memory-based parallelism is a little more conservative (200 MB per extraction instead of 170: 5 in parallel at 1 GB instead of 6) after measuring a 1,018 MB peak with 6 in parallel.
- Transcript track downloads are retried with back-off on network errors, 429 and 5xx, with an explicit connect timeout.
- Every row is checked against the dataset schema types before it is saved; `RUN_SUMMARY` adds `listingFallback` and `outputTypeMismatches`.
- Log and status messages are in English, like the README and the Store page. Data values (such as `source`) are unchanged for existing integrations.

#### Schemas and docs

- Dataset field descriptions translated to English, with notes on columns that are often empty (listing mode, options off).
- Input schema: neutral defaults for the filters and text options (0, empty), clearer descriptions for *Duration*, *Video type* and the filters.
- README: retries and the datacenter fallback documented as they really work; new summary keys listed.
- `requirements.txt`: every dependency upper-bounded (`yt-dlp[default]>=2026.10.26,<2028`, `deno>=2,<3`), so builds still take the newest yt-dlp within the range.

#### Tests

- `tests/`: offline tests for input routing and aliases, filters with text values, mapping of a saved yt-dlp video answer and search listing, schema checks on real platform and local rows, retries / refusals / circuit breaker with yt-dlp mocked, transcript retries and parsers. Run `python -m pytest -q`.
