{"record":{"id":"294f0f75a992506c","repo":"crewAIInc/crewAI","slug":"unable-to-load-youtube-channel-channel-url-e-s","errorCode":null,"errorMessage":"Unable to load YouTube channel {channel_url}: {e!s}","messagePattern":"Unable to load YouTube channel (.+?): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/rag/loaders/youtube_channel_loader.py","lineNumber":139,"sourceCode":"                                if text_parts:\n                                    preview = \" \".join(text_parts)[:500]\n                                    content_parts.append(\n                                        f\"   Transcript Preview: {preview}...\"\n                                    )\n                        except Exception:\n                            content_parts.append(\"   Transcript: Not available\")\n\n                    except Exception as e:\n                        content_parts.append(f\"\\n{i}. Error loading video: {e!s}\")\n\n            except ImportError:\n                for i, video_url in enumerate(video_urls, 1):\n                    content_parts.append(f\"\\n{i}. {video_url}\")\n\n            content = \"\\n\".join(content_parts)\n\n        except Exception as e:\n            raise ValueError(\n                f\"Unable to load YouTube channel {channel_url}: {e!s}\"\n            ) from e\n\n        return LoaderResult(\n            content=content,\n            source=channel_url,\n            metadata=metadata,\n            doc_id=self.generate_doc_id(source_ref=channel_url, content=content),\n        )\n\n    @staticmethod\n    def _extract_video_id(url: str) -> str | None:\n        \"\"\"Extract video ID from YouTube URL.\"\"\"\n        patterns = [\n            r\"(?:youtube\\.com\\/watch\\?v=|youtu\\.be\\/|youtube\\.com\\/embed\\/|youtube\\.com\\/v\\/)([^&\\n?#]+)\",\n        ]\n\n        for pattern in patterns:","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/rag/loaders/youtube_channel_loader.py#L121-L157","documentation":"The channel loader's outer catch-all: any exception during channel metadata fetching, video URL enumeration, or per-video processing is wrapped as ValueError('Unable to load YouTube channel ...') with the cause chained. Note that per-video failures are NOT fatal — they are appended into the content as 'Error loading video: ...' strings — so this outer error usually means the channel itself could not be fetched.","triggerScenarios":"pytube's Channel(channel_url) failing to scrape the channel page: YouTube layout changes breaking pytube, age/region-restricted channels, network errors, or an empty channel raising during channel_name/channel_id access. A pytube internals change ('regex match error') is the classic cause.","commonSituations":"pytube frequently breaks when YouTube changes its page structure — an environment that worked yesterday can fail today without any code change; channels with zero videos; running from datacenter IPs that YouTube challenges.","solutions":["Inspect e.__cause__ — for pytube scrape failures it is usually RegexMatchError, which means the installed pytube is outdated.","Upgrade pytube to the latest release: uv add 'pytube @ latest' — scrape fixes land regularly.","If pytube is unmaintained for your URL shape, consider pytubefix as a drop-in replacement (same import path).","Verify the channel URL opens in a browser from the same network; restricted or removed channels cannot be loaded.","Note that individual broken videos do not raise this — degraded content with 'Error loading video' entries means partial success, not total failure."],"exampleFix":"# shell, before: pip install pytube (old version, RegexMatchError)\n# after:\n# uv pip install -U pytubefix   # maintained fork, same API surface\nresult = loader.load(SourceContent(path=\"https://www.youtube.com/@handle\"))","handlingStrategy":"retry","validationCode":"def pytube_can_fetch_channel(channel_url: str) -> bool:\n    try:\n        from pytube import Channel\n        ch = Channel(channel_url)\n        _ = ch.channel_name\n        return True\n    except Exception:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    result = channel_loader.load(src)\nexcept ValueError as e:\n    if is_transient_network_error(e.__cause__):\n        backoff_and_retry(src)\n    elif \"RegexMatchError\" in repr(e.__cause__):\n        upgrade_pytube()  # YouTube layout changed","preventionTips":["Treat pytube as fragile: pin a known-good version and watch releases for scrape fixes.","Cache channel listings so repeated ingestion does not re-scrape.","Remember per-video errors degrade content gracefully — only this top-level error means total failure."],"tags":["youtube","pytube","web-scraping","dependency"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}