From e4a0ea4338dea4717c0d7adcd66106a7ee82252d Mon Sep 17 00:00:00 2001 From: tosiabunio Date: Thu, 2 Jul 2026 12:36:44 +0200 Subject: [PATCH 1/2] Migrate from pytube3 to pytubefix pytube3 is unmaintained and fails with HTTP 410 because YouTube removed the get_video_info endpoint it relies on. Switch to pytubefix, a maintained drop-in fork, and update the stream selection and download calls to its API. Add CLAUDE.md with repo guidance. Co-Authored-By: Claude Fable 5 --- CLAUDE.md | 32 ++++++++++++++++++++++++++++++++ average-colours.py | 8 ++++---- 2 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..6cf21ef --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,32 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Overview + +Single-script Python project that downloads a YouTube video and generates a PNG "barcode" image where each vertical line is the average colour of one frame per second of video. + +## Commands + +Install dependencies (no requirements.txt exists): +``` +pip install pytubefix opencv-python pillow +``` + +Run the script (prompts interactively for a YouTube URL): +``` +python average-colours.py +``` + +There is no test framework, linter, or build step. `test/test.py` is a standalone PIL scratch script, not an automated test — run it directly with `python test/test.py` to see a sample gradient image. + +## Architecture + +Everything lives in `average-colours.py`. The pipeline in `average_colours(video_url)`: + +1. Deletes and recreates the `cache/` working directory (gitignored). +2. Downloads the video via pytubefix as `cache/test.mp4` (360p mp4 stream). +3. `get_colour_list()` uses OpenCV to extract one frame per second (based on FPS) into `cache/frames/`, and `get_average_colour()` computes each frame's mean RGB via `PIL.ImageStat`. +4. Draws one vertical line per frame colour, resizes to 1920x1080, saves as `output.png` in the repo root, and opens it in the default viewer. + +Note: the project originally used `pytube`/`pytube3`, but those are unmaintained and fail against current YouTube (HTTP 410). It now uses `pytubefix`, a maintained drop-in fork. diff --git a/average-colours.py b/average-colours.py index 95c9446..6aaa2be 100644 --- a/average-colours.py +++ b/average-colours.py @@ -1,9 +1,9 @@ #pip install list: -# pytube +# pytubefix # opencv-python # pillow -from pytube import YouTube +from pytubefix import YouTube import cv2 import os import shutil @@ -51,8 +51,8 @@ def average_colours(video_url): #Download video print("downloading video...") video = YouTube(video_url) - stream = video.streams.filter(mime_type="video/mp4",res="360p").all()[0] - stream.download(download_folder, download_name) + stream = video.streams.filter(mime_type="video/mp4",res="360p").first() + stream.download(output_path=download_folder, filename=download_name+".mp4") print("averaging colours...") colour_list = get_colour_list(download_folder, download_name, frame_folder) From 8280dac708c5d85ab4f517429f2cd79778a58022 Mon Sep 17 00:00:00 2001 From: tosiabunio Date: Thu, 2 Jul 2026 12:48:47 +0200 Subject: [PATCH 2/2] Update README install instructions for pytubefix Co-Authored-By: Claude Fable 5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c69c87..462592f 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ git clone https://github.com/ShantnuS/AverageFrameColour.git Next a number of Python libraries need to be installed using pip: ``` -pip install pytube3 +pip install pytubefix pip install opencv-python pip install pillow ```