DEV Community

LousyCake
LousyCake

Posted on

Unleashing YTStatsAnalyzerGo: A Go-Powered Dive into YouTube Channel Insights

Introduction:

Dive into the world of data-driven YouTube channel insights with YTStatsAnalyzerGo, an open-source YouTube Channel Statistics Analyzer crafted in Go. Uncover the power of the YouTube Data API v3 as we journey into fetching channel statistics and analyzing top videos based on views, likes, and comments.

Getting Started:

Prerequisites:
Before embarking on your data exploration with YTStatsAnalyzerGo, make sure you have Go installed on your machine. Additionally, secure a Google Cloud API key for YouTube Data API v3.

Installation:

  • Clone the Repository:
git clone https://github.com/yourusername/YTStatsAnalyzerGo.git
cd YTStatsAnalyzerGo
Enter fullscreen mode Exit fullscreen mode
  • Add Your API Key:

Insert your Google Cloud API key into the 'apiKey' constant in 'main.go':

const apiKey = "YOUR_API_KEY"
Enter fullscreen mode Exit fullscreen mode
  • Run the Application:
go run main.go
Enter fullscreen mode Exit fullscreen mode

Usage:

  • Fetching Channel Statistics: Run the command to fetch and display channel statistics for a specified channel:
go run main.go
Enter fullscreen mode Exit fullscreen mode
  • Analyzing Top Videos:
    Analyze top videos based on views, likes, and comments. Results can be printed to the console or saved to a CSV file.
    Examples:

  • Analyzing most viewed videos:

go run main.go -top=views -count=10
Enter fullscreen mode Exit fullscreen mode
  • Analyzing least viewed videos:
go run main.go -top=views -count=10 -asc
Enter fullscreen mode Exit fullscreen mode
  • Saving to CSV: Save results to a CSV file using the '-csv' flag:
go run main.go -top=likes -count=5 -csv=output.csv
Enter fullscreen mode Exit fullscreen mode

Customization:

  • Modifying Output: Customize the output format by tweaking the 'getTopVideosCSV' function in 'main.go'.

Example: Changing CSV Format:
Modify the CSV format by updating the 'getTopVideosCSV' function. For instance:

result.WriteString("Rank,Title,Views,Likes,Comments\n")
result.WriteString(fmt.Sprintf("%d,\"%s\",%d,%d,%d\n",
    i+1, video.Snippet.Title, video.Statistics.ViewCount, video.Statistics.LikeCount, video.Statistics.CommentCount))
Enter fullscreen mode Exit fullscreen mode

Contributing:

Contributions are more than welcome! Feel free to fork the repository and submit a pull request, as we collectively enhance YTStatsAnalyzerGo.

Embark on Your Data Odyssey:

Explore, analyze, and elevate your understanding of YouTube channel dynamics with YTStatsAnalyzerGo. Let's unravel the secrets hidden in data and empower content creators!

Top comments (0)