<commit_before><?php

namespace Craft;

/**
 * YouTube Upload Task.
 *
 * Upload video assets to YouTube.
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2015, Itmundi
 * @license   MIT
 *
 * @link      http://github.com/boboldehampsink
 */
class YouTubeService extends BaseApplicationComponent
{
    /**
     * Holds a reference to the plugin class.
     *
     * @var YouTubePlugin
     */
    protected $plugin;

    /**
     * Holds the plugin settings.
     *
     * @var array
     */
    protected $settings;

    /**
     * Holds the OAuth client.
     *
     * @var \Google_Client|null
     */
    protected $client;

    /**
     * Holds the YouTube API.
     *
     * @var \Google_Service_YouTube|null
     */
    protected $youtube;

    /**
     * Holds cached asset locations
     *
     * @var array
     */
    protected $assets = array();

    /**
     * Initialize plugin.
     */
    public function init()
    {
        // Initialize parent
        parent::init();

        // Autoload dependencies
        require_once dirname(__FILE__).'/../vendor/autoload.php';

        // Get plugin
        $this->plugin = craft()->plugins->getPlugin('youtube');

        // Get plugin settings
        $this->settings = $this->plugin->getSettings();
    }

    /**
     * Upload and process the result.
     *
     * @param BaseElementModel $element
     * @param AssetFileModel   $asset
     * @param string           $handle
     *
     * @return bool
     */
    public function process(BaseElementModel $element, AssetFileModel $asset, $handle)
    {
        // Get max power
        craft()->config->maxPowerCaptain();

        // Upload to YouTube
        try {
            $status = $this->assemble($element, $asset);
        } catch (Exception $e) {
            return $e->getMessage();
        }

        // Get current video's
        $content = $element->getContent()->getAttribute($handle);

        // Make sure content's an array
        $content = is_array($content) ? $content : array();

        // Remove this asset's id from the content
        unset($content[array_search($asset->id, $content)]);

        // Add video to (existing) content
        $element->getContent()->$handle = array_merge($content, array($status->id));

        // Save the content without validation
        craft()->content->saveContent($element, false);

        // All went well
        return true;
    }
<commit_msg>We already get max power from the tasks service<commit_after><?php

namespace Craft;

/**
 * YouTube Upload Task.
 *
 * Upload video assets to YouTube.
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2015, Itmundi
 * @license   MIT
 *
 * @link      http://github.com/boboldehampsink
 */
class YouTubeService extends BaseApplicationComponent
{
    /**
     * Holds a reference to the plugin class.
     *
     * @var YouTubePlugin
     */
    protected $plugin;

    /**
     * Holds the plugin settings.
     *
     * @var array
     */
    protected $settings;

    /**
     * Holds the OAuth client.
     *
     * @var \Google_Client|null
     */
    protected $client;

    /**
     * Holds the YouTube API.
     *
     * @var \Google_Service_YouTube|null
     */
    protected $youtube;

    /**
     * Holds cached asset locations
     *
     * @var array
     */
    protected $assets = array();

    /**
     * Initialize plugin.
     */
    public function init()
    {
        // Initialize parent
        parent::init();

        // Autoload dependencies
        require_once dirname(__FILE__).'/../vendor/autoload.php';

        // Get plugin
        $this->plugin = craft()->plugins->getPlugin('youtube');

        // Get plugin settings
        $this->settings = $this->plugin->getSettings();
    }

    /**
     * Upload and process the result.
     *
     * @param BaseElementModel $element
     * @param AssetFileModel   $asset
     * @param string           $handle
     *
     * @return bool
     */
    public function process(BaseElementModel $element, AssetFileModel $asset, $handle)
    {
        // Upload to YouTube
        try {
            $status = $this->assemble($element, $asset);
        } catch (Exception $e) {
            return $e->getMessage();
        }

        // Get current video's
        $content = $element->getContent()->getAttribute($handle);

        // Make sure content's an array
        $content = is_array($content) ? $content : array();

        // Remove this asset's id from the content
        unset($content[array_search($asset->id, $content)]);

        // Add video to (existing) content
        $element->getContent()->$handle = array_merge($content, array($status->id));

        // Save the content without validation
        craft()->content->saveContent($element, false);

        // All went well
        return true;
    }

{'fraction_non_alphanumeric': 0.13031805039239983, 'fraction_numerical': 0.0016522098306484924, 'mean_word_length': 1.9298245614035088, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 43, 'https://': 0, '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': '7219887', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1330, 'n_words': 352}