YouTube viewing history analyzer with TUI interface
Full-featured tool for analyzing your YouTube viewing history with data export capabilities, video duration retrieval, and interactive report generation.
- Key Features
- Installation and Setup
- Getting Data from Google Takeout
- Streamlined TUI Interface
- Data Structure
- Generated Reports
- Technical Details
- Project Structure
- Usage Examples
- Results
- Automatic detection of Takeout files
- Combining two sources:
watch-history.json- viewing historyMyActivity.json- YouTube activity
- Automatic deduplication of records
- YouTube Music filtering (completely excluded)
- YouTube Data API v3 for reliable metadata retrieval
- Automatic time rounding to whole seconds
- Progress indicators with current statistics
- Result caching in CSV file
- Time-based activity: hours, days of week, months
- Top channels
- Watch time with total time estimation
- CSV file for Excel/Google Sheets
- Summary statistics in JSON
- Russian and English languages
- Python 3.8+ (including older versions)
- Extracted Google Takeout archives
- YouTube Data API key (for duration retrieval)
- Localization files (included in project)
pip3 install -r requirements.txt- Create a project in Google Cloud Console
- Enable YouTube Data API v3
- Create an API key
- Save the key to
youtube_api_key.txtfile in project root
Detailed instructions are described in API_INSTRUCTIONS.md
- Quota: 10,000 units per day
- Request: 1 unit per video
- Recommendation: start with 100-1000 video sample
To work with the analyzer, you need to export your YouTube viewing history from Google Takeout.
- Open Google Takeout
- Sign in to your Google account if not authorized
- Uncheck all services (button "Deselect all")
- Check only "YouTube and YouTube Music"
- Click "Next"
- File format: select "JSON"
- Archive size: leave "2 GB" (default)
- Click "Create export"
- Wait for export completion
- Download archive
takeout-YYYYMMDDTHHMMSSZ-001.zip - Extract to
Takeout/folder in project root
To get data before 2021, additionally export My Activity:
- Return to Google Takeout
- Check "My Activity"
- Click "Next"
- Select only YouTube from service list
- Format: JSON
- Create export and download second archive
- Extract second archive to same
Takeout/folder
After extraction, you should have structure:
Takeout/
├── YouTube and YouTube Music/
│ └── history/
│ └── watch-history.json
└── My Activity/
└── YouTube/
└── MyActivity.json
python3 youtube_analyzer.pyThe analyzer provides a convenient text interface with automation of main operations:
╭───────────────────────────────────────╮
│ YouTube History Analyzer │
│ YouTube Viewing History Analyzer │
╰───────────────────────────────────────╯
📊 Main Statistics
┌─────────────┬─────────┐
│ Parameter │ Value │
├─────────────┼─────────┤
│ Total Videos│ 1,234 │
│ Active Days │ 456 │
│ Average │ 2.7 │
│ Videos/Day │ │
└─────────────┴─────────┘
🏆 Top Channels
┌─────────────┬──────┐
│ Channel │ Videos│
├─────────────┼──────┤
│ Channel 1 │ 123 │
│ Channel 2 │ 89 │
│ Channel 3 │ 67 │
└─────────────┴──────┘
📊 Main Menu
1. Load data from Takeout
2. Get video duration
3. Generate HTML report
4. Export data to CSV
5. Open report in browser
0. Exit
- Automatically finds and loads both sources
- Combines data without duplicates
- Applies YouTube Music filtering
- Shows statistics of combination in real time
- YouTube Data API v3 for reliability
- Configurable sample size (default 100)
- Progress indicators with current statistics:
- Current average time
- Number of processed videos
- Completion percentage
- Automatic saving to CSV
- Automatically creates graphs during generation
- Built-in statistics and top channels
- Duration statistics (if available)
- Total watch time with estimates
- Interactive Plotly graphs
- Data in convenient format for Excel/Google Sheets
- Additional fields for analysis
- Video duration in seconds and readable format
- Automatic creation of README with column descriptions
- View HTML report with graphs
- Automatic opening in default browser
- video_id: unique video identifier
- title: video title
- channel: channel name
- url: video link
- date: viewing date
- time: viewing time
- day_of_week: day of week
- source: data source
- duration_seconds: video duration in seconds
- duration_formatted: human-readable duration
- Monthly activity trends
- Cumulative watch time over time
- Day of week activity patterns
- Hourly activity distribution
- Top channels with statistics
- Duration statistics (if available)
- Plotly-based interactive graphs
- Zoom and pan capabilities
- Hover information with details
- Export to PNG functionality
- Main metrics in visual cards
- Channel rankings with counts
- Time analysis with estimates
- Data coverage information
- Analysis period with dates
- Data sources with record counts
- Filtering and deduplication
- Deduplication: by
video_id+timestamp - Filtering: by
headerandtitleUrl - Validation: required field checking
- YouTube Data API v3 for reliability
- ISO 8601 parsing of duration (PT3M7S → 187 seconds)
- API error handling (400, 403, timeouts)
- Result caching in CSV
- Python 3.8+ (including older versions)
- Cross-platform (Linux, Windows, macOS)
- Auto-detection of file encodings
youtube-history-analytics/
├── youtube_analyzer.py # Main script
├── requirements.txt # Python dependencies
├── README.md # Documentation
├── locales.py # Localization files
├── youtube_api_key.txt # YouTube Data API key
├── images/ # Screenshots and images
├── Takeout/ # Extracted archives
│ ├── YouTube and YouTube Music/
│ └── My Activity/
└── youtube_analysis_output/ # Analysis results
├── report.html # HTML report
├── youtube_history_export.csv # CSV export
├── youtube_history_summary.json # Statistics
├── video_durations.csv # Video durations
├── average_convergence.html # Average convergence chart
├── average_progression.csv # Average progression data
├── average_progression.json # JSON with average data
└── README_export.md # Export description
# 1. Install dependencies
pip3 install -r requirements.txt
# 2. Setup API key
echo "YOUR_API_KEY_HERE" > youtube_api_key.txt
# 3. Launch analyzer
python3 youtube_analyzer.py
# 4. Select language (Russian/English)
# 5. Load data from Takeout
# 6. Get video duration
# 7. Generate HTML report- Load data → automatic combination of two sources
- Get duration → sample 100-1000 videos to start
- Generate report → create interactive graphs
- Export CSV → data for Excel/Google Sheets
- View results → analyze viewing habits
- Peak hours: when you most often watch YouTube
- Favorite days: which days of week have higher activity
- Trends: how activity changes by months
- Top channels: your favorite content creators
- Watch time: total time spent on YouTube
After analysis, you will have:
- HTML report with interactive graphs
- CSV file for further analysis
- Viewing statistics
- Clean data without duplicates and music
- Video duration for accurate time calculation
- Average convergence chart for video duration analysis
- Average progression data in CSV and JSON formats
- Understanding of your viewing habits
Below are screenshots of various sections of the HTML report generated by the analyzer:
💡 Tip: Click on any image to open it in full size
Analyze your YouTube history with pleasure and accurate time data!











