Last active
March 4, 2016 17:09
-
-
Save samrat/fc752012826724204252 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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