def process_track(target, stem_mapping): """Process a single episode from the 99pi Sound Cloud listing. @param target: The track listing returned from the Sound Cloud API. @type target: dict @return: Dictionary describing the episode. Contains keys name (str value), date (datetime.date), loc (url - str value), duration (seconds - int), and orig_tags (tags applied to episode - list of str) @rtype: dict """ name = target['title'].replace('99% Invisible-', '') date = interpret_99pi_date(target['created_at']) loc = target['permalink'] duration = target['duration'] / 1000 tags = common.get_tags_by_nlp( target['description'], MAPPED_PHRASES, stem_mapping, FILTERED_PHRASES ) return { 'name': name, 'date': date, 'loc': loc, 'duration': duration, 'orig_tags': tags }
def get_item_tags(title, item_soup, stem_mapping): """Get the tags for an episode. @param title: The title of the episode. @type title: basestring @param item_soup: Soup containing episode information. @type item_soup: bs4.BeautifulSoup @param stem_mapping: Mapping renaming stems for nlptk. @type stem_mapping: dict (str to str) """ description_content = title + '. ' + get_description_content(item_soup) return common.get_tags_by_nlp( description_content, PHRASE_REPLACEMENTS, stem_mapping, FILTERED_PHRASES )