43 lines
1.4 KiB
Markdown
43 lines
1.4 KiB
Markdown
# youtube-latest3
|
|
|
|
Fetch the latest uploads from a YouTube channel URL (including dynamic `@handle` URLs like `https://www.youtube.com/@ludwig/videos`).
|
|
|
|
## Why this approach
|
|
|
|
This tool resolves the channel ID from the exact channel URL, then reads YouTube's official uploads feed:
|
|
|
|
- `https://www.youtube.com/feeds/videos.xml?channel_id=<CHANNEL_ID>`
|
|
|
|
That feed is ordered by newest uploads, so fetching the first 3 entries gives the latest 3 videos.
|
|
|
|
## Usage
|
|
|
|
```bash
|
|
python3 latest3.py "https://www.youtube.com/@ludwig/videos"
|
|
python3 latest3.py "@ludwig" --json
|
|
python3 latest3.py "https://www.youtube.com/@ludwig/videos" --limit 3 --json
|
|
python3 latest3.py "https://www.youtube.com/@ludwig/videos" --limit 3 --no-shorts
|
|
python3 latest3.py "https://www.youtube.com/@ludwig/videos" --limit 3 --no-vods
|
|
python3 latest3.py "https://www.youtube.com/@ludwig/videos" --limit 3 --no-shorts --no-vods
|
|
```
|
|
|
|
## Output fields
|
|
|
|
- `id` - video ID
|
|
- `title` - video title
|
|
- `url` - watch URL
|
|
- `published` - ISO-8601 timestamp from the feed
|
|
|
|
## Flags
|
|
|
|
- `--limit N` how many videos to return (1-20)
|
|
- `--json` output as JSON
|
|
- `--no-shorts` exclude URLs matching `/shorts/`
|
|
- `--no-vods` exclude livestream VODs (`isLiveContent=true` on watch page)
|
|
|
|
## Notes
|
|
|
|
- Works with `@handle` URLs and plain `@handle` input.
|
|
- No API key required.
|
|
- If YouTube changes page markup for channel ID extraction, update `extract_channel_id()`.
|