Skip to content

Instantly share code, notes, and snippets.

@samrat
Last active March 4, 2016 17:09
Show Gist options
  • Select an option

  • Save samrat/fc752012826724204252 to your computer and use it in GitHub Desktop.

Select an option

Save samrat/fc752012826724204252 to your computer and use it in GitHub Desktop.
import feedparser
import subprocess
import os
import sys
def download_entry(entry):
ext = os.path.splitext(entry.link)[1]
subprocess.call(["wget", entry.link, "-O", entry.title + ext, "-c"])
def download_all_entries(feed_url):
with open('curr_download', 'r') as curr_dl_file_r:
try:
curr_dl_index = int(curr_dl_file_r.read())
except ValueError:
curr_dl_index = 0
print("Parsing feed: ", feed_url)
d = feedparser.parse(feed_url)
for entry in d.entries[curr_dl_index:]:
print("Downloading ", entry.title)
download_entry(entry)
curr_dl_index += 1
with open('curr_download', 'w') as file_w:
file_w.write(str(curr_dl_index))
if __name__ == '__main__':
if (len(sys.argv) != 2):
sys.exit("Usage: python panopto_feed_dl.py <feed_url>")
download_all_entries(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment