Skip to content

Instantly share code, notes, and snippets.

@larsenv
Last active August 1, 2021 21:40
Show Gist options
  • Save larsenv/b5cc58808c02e630c85cd7f880e89aca to your computer and use it in GitHub Desktop.
Save larsenv/b5cc58808c02e630c85cd7f880e89aca to your computer and use it in GitHub Desktop.
PBS Livestream Downloader
import json
import requests
import subprocess
stations = {}
stations["Alabama Public Television"] = "WBIQ"
stations["Alaska Public Media"] = "KAKM"
stations["Arizona Public Media"] = "KUAT"
stations["Arkansas PBS"] = "KETS"
stations["Austin PBS"] = "KLRU"
stations["Colorado Public Television"] = "KBDI"
stations["Connecticut Public Broadcasting"] = "WEDH"
stations["Detroit Public Television"] = "WTVS"
stations["East Tennessee PBS"] = "WETP"
stations["Illinois Public Media"] = "WILL"
stations["Iowa PBS"] = "KDIN"
stations["KAMU"] = "KAMU"
stations["Kansas City PBS"] = "KCPT"
stations["KCTS"] = "KCTS"
stations["KEDT"] = "KEDT"
stations["KIXE"] = "KIXE"
stations["KLRN"] = "KLRN"
stations["KMOS"] = "KMOS"
stations["KNPB"] = "KNPB"
stations["KPBS"] = "KPBS"
stations["KPTS"] = "KPTS"
stations["KRWG"] = "KRWG"
stations["KTWU"] = "KTWU"
stations["KUAC"] = "KUAC"
stations["KUED"] = "KUED"
stations["KVIE"] = "KVIE"
stations["Lakeland LPTV"] = "KAWE"
stations["Louisiana Public Broadcasting"] = "WLPB"
stations["Maine Public Broadcasting"] = "WCBB"
stations["Milwaukee PBS"] = "WMVS"
stations["MontanaPBS"] = "KUSM"
stations["Mountain Lake PBS"] = "WCFE"
stations["Nashville Public Television"] = "WNPT"
stations["Nebraska Network"] = "KUON"
stations["New Mexico PBS"] = "KNME"
stations["NJTV"] = "WNJT"
stations["North California Public Media"] = "KRCB"
stations["Oregon Public Broadcasting"] = "KOPB"
stations["Ozarks Public Television"] = "KOZK"
stations["PBS Charlotte "] = "WTVI"
stations["PBS SoCal"] = "KOCE"
stations["Pioneer Public TV"] = "KWCM"
stations["Prairie Public Broadcasting"] = "KFME"
stations["WQPT PBS"] = "WQPT"
stations["Rhode Island PBS"] = "WSBE"
stations["Rocky Mountain PBS"] = "KRMA"
stations["Smoky Hills PBS"] = "KOOD"
stations["SOPTV"] = "KSYS"
stations["South Dakota Public Broadcasting"] = "KUSD"
stations["The Kentucky Network"] = "WKLE"
stations["The Nine Network of Public Media"] = "KETC"
stations["Thirteen"] = "WNET"
stations["UNC-TV"] = "WUNC"
stations["Vegas PBS"] = "KLVX"
stations["WBGU"] = "WBGU"
stations["WEDU"] = "WEDU"
stations["WEIU"] = "WEIU"
stations["West VA Public Broadcasting"] = "WVPB"
stations["WETA"] = "WETA"
stations["WGTE"] = "WGTE"
stations["WGVU"] = "WGVU"
stations["WHRO"] = "WHRO"
stations["WHUT"] = "WHUT"
stations["WHYY"] = "WHYY"
stations["WITF"] = "WITF"
stations["WJCT"] = "WJCT"
stations["WKNO"] = "WKNO"
stations["WLIW"] = "WLIW"
stations["WMHT"] = "WMHT"
stations["WNED"] = "WNED"
stations["WNIN"] = "WNIN"
stations["WOSU"] = "WOSU"
stations["WQED"] = "WQED"
stations["WQLN"] = "WQLN"
stations["WSIU"] = "WSIU"
stations["WSRE"] = "WSRE"
stations["WTIU/WFIU"] = "WTIU"
stations["WTTW"] = "WTTW"
stations["WTVP"] = "WTVP"
stations["WUCF"] = "WUCF"
stations["WUFT-TV"] = "WUFT"
stations["WVUT"] = "WVUT"
stations["WXXI Public Broadcasting"] = "WXXI"
stations["WYES"] = "WYES"
stations["Wyoming PBS"] = "KCWC"
print("==========PBS Livestream Downloader==========\n")
print("Stations List:\n")
i = 0
for k,v in stations.items():
i += 1
print(str(i) + ". " + k)
selection = input("\nPlease enter the number of the station you want to download: ")
url = "https://jaws.pbs.org/localization/false/?callsign=" + list(stations.values())[int(selection) - 1] + "&profile=color"
response = requests.get(url).text
livestream_url = json.loads(response)["station"]["skylab_data"]["ga_live_stream_url"]
print("\nDownloading... Press Control+C or close the window to finish the downloading.")
k = 0
job = subprocess.call(["ffmpeg", "-i", livestream_url, list(stations.keys())[int(selection) - 1].replace(" ", "_") + ".mkv"])
@CodesForIdiots2002
Copy link

Larsen, can you make a tutorial on how to do this please? Cause I don't get it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment