def get_podcasts(): sheet = get_google_sheet() podcast_list = [] for i, podcast in enumerate(sheet): if podcast['Category']: podcast['slug'] = slugify(podcast['Name']) podcast_list.append(podcast) if podcast['RSS']: feed_url = podcast['RSS'] response = requests.get(feed_url) html = response.content soup = BeautifulSoup(html) all_enclosure_urls = soup.findAll(re.compile('^enclosure')) recent_episodes = [tag['url'] for tag in all_enclosure_urls] recent_titles = soup.findAll('title') podcast['recent_zero'] = recent_episodes[0] podcast['title_zero'] = recent_titles[2].string podcast['recent_one'] = recent_episodes[1] podcast['title_one'] = recent_titles[3].string podcast['recent_two'] = recent_episodes[2] podcast['title_two'] = recent_titles[4].string return podcast_list
def index(): sheets = get_google_sheet() staff_picks = [] for index, pick in enumerate(sheets): staff_pick = {} staff_pick["recommender"] = json.dumps(pick["Recommender"]) staff_pick["title"] = json.dumps(pick["Title"]) staff_pick["twitter"] = json.dumps(pick["Twitter"]) staff_pick["episode"] = json.dumps(pick["Episode"]) staff_pick["podcast"] = json.dumps(pick["Podcast"]) staff_pick["audio"] = json.dumps(pick["Audio"]) staff_pick["link"] = json.dumps(pick["Link"]) staff_pick["description"] = json.dumps(pick["Description"]) staff_picks.append(staff_pick) return render_template("staff_picks.json", staff_picks=staff_picks)
def get_bands(): sheet = get_google_sheet() band_list = [] for i, band in enumerate(sheet): if band['video']: band['slug'] = slugify(band['bandname']) band['bandmembers'] = [member for member in band['bandmembers'].split(';') if member] for j, member in enumerate(band['bandmembers']): member_list = member.split(',') band['bandmembers'][j] = {'name': member_list[0], 'instrument': member_list[1]} band['setlist'] = band['setlist'].split(';') band_list.insert(0, band) else: band_list.append(band) return band_list
def index(): sheets = get_google_sheet() staff_picks = [] for index, pick in enumerate(sheets): staff_pick = {} staff_pick['recommender'] = json.dumps(pick['Recommender']) staff_pick['title'] = json.dumps(pick['Title']) staff_pick['twitter'] = json.dumps(pick['Twitter']) staff_pick['episode'] = json.dumps(pick['Episode']) staff_pick['podcast'] = json.dumps(pick['Podcast']) staff_pick['audio'] = json.dumps(pick['Audio']) staff_pick['link'] = json.dumps(pick['Link']) staff_pick['description'] = json.dumps(pick['Description']) staff_picks.append(staff_pick) return render_template( 'staff_picks.json', staff_picks=staff_picks, )
def index(): os.environ["TZ"] = "US/Eastern" time.tzset() timestamp = time.strftime("%Y-%m-%d %H:%M:%S") sheets = get_google_sheet() stories = [] if len(sheets["vpr_news"]) > 0: for index, story in enumerate(sheets["vpr_news"]): this_story = {} this_story["link"] = json.dumps(story["Link"]) if story["Story ID"] == "": this_story["story_id"] = 0 else: this_story["story_id"] = story["Story ID"] stories.append(this_story) callout = {} callout["uri"] = sheets["callout"][0]["URI"] callout["text"] = json.dumps(sheets["callout"][0]["Text"]) billboard = {} if sheets["billboard"][0]["Story ID"] == "": billboard["story_id"] = 0 else: billboard["story_id"] = sheets["billboard"][0]["Story ID"] billboard["title"] = json.dumps(sheets["billboard"][0]["Title"]) billboard["text"] = json.dumps(sheets["billboard"][0]["Text"]) billboard["link"] = json.dumps(sheets["billboard"][0]["Link"]) billboard["facebook"] = json.dumps(sheets["billboard"][0]["Facebook"]) billboard["twitter"] = json.dumps(sheets["billboard"][0]["Twitter"]) billboard["email"] = json.dumps(sheets["billboard"][0]["Email"]) billboard["phone"] = json.dumps(sheets["billboard"][0]["Phone"]) return render_template( "vpr-homepage-app.json", timestamp=timestamp, stories=stories, callout=callout, billboard=billboard )
def get_results(): full_list = get_google_sheet() return full_list
def get_festivals(): full_list = get_google_sheet() festivals = restructure_festivals(full_list) return festivals
#!/usr/bin/python from slugify import slugify from sheet import get_google_sheet sheet = get_google_sheet() def get_chapters(): chapter_list = [] for i, chapter in enumerate(sheet): chapter['slug'] = slugify(unicode(chapter['Name'])) chapter_list.append(chapter) return chapter_list def get_slugs(Name): slugs = [slugify(unicode(i['Name'])) for i in sheet] links = False next = False prev = False for i in range(len(slugs)): if Name == slugs[i]: if i + 1 < len(slugs): next = slugs[i + 1] if i > 0: prev = slugs[i - 1] links = {'next': next, 'prev': prev}