Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

fixes bug 1163754 - Start submitting S3 URLs to Vid.ly with ?nocopy #339

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions airmozilla/base/tests/test_utils.py
Expand Up @@ -24,6 +24,16 @@ def test_unhtml(self):
input_ = 'A <a href="">FOO</a> BAR'
eq_(utils.unhtml(input_), 'A FOO BAR')

def test_prepare_vidly_video_url(self):
url = 'https://foo.bar/file.flv'
eq_(utils.prepare_vidly_video_url(url), url)

url = 'https://mybucket.s3.amazonaws.com/file.mp4'
eq_(utils.prepare_vidly_video_url(url), url + '?nocopy')

url = 'https://mybucket.s3.amazonaws.com/file.mp4?cachebust=1'
eq_(utils.prepare_vidly_video_url(url), url + '&nocopy')


class _Communicator(object):
def __init__(self, response):
Expand Down
16 changes: 16 additions & 0 deletions airmozilla/base/utils.py
Expand Up @@ -196,3 +196,19 @@ def get_base_url(request):
RequestSite(request).domain
)
)


def prepare_vidly_video_url(url):
"""Return the URL prepared for Vid.ly
See # See http://help.encoding.com/knowledge-base/article/\
save-some-time-on-your-encodes/

Hopefully this will make the transcoding faster.
"""
if 's3.amazonaws.com' in url:
if '?' in url:
url += '&'
else:
url += '?'
url += 'nocopy'
return url
3 changes: 3 additions & 0 deletions airmozilla/manage/views/events.py
Expand Up @@ -33,6 +33,7 @@
unhtml,
shorten_url,
get_base_url,
prepare_vidly_video_url,
)
from airmozilla.main.models import (
Approval,
Expand Down Expand Up @@ -1523,6 +1524,8 @@ def vidly_url_to_shortcode(request, id):
base_url = get_base_url(request)
webhook_url = base_url + reverse('manage:vidly_media_webhook')

url = prepare_vidly_video_url(url)

shortcode, error = vidly.add_media(
url,
token_protection=token_protection,
Expand Down
11 changes: 8 additions & 3 deletions airmozilla/manage/views/vidly_media.py
Expand Up @@ -15,7 +15,11 @@
from jsonview.decorators import json_view
import xmltodict

from airmozilla.base.utils import paginate, get_base_url
from airmozilla.base.utils import (
paginate,
get_base_url,
prepare_vidly_video_url,
)
from airmozilla.main.models import Event, VidlySubmission
from airmozilla.manage import forms
from airmozilla.manage import vidly
Expand Down Expand Up @@ -244,15 +248,16 @@ def vidly_media_resubmit(request):
webhook_url = base_url + reverse('manage:vidly_media_webhook')

old_tag = environment['tag']
url = prepare_vidly_video_url(form.cleaned_data['url'])
shortcode, error = vidly.add_media(
url=form.cleaned_data['url'],
url=url,
hd=form.cleaned_data['hd'],
token_protection=token_protection,
notify_url=webhook_url,
)
VidlySubmission.objects.create(
event=event,
url=form.cleaned_data['url'],
url=url,
token_protection=token_protection,
hd=form.cleaned_data['hd'],
tag=shortcode,
Expand Down
7 changes: 4 additions & 3 deletions airmozilla/new/views.py
Expand Up @@ -26,7 +26,7 @@
from PIL import Image

from airmozilla.manage import vidly
from airmozilla.base.utils import get_base_url
from airmozilla.base.utils import get_base_url, prepare_vidly_video_url
from airmozilla.main.models import (
Event,
VidlySubmission,
Expand Down Expand Up @@ -244,8 +244,9 @@ def event_archive(request, event):
base_url = get_base_url(request)
webhook_url = base_url + reverse('new:vidly_media_webhook')

video_url = prepare_vidly_video_url(upload.url)
tag, error = vidly.add_media(
upload.url,
video_url,
hd=True,
notify_url=webhook_url,
# Note that we deliberately don't bother yet to set
Expand All @@ -257,7 +258,7 @@ def event_archive(request, event):
# then we need to record that we did this
vidly_submission = VidlySubmission.objects.create(
event=event,
url=upload.url,
url=video_url,
tag=tag,
hd=True,
submission_error=error or None
Expand Down
4 changes: 2 additions & 2 deletions bin/crontab/crontab.tpl
Expand Up @@ -9,8 +9,8 @@ HOME=/tmp
# Every 1 hour
0 */1 * * * {{ cron }} send_unsent_tweets 2>&1 | grep -Ev '(DeprecationWarning|UserWarning|simplejson|from pkg_resources)'

# Every 15 minutes
*/15 * * * * {{ cron }} auto_archive 2>&1 | grep -Ev '(DeprecationWarning|UserWarning|simplejson|from pkg_resources)'
# Every 10 minutes
*/10 * * * * {{ cron }} auto_archive 2>&1 | grep -Ev '(DeprecationWarning|UserWarning|simplejson|from pkg_resources)'

# Daily
7 0 * * * {{ cron }} pester_approvals 2>&1 | grep -Ev '(DeprecationWarning|UserWarning|simplejson|from pkg_resources)'
Expand Down