{"id":15201715,"url":"https://github.com/roneylaurent/youtube-analytics","last_synced_at":"2026-01-07T04:43:29.875Z","repository":{"id":241639176,"uuid":"807282421","full_name":"roneylaurent/YouTube-Analytics","owner":"roneylaurent","description":"YouTube Analytics ","archived":false,"fork":false,"pushed_at":"2024-05-28T20:44:19.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T22:14:41.541Z","etag":null,"topics":["creator-economy","influencers","youtube","youtube-analytics","youtube-api","youtube-channel"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roneylaurent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-28T20:00:40.000Z","updated_at":"2024-11-15T12:58:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"229e3a98-cf31-4e8a-8924-f9fd88f1f60b","html_url":"https://github.com/roneylaurent/YouTube-Analytics","commit_stats":{"total_commits":2,"total_committers":2,"mean_commits":1.0,"dds":0.5,"last_synced_commit":"ae65c6a27bebacbdcd9fb9f8ab570b8a19e8c636"},"previous_names":["roneylaurent/youtube-analytics"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roneylaurent%2FYouTube-Analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roneylaurent%2FYouTube-Analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roneylaurent%2FYouTube-Analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roneylaurent%2FYouTube-Analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roneylaurent","download_url":"https://codeload.github.com/roneylaurent/YouTube-Analytics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245907769,"owners_count":20691991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["creator-economy","influencers","youtube","youtube-analytics","youtube-api","youtube-channel"],"created_at":"2024-09-28T03:21:36.038Z","updated_at":"2026-01-07T04:43:29.848Z","avatar_url":"https://github.com/roneylaurent.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YouTube Channel Analysis README\n\n## Overview\nThis script analyzes a YouTube channel by retrieving and analyzing data from the YouTube API. It collects video details such as views, likes, and comments, and saves the analysis in a CSV file. The script is written in Python and uses the `googleapiclient` and `pandas` libraries.\n\n## Prerequisites\nBefore you run this script, ensure you have the following installed:\n\n- Python 3.x\n- `googleapiclient` library\n- `pandas` library\n\nYou can install the required libraries using pip:\n```bash\npip install google-api-python-client pandas\n```\n\n## Setup\n1. **API Key**: Obtain a YouTube Data API v3 key from the Google Developer Console. Replace `'YOUR-API'` with your API key in the script.\n\n2. **Channel ID**: Identify the YouTube channel ID you wish to analyze. Replace `'THE-CHANNEL-ID'` in the script with the channel ID.\n\n## Script Explanation\n### 1. Import Libraries\n```python\nimport os\nimport pandas as pd\nfrom googleapiclient.discovery import build\n```\n- `os`: For interacting with the operating system.\n- `pandas`: For data manipulation and analysis.\n- `googleapiclient.discovery`: For interacting with the YouTube Data API.\n\n### 2. Configure the YouTube API\n```python\nAPI_KEY = 'YOUR-API'\nyoutube = build('youtube', 'v3', developerKey=API_KEY)\n```\n- Replace `'YOUR-API'` with your actual YouTube Data API v3 key.\n\n### 3. Retrieve Channel Videos\n```python\ndef get_channel_videos(channel_id):\n    videos = []\n    request = youtube.search().list(part='snippet', channelId=channel_id, maxResults=50, order='date')\n    response = request.execute()\n    \n    while response:\n        for item in response['items']:\n            if item['id']['kind'] == 'youtube#video':\n                video_id = item['id']['videoId']\n                videos.append(video_id)\n        \n        if 'nextPageToken' in response:\n            request = youtube.search().list(part='snippet', channelId=channel_id, maxResults=50, order='date', pageToken=response['nextPageToken'])\n            response = request.execute()\n        else:\n            break\n\n    return videos\n```\n- This function retrieves video IDs from a given channel using the YouTube Data API.\n\n### 4. Retrieve Video Details\n```python\ndef get_video_details(video_ids):\n    video_details = []\n    for i in range(0, len(video_ids), 50):\n        request = youtube.videos().list(part='snippet,statistics', id=','.join(video_ids[i:i+50]))\n        response = request.execute()\n        \n        for item in response['items']:\n            video_data = {\n                'video_id': item['id'],\n                'title': item['snippet']['title'],\n                'views': int(item['statistics'].get('viewCount', 0)),\n                'likes': int(item['statistics'].get('likeCount', 0)),\n                'comments': int(item['statistics'].get('commentCount', 0))\n            }\n            video_details.append(video_data)\n    \n    return video_details\n```\n- This function retrieves details such as views, likes, and comments for each video.\n\n### 5. Analyze Channel Data\n```python\ndef analyze_channel(channel_id):\n    video_ids = get_channel_videos(channel_id)\n    video_details = get_video_details(video_ids)\n    \n    df = pd.DataFrame(video_details)\n    print(f\"Total Videos: {len(df)}\")\n    print(f\"Average Views: {df['views'].mean()}\")\n    print(f\"Average Likes: {df['likes'].mean()}\")\n    print(f\"Average Comments: {df['comments'].mean()}\")\n\n    return df\n```\n- This function analyzes the collected video data and prints out the total number of videos, average views, likes, and comments.\n\n### 6. Main Function\n```python\nif __name__ == \"__main__\":\n    channel_id = 'THE-CHANNEL-ID'\n    df = analyze_channel(channel_id)\n    df.to_csv('youtube_channel_analysis.csv', index=False)\n    print(\"Data saved to 'youtube_channel_analysis.csv'\")\n```\n- The main function executes the analysis for a specified channel ID and saves the results to a CSV file.\n\n## Running the Script\n1. Ensure you have replaced `'YOUR-API'` and `'THE-CHANNEL-ID'` with your API key and the channel ID you wish to analyze.\n2. Run the script:\n```bash\npython your_script_name.py\n```\n3. The script will print the analysis results and save them to a file named `youtube_channel_analysis.csv`.\n\n## Output\n- The output CSV file will contain columns for `video_id`, `title`, `views`, `likes`, and `comments` for each video in the analyzed channel.\n\nBy following these steps, you can successfully analyze a YouTube channel's video performance using this script.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froneylaurent%2Fyoutube-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froneylaurent%2Fyoutube-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froneylaurent%2Fyoutube-analytics/lists"}