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 bs4
|
||||||
import requests
|
import requests
|
||||||
import os
|
import os
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
from peewee import *
|
from peewee import *
|
||||||
from bottle import hook, request, route, run, view
|
from bottle import hook, request, route, run, view
|
||||||
@@ -129,9 +130,15 @@ def results_page():
|
|||||||
delta = int(request.forms.timedelta or 0)
|
delta = int(request.forms.timedelta or 0)
|
||||||
hour = hour + delta
|
hour = hour + delta
|
||||||
time = '{:0>2}:00'.format(hour)
|
time = '{:0>2}:00'.format(hour)
|
||||||
|
results = [
|
||||||
results = search_song(day, hour)
|
{ 'date': x.date,
|
||||||
return dict(results=[x for x in results],
|
'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,
|
date=day,
|
||||||
time=time,
|
time=time,
|
||||||
start_time=time,
|
start_time=time,
|
||||||
|
|||||||
@@ -34,15 +34,15 @@
|
|||||||
<input value="Chercher" type="submit" />
|
<input value="Chercher" type="submit" />
|
||||||
</form>
|
</form>
|
||||||
<h1>Chansons du {{date.strftime('%A %d %B %Y')}} entre {{start_time}} et {{end_time}}</h1>
|
<h1>Chansons du {{date.strftime('%A %d %B %Y')}} entre {{start_time}} et {{end_time}}</h1>
|
||||||
<a href="#" id="go_sooner">[Plus tôt]</a>
|
<a href="#" id="go_sooner">[<i class="fas fa-angle-left"></i> Plus tôt]</a>
|
||||||
<a href="#" id="go_later">[Plus tard]</a>
|
<a href="#" id="go_later">[Plus tard <i class="fas fa-angle-right"></i>]</a>
|
||||||
<table id="results">
|
<table id="results">
|
||||||
% for x in results:
|
% for x in results:
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{str(x.date.time())}}</th>
|
<th>{{str(x['date'].time())}}</th>
|
||||||
<td>{{x.song.artist}}</td>
|
<td>{{x['song'].artist}}</td>
|
||||||
<td>{{x.song.title}}</td>
|
<td>{{x['song'].title}}</td>
|
||||||
<td><a href="https://www.youtube.com/results?search_query={{x.song.artist + ' ' + x.song.title}}" title="Rechercher sur Youtube"><i class="fab fa-lg fa-youtube"></i></a></td>
|
<td><a href="{{x['youtube_url']}}" title="Rechercher sur Youtube"><i class="fab fa-lg fa-youtube"></i></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
% end
|
% end
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user