diff --git a/balises.py b/balises.py index 4f47c13..c83e12b 100755 --- a/balises.py +++ b/balises.py @@ -7,6 +7,7 @@ import datetime as dt import bs4 import requests import os +import urllib.parse from peewee import * from bottle import hook, request, route, run, view @@ -129,9 +130,15 @@ def results_page(): delta = int(request.forms.timedelta or 0) hour = hour + delta time = '{:0>2}:00'.format(hour) - - results = search_song(day, hour) - return dict(results=[x for x in results], + results = [ + { 'date': x.date, + 'song': x.song, + 'youtube_url': 'https://www.youtube.com/results?search_query=' + + urllib.parse.quote_plus(x.song.artist + ' ' + x.song.title) + } + for x in search_song(day, hour) + ] + return dict(results=results, date=day, time=time, start_time=time, diff --git a/views/search_results.tpl b/views/search_results.tpl index 20910b8..3b23fc1 100644 --- a/views/search_results.tpl +++ b/views/search_results.tpl @@ -34,15 +34,15 @@
| {{str(x.date.time())}} | -{{x.song.artist}} | -{{x.song.title}} | -+ | {{str(x['date'].time())}} | +{{x['song'].artist}} | +{{x['song'].title}} | +
|---|