<commit_before><?php
namespace AzuraCast\Console\Command;

use AzuraCast\Radio\Adapters;
use AzuraCast\Radio\Backend\Liquidsoap;
use Doctrine\ORM\EntityManager;
use Entity;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class StreamerAuth extends \App\Console\Command\CommandAbstract
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this->setName('azuracast:internal:auth')
            ->setDescription('Authorize a streamer to connect as a source for the radio service.')
            ->addArgument(
                'station_id',
                InputArgument::REQUIRED,
                'The ID of the station.'
            )->addOption(
                'dj_user',
                null,
                InputOption::VALUE_REQUIRED,
                'The streamer username (or "shoutcast" for SC legacy auth).'
            )->addOption(
                'dj_pass',
                null,
                InputOption::VALUE_REQUIRED,
                'The streamer password (or "<PASSWORD>:password" for SC legacy auth).'
            );
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $station_id = (int)$input->getArgument('station_id');

        /** @var EntityManager $em */
        $em = $this->di[EntityManager::class];

        $station = $em->getRepository(Entity\Station::class)->find($station_id);

        if (!($station instanceof Entity\Station) || !$station->getEnableStreamers()) {
            $output->write('false');
            return false;
        }

        $user = $input->getOption('dj_user');
        $pass = $input->getOption('dj_pass');

        /** @var Adapters $adapters */
        $adapters = $this->di[Adapters::class];

        $adapter = $adapters->getBackendAdapter($station);

        if ($adapter instanceof Liquidsoap) {
            $response = $adapter->authenticateStreamer($user, $pass);
            $output->write($response);
            return ($response === 'true');
        }

        $output->write('false');
        return false;
    }
}<commit_msg>#444 -- Fix inconsistency in CLI/URL opts<commit_after><?php
namespace AzuraCast\Console\Command;

use AzuraCast\Radio\Adapters;
use AzuraCast\Radio\Backend\Liquidsoap;
use Doctrine\ORM\EntityManager;
use Entity;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class StreamerAuth extends \App\Console\Command\CommandAbstract
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this->setName('azuracast:internal:auth')
            ->setDescription('Authorize a streamer to connect as a source for the radio service.')
            ->addArgument(
                'station_id',
                InputArgument::REQUIRED,
                'The ID of the station.'
            )->addOption(
                'dj_user',
                null,
                InputOption::VALUE_REQUIRED,
                'The streamer username (or "shoutcast" for SC legacy auth).'
            )->addOption(
                'dj_password',
                null,
                InputOption::VALUE_REQUIRED,
                'The streamer password (or "<PASSWORD>:password" for SC legacy auth).'
            );
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $station_id = (int)$input->getArgument('station_id');

        /** @var EntityManager $em */
        $em = $this->di[EntityManager::class];

        $station = $em->getRepository(Entity\Station::class)->find($station_id);

        if (!($station instanceof Entity\Station) || !$station->getEnableStreamers()) {
            $output->write('false');
            return false;
        }

        $user = $input->getOption('dj_user');
        $pass = $input->getOption('dj_password');

        /** @var Adapters $adapters */
        $adapters = $this->di[Adapters::class];

        $adapter = $adapters->getBackendAdapter($station);

        if ($adapter instanceof Liquidsoap) {
            $response = $adapter->authenticateStreamer($user, $pass);
            $output->write($response);
            return ($response === 'true');
        }

        $output->write('false');
        return false;
    }
}
{'fraction_non_alphanumeric': 0.13202614379084968, 'fraction_numerical': 0.00065359477124183, 'mean_word_length': 2.251416430594901, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 41, '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': '6339366', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1230, 'n_words': 251}