Skip to content

Instantly share code, notes, and snippets.

@glasslion
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glasslion/10798278 to your computer and use it in GitHub Desktop.
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.
# 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