Encode youtube url parameter correctly
This commit is contained in:
13
balises.py
13
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,
|
||||
|
||||
Reference in New Issue
Block a user