Add /videos to get overall list of videos.
This commit is contained in:
parent
2959673f74
commit
1c85df8ba1
1 changed files with 24 additions and 4 deletions
28
ycdl_site.py
28
ycdl_site.py
|
@ -122,14 +122,34 @@ def get_channels():
|
||||||
channel['has_pending'] = youtube.channel_has_pending(channel['id'])
|
channel['has_pending'] = youtube.channel_has_pending(channel['id'])
|
||||||
return flask.render_template('channels.html', channels=channels)
|
return flask.render_template('channels.html', channels=channels)
|
||||||
|
|
||||||
|
@site.route('/videos')
|
||||||
|
@site.route('/videos/<download_filter>')
|
||||||
@site.route('/channel/<channel_id>')
|
@site.route('/channel/<channel_id>')
|
||||||
@site.route('/channel/<channel_id>/<download_filter>')
|
@site.route('/channel/<channel_id>/<download_filter>')
|
||||||
def get_channel(channel_id, download_filter=None):
|
def get_channel(channel_id=None, download_filter=None):
|
||||||
channel = youtube.get_channel(channel_id)
|
if channel_id is not None:
|
||||||
if channel is None:
|
youtube.add_channel(channel_id)
|
||||||
flask.abort(404)
|
channel = youtube.get_channel(channel_id)
|
||||||
|
if channel is None:
|
||||||
|
flask.abort(404)
|
||||||
|
else:
|
||||||
|
channel = None
|
||||||
|
|
||||||
videos = youtube.get_videos(channel_id=channel_id, download_filter=download_filter)
|
videos = youtube.get_videos(channel_id=channel_id, download_filter=download_filter)
|
||||||
|
|
||||||
|
search_term = request.args.get('q', None)
|
||||||
|
if search_term is not None:
|
||||||
|
search_term = search_term.lower()
|
||||||
|
videos = [v for v in videos if search_term in v['title'].lower()]
|
||||||
|
|
||||||
|
limit = request.args.get('limit', None)
|
||||||
|
if limit is not None:
|
||||||
|
try:
|
||||||
|
limit = int(limit)
|
||||||
|
videos = videos[:limit]
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
for video in videos:
|
for video in videos:
|
||||||
published = video['published']
|
published = video['published']
|
||||||
published = datetime.datetime.utcfromtimestamp(published)
|
published = datetime.datetime.utcfromtimestamp(published)
|
||||||
|
|
Loading…
Reference in a new issue