Suggest Videos From YouTube Playlist #1437
controllers/ajax_controller.py
| @@ -195,3 +197,52 @@ def memcacheFlush(self, event_key): | ||
| keys = [self._render_cache_key(self.CACHE_KEY_FORMAT.format(event_key, n)) for n in range(10)] | ||
| memcache.delete_multi(keys) | ||
| return keys | ||
| + | ||
| + | ||
| +class YouTubePlaylistHandler(LoggedInHandler): | ||
| + """ | ||
| + For Hittin the YouTube API to get a list of video keys associated with a playlist |
|
|
templates_jinja2/suggest_match_video_playlist.html
| + <div class="panel-body"> | ||
| + <p>Thanks for helping make The Blue Alliance better! Let us know about videos so we can add them to the site!</p> | ||
| + <ul> | ||
| + <li>Your suggestion will be reviewed by a moderator</li> | ||
| + <li>Your account info (like {{user_bundle.user.email()}} and {{user_bundle.user.nickname()}}) will also be submitted. <a href="{{user_bundle.logout_url}}">log in as a different user</a></li> | ||
| + </ul> | ||
| + <div class="alert alert-success"> | ||
| + <strong>Match Partial Examples</strong> | ||
| + <p>Enter the "match partial" for the various videos in the playlist you want to suggest to The Blue Alliance. A valid match partial consists of <code><Match Type Abbreviation>m<Match Number></code>. Leave the field blank if you do not wish to submit the video as a suggestion or if it is not a match video (e.g. award ceremony).</p> | ||
| + <p>The following are acceptable match type abbreviations: <code>q, qf1, sf2, f1</code></p> | ||
| + <p>Below are some examples of valid match partials:</p> | ||
| + <ul> | ||
| + <li>qm3 (Qualification Match #3)</li> | ||
| + <li>qf2m1 (Quarterfinal 2 Match #1)</li> | ||
| + <li>sf1m3 (Semifinal 1 Match #3)</li> | ||
| + <li>f1m3 (Finals Match #3</li> |
|
|
templates_jinja2/suggest_match_video_playlist.html
| + <h4>Thanks!</h4> | ||
| + <p>Added {{ num_added }} new suggestions. We'll review them and get them added to the site soon!</p> | ||
| + </div> | ||
| + {% endif %} | ||
| + <div class="panel panel-default"> | ||
| + <div class="panel-heading"> | ||
| + <h1 class="panel-title">Help others by adding videos!</h1> | ||
| + </div> | ||
| + <div class="panel-body"> | ||
| + <p>Thanks for helping make The Blue Alliance better! Let us know about videos so we can add them to the site!</p> | ||
| + <ul> | ||
| + <li>Your suggestion will be reviewed by a moderator</li> | ||
| + <li>Your account info (like {{user_bundle.user.email()}} and {{user_bundle.user.nickname()}}) will also be submitted. <a href="{{user_bundle.logout_url}}">log in as a different user</a></li> | ||
| + </ul> | ||
| + <div class="alert alert-success"> | ||
| + <strong>Match Partial Examples</strong> |
|
fangeugene
I think we should call this "Match ID" everywhere user-facing. It's more digestible than "Match Partial" IMO |
templates_jinja2/suggest_match_video_playlist.html
| + </div> | ||
| + {% endif %} | ||
| + <div class="panel panel-default"> | ||
| + <div class="panel-heading"> | ||
| + <h1 class="panel-title">Help others by adding videos!</h1> | ||
| + </div> | ||
| + <div class="panel-body"> | ||
| + <p>Thanks for helping make The Blue Alliance better! Let us know about videos so we can add them to the site!</p> | ||
| + <ul> | ||
| + <li>Your suggestion will be reviewed by a moderator</li> | ||
| + <li>Your account info (like {{user_bundle.user.email()}} and {{user_bundle.user.nickname()}}) will also be submitted. <a href="{{user_bundle.logout_url}}">log in as a different user</a></li> | ||
| + </ul> | ||
| + <div class="alert alert-success"> | ||
| + <strong>Match Partial Examples</strong> | ||
| + <p>Enter the "match partial" for the various videos in the playlist you want to suggest to The Blue Alliance. A valid match partial consists of <code><Match Type Abbreviation>m<Match Number></code>. Leave the field blank if you do not wish to submit the video as a suggestion or if it is not a match video (e.g. award ceremony).</p> | ||
| + <p>The following are acceptable match type abbreviations: <code>q, qf1, sf2, f1</code></p> |
|
|
phil-lopreiato
added
some commits
Mar 28, 2016
templates_jinja2/suggest_match_video_playlist.html
| + video_list.empty(); | ||
| + video_list.append($("<p>Invalid playlist URL</p>")); | ||
| + return; | ||
| + } | ||
| + video_list.empty(); | ||
| + video_list.append($("<p>Loading videos...</p>")); | ||
| + $.get("/_/yt/playlist/videos", {'playlist_id': playlist_id}).done(function(data) { | ||
| + var video_ids = JSON.parse(data); | ||
| + video_list.empty(); | ||
| + video_list.append($("<input>", {name: "num_videos", type: "hidden", value: video_ids.length})); | ||
| + $.each(video_ids, function(index, video_data) { | ||
| + var yt_id = video_data['snippet']['resourceId']['videoId']; | ||
| + var li = $("<li>"); | ||
| + var group = $('<div>', {class: 'input-group'}); | ||
| + li.append(group); | ||
| + group.append($("<a>", {href:"https://youtu.be/"+yt_id}).append($("<h4>"+video_data['snippet']['title']+"</h4>"))); |
|
fangeugene
You should make this target="_blank" so clicking on a link doesn't wipe all progress. |
templates_jinja2/suggest_match_video_playlist.html
| @@ -0,0 +1,101 @@ | ||
| +{% extends "base.html" %} | ||
| + | ||
| +{% block title %}The Blue Alliance - Add Match Video{% endblock %} | ||
| + | ||
| +{% block meta_description %}Add match videos to The Blue Alliance.{% endblock %} | ||
| + | ||
| +{% block content %} | ||
| +<script type="text/javascript"> |
|
fangeugene
Put the javascript in a {% block inline_javascript %}{% endblock %} https://github.com/the-blue-alliance/the-blue-alliance/blob/master/templates_jinja2/base.html#L166 |
phil-lopreiato
added
some commits
Mar 28, 2016
1 check passed
continuous-integration/travis-ci/pr
The Travis CI build passed
Details
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Input a playlist id, and then relate match partials to each video (invalid/leave blank to ignore)
Try it out at http://tba.lopreiato.me/suggest/event/video?event_key=2016nyny with playlist ID https://www.youtube.com/playlist?list=PLLDODAGuIHqNRyZPxoHlvwMsJYP79ptCv
You'll need to add a sitevar named
youtube_api_keywith the value of a new Google API key (generated in dev console), as well as enable the YouTube Data v3 API