Skip to content

Instantly share code, notes, and snippets.

@andkamau
andkamau / youtube_screen_scrape.py
Created October 16, 2016 18:38 — forked from ljmccarthy/youtube_screen_scrape.py
An example of how to download metadata for all videos of a specified YouTube channel using simple BeautifulSoup screen scraping. The data will be much more up-to-date and reliable than the RSS feed or YouTube API results (which is a sad state of affairs really).
import urllib
import json
from bs4 import BeautifulSoup
from collections import namedtuple
Video = namedtuple("Video", "video_id title duration views thumbnail")
def parse_video_div(div):
video_id = div.get("data-context-item-id", "")
title = div.find("a", "yt-uix-tile-link").text
import os, sys
from datetime import datetime
from ckanapi import RemoteCKAN
API_KEY = os.getenv("CKAN_API_KEY", None)
USER_AGENT = "openafrica-client"
URL = "https://africaopendata.org"
def upload_files(directory, dataset):