A cross-platform command-line tool for bidirectional lookups between YouTube usernames (handles) and channel IDs using web scraping.
- ✅ Username to Channel ID: Convert @username to channel ID
- ✅ Channel ID to Username: Convert channel ID to @username
- ✅ Cross-platform: Works on Windows, macOS, and Linux
- ✅ Configurable User Agent: Browser-like default with optional override
- ✅ Configurable Retries: Optional retry count and delay
- ✅ Multiple Output Modes: Default (bare value), URL, feed URL, or verbose
- Clone or download this repository
- Install the package (this also installs all dependencies and registers the
youtube-lookupcommand):
pip install -e .Or install dependencies only (use python youtube_lookup.py directly):
pip install -r requirements.txtNote: After installing with
pip install -e ., ensure your Python Scripts directory is on your PATH. Python will warn you if it isn't.
The tool supports four output modes. Only one can be active at a time:
| Mode | Flag | Output |
|---|---|---|
| Default | (none) | Bare result — channel ID or @username |
| URL | --url |
Channel URL |
| Feed | --feed |
RSS feed URL |
| Verbose | --verbose / -v |
All details: labels, channel URL, feed URL |
Username → Channel ID (default):
youtube-lookup --username "MicrosoftCloud"
# UCSgzRJMqIiCNtoM6Q7Q9LqwChannel ID → Username (default):
youtube-lookup --channel-id "UCSgzRJMqIiCNtoM6Q7Q9Lqw"
# @MicrosoftCloudOutput just the channel URL:
youtube-lookup --username "MicrosoftCloud" --url
# https://www.youtube.com/channel/UCSgzRJMqIiCNtoM6Q7Q9Lqw
youtube-lookup --channel-id "UCSgzRJMqIiCNtoM6Q7Q9Lqw" --url
# https://www.youtube.com/@MicrosoftCloudOutput just the RSS feed URL:
youtube-lookup --username "MicrosoftCloud" --feed
# https://www.youtube.com/feeds/videos.xml?channel_id=UCSgzRJMqIiCNtoM6Q7Q9LqwVerbose output:
youtube-lookup --username "MicrosoftCloud" --verboseLooking up channel ID for username: @MicrosoftCloud
Channel ID: UCSgzRJMqIiCNtoM6Q7Q9Lqw
Channel URL: https://www.youtube.com/channel/UCSgzRJMqIiCNtoM6Q7Q9Lqw
Feed URL: https://www.youtube.com/feeds/videos.xml?channel_id=UCSgzRJMqIiCNtoM6Q7Q9Lqw
With retries and delay:
youtube-lookup --username "MicrosoftCloud" --retry 5 --delay 2.0Custom user agent:
youtube-lookup --username "MicrosoftCloud" --user-agent "MyBot/1.0"usage: youtube-lookup [-h] (--username USERNAME | --channel-id CHANNEL_ID)
[--retry RETRY] [--delay DELAY]
[--verbose] [--url] [--feed]
[--user-agent USER_AGENT]
options:
-h, --help show this help message and exit
--username USERNAME, -u YouTube username to lookup (with or without @)
--channel-id CHANNEL_ID, -c YouTube channel ID to lookup
--retry RETRY, -r Number of retry attempts (optional)
--delay DELAY, -d Delay between retries in seconds (optional)
--verbose, -v Show full details: labels, channel URL, and feed URL
--url Output just the channel URL
--feed Output just the RSS feed URL
--user-agent USER_AGENT, -A User-Agent string to use (default: Chrome browser)
-
Username to Channel ID:
- Fetches
youtube.com/@username - Extracts the channel ID from page metadata using regex patterns
- Validates the channel ID format (
UCprefix, 24 characters)
- Fetches
-
Channel ID to Username:
- Fetches
youtube.com/channel/<CHANNEL_ID> - Extracts the handle from
canonicalBaseUrlin page metadata - Returns the canonical
@usernameformat
- Fetches
https://www.youtube.com/feeds/videos.xml?channel_id=<CHANNEL_ID>
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Override with --user-agent / -A.
- Python 3.6+
- requests
- 0: Success
- 1: Lookup failed (not found or network error after all retries)
- Relies on web scraping — may break if YouTube changes their page structure
- Requires an internet connection
- May be subject to YouTube's terms of service
- Some channels may not have public usernames or may not be discoverable
Feel free to submit issues and pull requests to improve the tool!
Copyright (c) 2026 Matthew Housholder. Released under the MIT License.
