Merge pull request #3039 from edx/valera/separate_youtube_urls
Moved all YouTube related URLs to a separate namespace.
This commit is contained in:
@@ -262,9 +262,9 @@ def check_transcripts(request):
|
||||
log.debug("Can't find transcripts in storage for youtube id: %s", youtube_id)
|
||||
|
||||
# youtube server
|
||||
youtube_api = copy.deepcopy(settings.YOUTUBE_API)
|
||||
youtube_api['params']['v'] = youtube_id
|
||||
youtube_response = requests.get(youtube_api['url'], params=youtube_api['params'])
|
||||
youtube_text_api = copy.deepcopy(settings.YOUTUBE['TEXT_API'])
|
||||
youtube_text_api['params']['v'] = youtube_id
|
||||
youtube_response = requests.get('http://' + youtube_text_api['url'], params=youtube_text_api['params'])
|
||||
|
||||
if youtube_response.status_code == 200 and youtube_response.text:
|
||||
transcripts_presence['youtube_server'] = True
|
||||
|
||||
@@ -119,5 +119,6 @@ except ImportError:
|
||||
pass
|
||||
|
||||
# Point the URL used to test YouTube availability to our stub YouTube server
|
||||
YOUTUBE_TEST_URL = "http://127.0.0.1:{0}/test_youtube/".format(YOUTUBE_PORT)
|
||||
YOUTUBE_API['url'] = "http://127.0.0.1:{0}/test_transcripts_youtube/".format(YOUTUBE_PORT)
|
||||
YOUTUBE['API'] = 'youtube.com/iframe_api'
|
||||
YOUTUBE['TEST_URL'] = "127.0.0.1:{0}/test_youtube/".format(YOUTUBE_PORT)
|
||||
YOUTUBE['TEXT_API']['url'] = "127.0.0.1:{0}/test_transcripts_youtube/".format(YOUTUBE_PORT)
|
||||
|
||||
@@ -425,9 +425,23 @@ CELERY_QUEUES = {
|
||||
|
||||
############################## Video ##########################################
|
||||
|
||||
# URL to test YouTube availability
|
||||
YOUTUBE_TEST_URL = 'https://gdata.youtube.com/feeds/api/videos/'
|
||||
YOUTUBE = {
|
||||
# YouTube JavaScript API
|
||||
'API': 'www.youtube.com/iframe_api',
|
||||
|
||||
# URL to test YouTube availability
|
||||
'TEST_URL': 'gdata.youtube.com/feeds/api/videos/',
|
||||
|
||||
# Current youtube api for requesting transcripts.
|
||||
# For example: http://video.google.com/timedtext?lang=en&v=j_jEn79vS3g.
|
||||
'TEXT_API': {
|
||||
'url': 'video.google.com/timedtext',
|
||||
'params': {
|
||||
'lang': 'en',
|
||||
'v': 'set_youtube_id_of_11_symbols_here',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
############################ APPS #####################################
|
||||
|
||||
@@ -529,14 +543,6 @@ PASSWORD_DICTIONARY = []
|
||||
TRACKING_IGNORE_URL_PATTERNS = [r'^/event', r'^/login', r'^/heartbeat']
|
||||
TRACKING_ENABLED = True
|
||||
|
||||
# Current youtube api for requesting transcripts.
|
||||
# for example: http://video.google.com/timedtext?lang=en&v=j_jEn79vS3g.
|
||||
YOUTUBE_API = {
|
||||
'url': "http://video.google.com/timedtext",
|
||||
'params': {'lang': 'en', 'v': 'set_youtube_id_of_11_symbols_here'}
|
||||
}
|
||||
|
||||
|
||||
##### ACCOUNT LOCKOUT DEFAULT PARAMETERS #####
|
||||
MAX_FAILED_LOGIN_ATTEMPTS_ALLOWED = 5
|
||||
MAX_FAILED_LOGIN_ATTEMPTS_LOCKOUT_PERIOD_SECS = 15 * 60
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
data-transcript-available-translations-url="/transcript/available_translations"
|
||||
data-autoplay="False"
|
||||
data-yt-test-timeout="1500"
|
||||
data-yt-test-url="https://gdata.youtube.com/feeds/api/videos/"
|
||||
data-yt-api-url="www.youtube.com/iframe_api"
|
||||
data-yt-test-url="gdata.youtube.com/feeds/api/videos/"
|
||||
data-autohide-html5="True"
|
||||
>
|
||||
<div class="focus_grabber first"></div>
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
data-ogg-source="xmodule/include/fixtures/test.ogv"
|
||||
data-autoplay="False"
|
||||
data-yt-test-timeout="1500"
|
||||
data-yt-test-url="https://gdata.youtube.com/feeds/api/videos/"
|
||||
data-yt-api-url="www.youtube.com/iframe_api"
|
||||
data-yt-test-url="gdata.youtube.com/feeds/api/videos/"
|
||||
data-autohide-html5="True"
|
||||
>
|
||||
<div class="focus_grabber first"></div>
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
data-ogg-source="xmodule/include/fixtures/test.ogv"
|
||||
data-autoplay="False"
|
||||
data-yt-test-timeout="1500"
|
||||
data-yt-test-url="https://gdata.youtube.com/feeds/api/videos/"
|
||||
data-yt-api-url="www.youtube.com/iframe_api"
|
||||
data-yt-test-url="gdata.youtube.com/feeds/api/videos/"
|
||||
data-autohide-html5="True"
|
||||
>
|
||||
<div class="focus_grabber first"></div>
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
data-transcript-available-translations-url="/transcript/available_translations"
|
||||
data-autoplay="False"
|
||||
data-yt-test-timeout="1500"
|
||||
data-yt-test-url="https://gdata.youtube.com/feeds/api/videos/"
|
||||
data-yt-api-url="www.youtube.com/iframe_api"
|
||||
data-yt-test-url="gdata.youtube.com/feeds/api/videos/"
|
||||
data-autohide-html5="True"
|
||||
>
|
||||
<div class="focus_grabber first"></div>
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
data-transcript-available-translations-url="/transcript/available_translations"
|
||||
data-autoplay="False"
|
||||
data-yt-test-timeout="1500"
|
||||
data-yt-test-url="https://gdata.youtube.com/feeds/api/videos/"
|
||||
data-yt-api-url="www.youtube.com/iframe_api"
|
||||
data-yt-test-url="gdata.youtube.com/feeds/api/videos/"
|
||||
data-autohide-html5="True"
|
||||
>
|
||||
<div class="focus_grabber first"></div>
|
||||
|
||||
@@ -156,7 +156,7 @@ function (VideoPlayer, VideoStorage) {
|
||||
_reportToServer(state, state.youtubeApiAvailable);
|
||||
}, state.config.ytTestTimeout);
|
||||
|
||||
$.getScript(document.location.protocol + '//www.youtube.com/iframe_api');
|
||||
$.getScript(document.location.protocol + '//' + state.config.ytApiUrl);
|
||||
}
|
||||
|
||||
function _reportToServer(state, youtubeIsAvailable) {
|
||||
@@ -704,7 +704,7 @@ function (VideoPlayer, VideoStorage) {
|
||||
}
|
||||
successHandler = ($.isFunction(callback)) ? callback : null;
|
||||
xhr = $.ajax({
|
||||
url: this.config.ytTestUrl + url + '?v=2&alt=jsonc',
|
||||
url: document.location.protocol + '//' + this.config.ytTestUrl + url + '?v=2&alt=jsonc',
|
||||
dataType: 'jsonp',
|
||||
timeout: this.config.ytTestTimeout,
|
||||
success: successHandler
|
||||
|
||||
@@ -97,9 +97,9 @@ def get_transcripts_from_youtube(youtube_id, settings, i18n):
|
||||
|
||||
utf8_parser = etree.XMLParser(encoding='utf-8')
|
||||
|
||||
youtube_api = copy.deepcopy(settings.YOUTUBE_API)
|
||||
youtube_api['params']['v'] = youtube_id
|
||||
data = requests.get(youtube_api['url'], params=youtube_api['params'])
|
||||
youtube_text_api = copy.deepcopy(settings.YOUTUBE['TEXT_API'])
|
||||
youtube_text_api['params']['v'] = youtube_id
|
||||
data = requests.get('http://' + youtube_text_api['url'], params=youtube_text_api['params'])
|
||||
|
||||
if data.status_code != 200 or not data.text:
|
||||
msg = _("Can't receive transcripts from Youtube for {youtube_id}. Status code: {status_code}.").format(
|
||||
@@ -522,4 +522,3 @@ class Transcript(object):
|
||||
return StaticContent.compute_location(
|
||||
location.org, location.course, filename
|
||||
)
|
||||
|
||||
|
||||
@@ -325,7 +325,8 @@ class VideoModule(VideoFields, XModule):
|
||||
# TODO: Later on the value 1500 should be taken from some global
|
||||
# configuration setting field.
|
||||
'yt_test_timeout': 1500,
|
||||
'yt_test_url': settings.YOUTUBE_TEST_URL,
|
||||
'yt_api_url': settings.YOUTUBE['API'],
|
||||
'yt_test_url': settings.YOUTUBE['TEST_URL'],
|
||||
'transcript_download_format': transcript_download_format,
|
||||
'transcript_download_formats_list': self.descriptor.fields['transcript_download_format'].values,
|
||||
'transcript_language': transcript_language,
|
||||
|
||||
@@ -39,7 +39,8 @@ class TestVideoYouTube(TestVideo):
|
||||
'track': None,
|
||||
'youtube_streams': create_youtube_string(self.item_descriptor),
|
||||
'yt_test_timeout': 1500,
|
||||
'yt_test_url': 'https://gdata.youtube.com/feeds/api/videos/',
|
||||
'yt_api_url': 'www.youtube.com/iframe_api',
|
||||
'yt_test_url': 'gdata.youtube.com/feeds/api/videos/',
|
||||
'transcript_download_format': 'srt',
|
||||
'transcript_download_formats_list': [{'display_name': 'SubRip (.srt) file', 'value': 'srt'}, {'display_name': 'Text (.txt) file', 'value': 'txt'}],
|
||||
'transcript_language': u'en',
|
||||
@@ -104,7 +105,8 @@ class TestVideoNonYouTube(TestVideo):
|
||||
'youtube_streams': '1.00:OEoXaMPEzfM',
|
||||
'autoplay': settings.FEATURES.get('AUTOPLAY_VIDEOS', True),
|
||||
'yt_test_timeout': 1500,
|
||||
'yt_test_url': 'https://gdata.youtube.com/feeds/api/videos/',
|
||||
'yt_api_url': 'www.youtube.com/iframe_api',
|
||||
'yt_test_url': 'gdata.youtube.com/feeds/api/videos/',
|
||||
'transcript_download_format': 'srt',
|
||||
'transcript_download_formats_list': [{'display_name': 'SubRip (.srt) file', 'value': 'srt'}, {'display_name': 'Text (.txt) file', 'value': 'txt'}],
|
||||
'transcript_language': u'en',
|
||||
@@ -206,7 +208,8 @@ class TestGetHtmlMethod(BaseTestXmodule):
|
||||
'youtube_streams': '1.00:OEoXaMPEzfM',
|
||||
'autoplay': settings.FEATURES.get('AUTOPLAY_VIDEOS', True),
|
||||
'yt_test_timeout': 1500,
|
||||
'yt_test_url': 'https://gdata.youtube.com/feeds/api/videos/',
|
||||
'yt_api_url': 'www.youtube.com/iframe_api',
|
||||
'yt_test_url': 'gdata.youtube.com/feeds/api/videos/',
|
||||
'transcript_download_formats_list': [{'display_name': 'SubRip (.srt) file', 'value': 'srt'}, {'display_name': 'Text (.txt) file', 'value': 'txt'}],
|
||||
}
|
||||
|
||||
@@ -323,7 +326,8 @@ class TestGetHtmlMethod(BaseTestXmodule):
|
||||
'youtube_streams': '1.00:OEoXaMPEzfM',
|
||||
'autoplay': settings.FEATURES.get('AUTOPLAY_VIDEOS', True),
|
||||
'yt_test_timeout': 1500,
|
||||
'yt_test_url': 'https://gdata.youtube.com/feeds/api/videos/',
|
||||
'yt_api_url': 'www.youtube.com/iframe_api',
|
||||
'yt_test_url': 'gdata.youtube.com/feeds/api/videos/',
|
||||
'transcript_download_format': 'srt',
|
||||
'transcript_download_formats_list': [{'display_name': 'SubRip (.srt) file', 'value': 'srt'}, {'display_name': 'Text (.txt) file', 'value': 'txt'}],
|
||||
'transcript_language': u'en',
|
||||
|
||||
@@ -176,4 +176,6 @@ XQUEUE_INTERFACE = {
|
||||
}
|
||||
|
||||
# Point the URL used to test YouTube availability to our stub YouTube server
|
||||
YOUTUBE_TEST_URL = "http://127.0.0.1:{0}/test_youtube/".format(YOUTUBE_PORT)
|
||||
YOUTUBE['API'] = 'youtube.com/iframe_api'
|
||||
YOUTUBE['TEST_URL'] = "127.0.0.1:{0}/test_youtube/".format(YOUTUBE_PORT)
|
||||
YOUTUBE['TEXT_API']['url'] = "127.0.0.1:{0}/test_transcripts_youtube/".format(YOUTUBE_PORT)
|
||||
|
||||
@@ -1066,9 +1066,23 @@ BULK_EMAIL_RETRY_DELAY_BETWEEN_SENDS = 0.02
|
||||
|
||||
############################## Video ##########################################
|
||||
|
||||
# URL to test YouTube availability
|
||||
YOUTUBE_TEST_URL = 'https://gdata.youtube.com/feeds/api/videos/'
|
||||
YOUTUBE = {
|
||||
# YouTube JavaScript API
|
||||
'API': 'www.youtube.com/iframe_api',
|
||||
|
||||
# URL to test YouTube availability
|
||||
'TEST_URL': 'gdata.youtube.com/feeds/api/videos/',
|
||||
|
||||
# Current youtube api for requesting transcripts.
|
||||
# For example: http://video.google.com/timedtext?lang=en&v=j_jEn79vS3g.
|
||||
'TEXT_API': {
|
||||
'url': 'video.google.com/timedtext',
|
||||
'params': {
|
||||
'lang': 'en',
|
||||
'v': 'set_youtube_id_of_11_symbols_here',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
################################### APPS ######################################
|
||||
INSTALLED_APPS = (
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
data-transcript-languages='${transcript_languages}'
|
||||
data-autoplay="${autoplay}"
|
||||
data-yt-test-timeout="${yt_test_timeout}"
|
||||
data-yt-api-url="${yt_api_url}"
|
||||
data-yt-test-url="${yt_test_url}"
|
||||
data-transcript-translation-url="${transcript_translation_url}"
|
||||
data-transcript-available-translations-url="${transcript_available_translations_url}"
|
||||
|
||||
Reference in New Issue
Block a user