Skip to content

Instantly share code, notes, and snippets.

@gokart23
Forked from rjchee/download.py
Last active December 19, 2019 00:28
Show Gist options
  • Save gokart23/7bbaf3f8d09037ec0ff03d19188959a8 to your computer and use it in GitHub Desktop.
Save gokart23/7bbaf3f8d09037ec0ff03d19188959a8 to your computer and use it in GitHub Desktop.
Download videos from Panopto based on RSS feed file
#!/bin/env python3
import argparse, sys
import os, subprocess
import xml.etree.ElementTree as ET
parser = argparse.ArgumentParser()
parser.add_argument("--rssfile", help="Location of RSS feed file downloaded from Panopto",
required=True, type=argparse.FileType('r'))
args = parser.parse_args()
with args.rssfile as rss:
et = ET.parse(rss)
root = et.getroot()
for name, url in zip((e.text for e in root.findall('./channel/item/title')),
(e.attrib['url'] for e in root.findall('./channel/item/enclosure'))):
download_name = f"{name.replace(' ', '-')}.mp4"
if os.path.isfile(download_name):
print(f'Skipping {download_name} because it already exists')
else:
subprocess.run(['wget', f"-O{download_name}", url])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment