<commit_before># -*- coding: utf-8 -*-
#

# Imports ###########################################################

import logging
import textwrap
import json
from urllib2 import urlopen

from lxml import etree
from StringIO import StringIO

from xblock.core import XBlock
from xblock.fields import Scope, String, Integer, Boolean
from xblock.fragment import Fragment

from .utils import render_template
from .tokens import generate_player_token
from .overlay import OoyalaOverlay

# Globals ###########################################################

log = logging.getLogger(__name__)


# Classes ###########################################################

class OoyalaPlayerBlock(XBlock):
    """
    XBlock providing a video player for videos hosted on Brightcove
    """
    display_name = String(
        display_name="Display Name",
        help="This name appears in the horizontal navigation at the top of the page.",
        scope=Scope.settings,
        default="Ooyala Player"
    )

    content_id = String(
        display_name="Content Id",
        help="Identifier for the Content Id.",
        scope=Scope.content,
        default='Q1eXg5NzpKqUUzBm5WTIb6bXuiWHrRMi'
    )

    transcript_file_id = String(
        display_name="3Play Transcript Id",
        help="Identifier for the 3Play Transcript File",
        scope=Scope.content,
        default=''
    )

    enable_player_token = Boolean(
        display_name="Enable Player Token",
        help='Set to True if a player token is required.',
        scope=Scope.content,
        default=False
    )

    partner_code = String(
        display_name="Partner Code",
        help='Needed to generate a player token.',
        scope=Scope.content,
        default=''
    )

    api_key = String(
        display_name="Api Key",
        help='Needed to generate a player token.',
        scope=Scope.content,
        default=''
    )

    api_secret_key = String(
        display_name="Api SecRet Key",
        help='Needed to generate a player token.',
        scope=Scope.content,
        default=''
    )

    player_width = String(
        display_name="Player Width",
        help='The width of the player in pixels.',
        scope=Scope.content,
        default="740px"
    )

    player_height = String(
        display_name="Player Height",
        help='The height of the player in pixels.',
        scope=Scope.content,
        default="416px"
    )

    expiration_time = Integer(
        display_name="Expiration Time",
        help='Expiration time in seconds. Needed to generate a player token.',
        scope=Scope.content,
        default=600
    )

    fire_progress_event_on_student_view = Boolean(
        display_name="Fire Progress Event on Student View",
        help='Set to True if you would like to get a progress event in the event stream when the user views this xBlock.',
        scope=Scope.content,
        default=True
    )

    xml_config = String(help="XML Configuration", default='<ooyala>\n</ooyala>',
                        scope=Scope.content)

    player_id = '8582dca2417b4e13bed27a4f0647c139'

    @property
    def player_token(self):<commit_msg>default-width: Update default width to 760px<commit_after># -*- coding: utf-8 -*-
#

# Imports ###########################################################

import logging
import textwrap
import json
from urllib2 import urlopen

from lxml import etree
from StringIO import StringIO

from xblock.core import XBlock
from xblock.fields import Scope, String, Integer, Boolean
from xblock.fragment import Fragment

from .utils import render_template
from .tokens import generate_player_token
from .overlay import OoyalaOverlay

# Globals ###########################################################

log = logging.getLogger(__name__)


# Classes ###########################################################

class OoyalaPlayerBlock(XBlock):
    """
    XBlock providing a video player for videos hosted on Brightcove
    """
    display_name = String(
        display_name="Display Name",
        help="This name appears in the horizontal navigation at the top of the page.",
        scope=Scope.settings,
        default="Ooyala Player"
    )

    content_id = String(
        display_name="Content Id",
        help="Identifier for the Content Id.",
        scope=Scope.content,
        default='Q1eXg5NzpKqUUzBm5WTIb6bXuiWHrRMi'
    )

    transcript_file_id = String(
        display_name="3Play Transcript Id",
        help="Identifier for the 3Play Transcript File",
        scope=Scope.content,
        default=''
    )

    enable_player_token = Boolean(
        display_name="Enable Player Token",
        help='Set to True if a player token is required.',
        scope=Scope.content,
        default=False
    )

    partner_code = String(
        display_name="Partner Code",
        help='Needed to generate a player token.',
        scope=Scope.content,
        default=''
    )

    api_key = String(
        display_name="Api Key",
        help='Needed to generate a player token.',
        scope=Scope.content,
        default=''
    )

    api_secret_key = String(
        display_name="Api SecRet Key",
        help='Needed to generate a player token.',
        scope=Scope.content,
        default=''
    )

    player_width = String(
        display_name="Player Width",
        help='The width of the player in pixels.',
        scope=Scope.content,
        default="760px"
    )

    player_height = String(
        display_name="Player Height",
        help='The height of the player in pixels.',
        scope=Scope.content,
        default="427px"
    )

    expiration_time = Integer(
        display_name="Expiration Time",
        help='Expiration time in seconds. Needed to generate a player token.',
        scope=Scope.content,
        default=600
    )

    fire_progress_event_on_student_view = Boolean(
        display_name="Fire Progress Event on Student View",
        help='Set to True if you would like to get a progress event in the event stream when the user views this xBlock.',
        scope=Scope.content,
        default=True
    )

    xml_config = String(help="XML Configuration", default='<ooyala>\n</ooyala>',
                        scope=Scope.content)

    player_id = '8582dca2417b4e13bed27a4f0647c139'

    @property
    def player_token(self):
{'fraction_non_alphanumeric': 0.13671444321940462, 'fraction_numerical': 0.012442904394392818, 'mean_word_length': 2.7955768081291095, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '642763', 'n_tokens_mistral': 1785, 'n_tokens_neox': 1708, 'n_words': 496}