def get_embed_details_google(id): """Given a Google Video ID, return the associated thumbnail URL and the duration of the video. :param id: a valid Google Video ID :type id: string :returns: Thumbnail URL (or None), and duration (or None) :rtype: tuple (string, int) """ google_data_url = 'http://video.google.com/videofeed?docid=%s' % id thumb_url = None duration = None title = None # Google Video doesn't appear to expose the title from mediacore.lib.helpers import decode_entities try: temp_data = urllib2.urlopen(google_data_url) data = temp_data.read() temp_data.close() thumb_match = google_image_rgx.search(data) dur_match = google_duration_rgx.search(data) if thumb_match: thumb_url = decode_entities(thumb_match.group(1)) if dur_match: duration = int(dur_match.group(1)) except urllib2.URLError, e: log.exception(e)
def option_tree(cats): indent = helpers.decode_entities(u' ') * 4 return [(None, None)] + \ [(c.id, indent * depth + c.name) for c, depth in cats.traverse()]
def _to_python(self, value, state=None): """Convert XHTML entities to unicode.""" return decode_entities(value)
def option_tree(cats): indent = helpers.decode_entities(u" ") * 4 return [(None, None)] + [(c.id, indent * depth + c.name) for c, depth in cats.traverse()]