A script to find the banned reason for YouTube videos. This works by reading json/csv/xlsx files containing YouTube video data. It will grab the video ids from those files and query the YouTube iframe API to get the video's banned reason. We will update the Import files with this information and save them to the Export folder.
The script will add these columns to the video data: banned_status
, banned_reason
, banned_message
(all say pretty much the same thing). If a video is available, these columns will be empty.
- Git clone the repository
- Activate a virtual environment
- Install the requirements
pip install -r requirements.txt
- Import the files you want to process into the 'Import' folder
- Supported file formats are json, csv, and xlsx
- Edit the
video_id_column_name
variable in theprocess.py
file to the name of the column containing the video ids - Run the script
python process.py
- The output will be in the
Export
folder- Currently set to export as xlsx
The script will add these columns to the video data: banned_status
, banned_reason
, banned_message
.
These are three different responses we get from YouTube's iFrame player API. The banned_message
would be the message displayed on the YouTube site. The other values are likley used for YouTube's back end (we don't have documentation on their API).
If banned_status
, banned_reason
, banned_message
are None
, that means the YouTube video is not banned and is accessable.
For the API to work, you need a propritary API key and a cookie from the YouTube iFrame player. There is currenlty one in this project, but we do not know when it will expire. One way to generate your own is to open the player.html
file and fetch the cookie and key from the player:
- In Chrome, open
player.html
. - Open the developer side panel (Ctrl+Shift+I).
- Click on the 'Network' Tab.
- Filter network events by
Name
to order alphabetically. - Look for the event starting with
player?key=
and click on it. - Scroll down to reveal the
Request Headers
and make a note of the API key (within thepath
parameter) as well as thecookie
.
If you are having issues contact Joseph or Thomas.