<commit_before>
function embedYoutubeVideo(id, _username, _podcast_url, _episode_url) {

    var params = { allowScriptAccess: "always" };
    var atts = { id: "ytplayer" };

    // store global variables for onytplayerStateChange
    username = _username
    podcast_url = _podcast_url
    episode_url = _episode_url

    swfobject.embedSWF("http://www.youtube.com/v/" + id + "?enablejsapi=1&playerapiid=ytplayer",
                       "ytapiplayer", "425", "356", "8", null, null, params, atts);
}


function onYouTubePlayerReady(playerId) {
    player = document.getElementById("ytplayer");
    player.addEventListener("onStateChange", "onytplayerStateChange");
}

function onytplayerStateChange(newState) {

    if (newState == 1)
    {
        var str = JSON.stringify([{"podcast": podcast_url, "episode": episode_url, "action": "play"}])
        $.post('/api/1/episodes/' + username + '.json', str);
    }
}
<commit_msg>send only one play event per page load for youtube videos<commit_after>
function embedYoutubeVideo(id, _username, _podcast_url, _episode_url) {

    var params = { allowScriptAccess: "always" };
    var atts = { id: "ytplayer" };

    // store global variables for onytplayerStateChange
    username = _username;
    podcast_url = _podcast_url;
    episode_url = _episode_url;
    already_played = false;

    swfobject.embedSWF("http://www.youtube.com/v/" + id + "?enablejsapi=1&playerapiid=ytplayer",
                       "ytapiplayer", "425", "356", "8", null, null, params, atts);
}


function onYouTubePlayerReady(playerId) {
    player = document.getElementById("ytplayer");
    player.addEventListener("onStateChange", "onytplayerStateChange");
}

function onytplayerStateChange(newState) {

    if ((newState == 1) && !already_played)
    {
        var str = JSON.stringify([{"podcast": podcast_url, "episode": episode_url, "action": "play"}])
        $.post('/api/1/episodes/' + username + '.json', str);
        already_played = true;
    }
}

{'fraction_non_alphanumeric': 0.14120020171457387, 'fraction_numerical': 0.010085728693898134, 'mean_word_length': 3.690307328605201, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3811424', 'n_tokens_mistral': 658, 'n_tokens_neox': 625, 'n_words': 133}