Last active
August 29, 2015 13:59
-
-
Save glasslion/10798278 to your computer and use it in GitHub Desktop.
A simple script extract metadata from a Pyvideo category feed url, and print to stdout.
This file contains 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
# coding: utf-8 | |
from __future__ import print_function | |
import feedparser | |
import sys, codecs | |
if not sys.stdout.isatty(): | |
sys.stdout = codecs.getwriter('utf8')(sys.stdout) | |
if __name__ == '__main__': | |
PYVIDEO_FEED_URL = sys.argv[1] | |
d = feedparser.parse(PYVIDEO_FEED_URL) | |
for entry in d.entries: | |
print('## Title: %s ##' % entry.title) | |
if hasattr(entry, 'author'): | |
print ('*Author: %s*' % entry.author) | |
print ('[Youtube Link](%s) ' % entry.links[1].href) | |
summary = entry.summary.split('\n') | |
for (index,line) in enumerate(summary): | |
if line == "<p>Abstract</p>": | |
continue | |
if len(summary) > 100 and line.startswith('<p>Description</p>'): | |
# some summaries are too long, truncate them | |
break | |
print(line, end=',') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment