Suggest Videos From YouTube Playlist #1437

Merged
merged 6 commits into from Mar 28, 2016

Projects

None yet

2 participants

@phil-lopreiato
Member

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_key with the value of a new Google API key (generated in dev console), as well as enable the YouTube Data v3 API

@phil-lopreiato phil-lopreiato Add suggestions from YouTube playlist
Input a playlist ID, use YouTube API to get a list of videos. Display a
page with those video titles and have user input corresponding match
partial.

Also refactors YT suggestion creation into common function
33f0e31
@fangeugene fangeugene commented on an outdated diff Mar 28, 2016
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
@fangeugene fangeugene commented on an outdated diff Mar 28, 2016
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>&lt;Match Type Abbreviation&gt;m&lt;Match Number&gt;</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>
@fangeugene
fangeugene Mar 28, 2016 Member

close parens

@fangeugene fangeugene commented on an outdated diff Mar 28, 2016
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
fangeugene Mar 28, 2016 Member

I think we should call this "Match ID" everywhere user-facing. It's more digestible than "Match Partial" IMO

@fangeugene fangeugene commented on an outdated diff Mar 28, 2016
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>&lt;Match Type Abbreviation&gt;m&lt;Match Number&gt;</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>
@fangeugene
fangeugene Mar 28, 2016 Member

The following are examples of acceptable...

@fangeugene fangeugene commented on an outdated diff 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
fangeugene Mar 28, 2016 Member

You should make this target="_blank" so clicking on a link doesn't wipe all progress.

@fangeugene fangeugene commented on an outdated diff Mar 28, 2016
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 fangeugene merged commit f310798 into the-blue-alliance:master Mar 28, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@phil-lopreiato phil-lopreiato deleted the phil-lopreiato:yt-playlist branch Mar 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment