Skip to content

Instantly share code, notes, and snippets.

@dreness
Last active November 13, 2019 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dreness/cb65c272328d5bad2517660775c57db6 to your computer and use it in GitHub Desktop.
Save dreness/cb65c272328d5bad2517660775c57db6 to your computer and use it in GitHub Desktop.
cc_southpark.py uses #BeautifulSoup to produce a list of links to #SouthPark episodes
#!/usr/bin/env python3
import json
from beautifulscraper import BeautifulScraper
from pprint import pprint as pp
URL = "http://southpark.cc.com/feeds/carousel/video/08f60a6f-24a8-4d88-88a3-eb5588494cbc/30/1/json/views/season-"
# a sample item:
'''
{
"contentType": "Video",
"itemId": "8f5ef4a4-8300-4e52-95ff-459008c74996",
"title": "It’s Like Mango and Kiwi",
"description": "Kyle, Stan, Kenny and Cartman confront the person who has been selling Vape Pens to Kyle’s little brother.",
"shortDescription": "Kyle, Stan, Kenny and Cartman confront the person who has been selling Vape Pens to Kyle’s little brother.",
"images": "https://southparkstudios.mtvnimages.com/images/shows/south-park/clip-thumbnails/season-22/2204/south-park-s22e04-Its-Like-Mango-and-Kiwi_16x9.jpg",
"originalAirDate": "1539828000",
"episode": {
"title": "Tegridy Farms",
"description": "Butters is selling vape pens and all kinds of fruity-flavored vape accessories at school. Meanwhile, Randy decides he should move the family to the country and take up farming.",
"shortDescription": "Randy moves the family to the country and he takes up farming.",
"originalAirDate": "1539828000",
"episodeNumber": "2204"
},
"viewCount": "125392",
"_url": {
"default": "https://southpark.cc.com/clips/ilnk3q/its-like-mango-and-kiwi#source=08f60a6f-24a8-4d88-88a3-eb5588494cbc:896b2aa3-ac17-11e8-b956-70df2f866ace&position=2&sort=views",
"sidebar": "https://southpark.cc.com/iframes/sidebar/8f5ef4a4-8300-4e52-95ff-459008c74996",
"collection_creator_mobile": "/profile/collection-creator-mobile",
"wiki": "https://southpark.cc.com/wiki/Tegridy_Farms"
},
"_availability": "true",
"_carouselFlag": "/sitewide/img/carousel-flags/preview.png"
},
'''
# The URL in _url.default up to the "#" is the VOD URL
def seasonClips(URL):
VIDS = []
scraper = BeautifulScraper()
body = scraper.go(URL)
j = json.loads(body.text)
for d in j['results']:
u = d.get('_url').get('default').split('#')[0]
VIDS.append(u)
return VIDS
for season in range(1,22):
target = f'{URL}{season}'
# print(target)
[ print(u) for u in seasonClips(target) ]
# Put these URLs in a file, then feed them to youtube-dl:
# cat URLS.txt | xargs youtube-dl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment