<commit_before>/**
 * @see https://developers.google.com/youtube/js_api_reference
 */
function onYouTubePlayerReady(player){
    var YT_PLAYERSTATE_UNSTARTED = -1;
    var setHighestQuality = function(player) {
        // We need to be little bit stubborn about setting playback quality, because:
        // a) half the time between onYouTubePlayerReady call and actual playback
        // the quality can't be changed. And there is no event that would guarantee
        // it to be ready before playback starts. Setting quality during playback
        // won't prevent player to buffer low quality video at the beginning.
        // b) video ads block the settings too.
        // c) changing video may result in video ad (see b).
        var intervalId = window.setInterval(function() {
            var highestQuality = player.getAvailableQualityLevels()[0] || "highres";
            player.setPlaybackQuality(highestQuality);
            if (player.getPlaybackQuality() === highestQuality) {
                window.clearInterval(intervalId);
            }
        }, 100);
    };

    // The onYouTubePlayerReady() is called twice. During first call the 'player'
    // parameter equals to player ID string. On the second call it equals to
    // the player object. Make sure we respond to the second call only.
    if (player && typeof player === "object") {
        setHighestQuality(player);
        player.addEventListener("onStateChange", function(event) {
            if (event === YT_PLAYERSTATE_UNSTARTED) {
                // Player has changed the video (without page reload).<commit_msg>Minor: we made sure that interval will be cleared once player is destroyed<commit_after>/**
 * @see https://developers.google.com/youtube/js_api_reference
 */
function onYouTubePlayerReady(player){
    var YT_PLAYERSTATE_UNSTARTED = -1;
    var setHighestQuality = function(player) {
        // We need to be little bit stubborn about setting playback quality, because:
        // a) half the time between onYouTubePlayerReady call and actual playback
        // the quality can't be changed. And there is no event that would guarantee
        // it to be ready before playback starts. Setting quality during playback
        // won't prevent player to buffer low quality video at the beginning.
        // b) video ads block the settings too.
        // c) changing video may result in video ad (see b).
        var intervalId = window.setInterval(function() {
            try {
                var highestQuality = player.getAvailableQualityLevels()[0] || "highres";
                player.setPlaybackQuality(highestQuality);
                if (player.getPlaybackQuality() === highestQuality) {
                    window.clearInterval(intervalId);
                }
            } catch(e) {
                // Make sure interval isn't lingering after player is destroyed.
                window.clearInterval(intervalId);
            }
        }, 100);
    };

    // The onYouTubePlayerReady() is called twice. During first call the 'player'
    // parameter equals to player ID string. On the second call it equals to
    // the player object. Make sure we respond to the second call only.
    if (player && typeof player === "object") {
        setHighestQuality(player);
        player.addEventListener("onStateChange", function(event) {
            if (event === YT_PLAYERSTATE_UNSTARTED) {
                // Player has changed the video (without page reload).
{'fraction_non_alphanumeric': 0.08614232209737828, 'fraction_numerical': 0.002881014116969173, 'mean_word_length': 2.465069860279441, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3267083', 'n_tokens_mistral': 896, 'n_tokens_neox': 833, 'n_words': 327}