<commit_before><?php
namespace App\Controller\Frontend;

use App\View;
use App\Radio\Frontend\FrontendAbstract;
use App\Entity;
use App\Http\Request;
use App\Http\Response;

class PublicController
{
    public function indexAction(Request $request, Response $response, $station_id = null, $autoplay = false): Response
    {
        $template_vars = ['autoplay' => ($autoplay === 'autoplay')];
        return $this->_getPublicPage($request, $response, 'frontend/public/index', $template_vars);
    }

    public function embedAction(Request $request, Response $response, $station_id = null, $autoplay = false): Response
    {
        $template_vars = ['autoplay' => ($autoplay === 'autoplay')];
        return $this->_getPublicPage($request, $response, 'frontend/public/embed', $template_vars);
    }

    public function embedrequestsAction(Request $request, Response $response): Response
    {
        return $this->_getPublicPage($request, $response, 'frontend/public/embedrequests');
    }

    protected function _getPublicPage(Request $request, Response $response, $template_name, $template_vars = [])
    {
        // Override system-wide iframe refusal
        $response = $response->withoutHeader('X-Frame-Options');

        $station = $request->getStation();

        if (!$station->getEnablePublicPage()) {
            throw new \App\Exception(__('Station not found!'));
        }

        $frontend_adapter = $request->getStationFrontend();

        return $request->getView()->renderToResponse($response, $template_name, $template_vars + [
            'station' => $station,
            'stream_url' => $frontend_adapter->getStreamUrl($station),
        ]);
    }

    public function playlistAction(Request $request, Response $response): Response
    {
        $station = $request->getStation();
        $fa = $request->getStationFrontend();

        $stream_urls = $fa->getStreamUrls($station);

        $format = strtolower($request->getParam('format', 'pls'));

        switch ($format) {
            // M3U Playlist Format
            case "m3u":
                $m3u_file = implode("\n", $stream_urls);
<commit_msg>Fix usage of format route argument (#936)<commit_after><?php
namespace App\Controller\Frontend;

use App\View;
use App\Radio\Frontend\FrontendAbstract;
use App\Entity;
use App\Http\Request;
use App\Http\Response;

class PublicController
{
    public function indexAction(Request $request, Response $response, $station_id = null, $autoplay = false): Response
    {
        $template_vars = ['autoplay' => ($autoplay === 'autoplay')];
        return $this->_getPublicPage($request, $response, 'frontend/public/index', $template_vars);
    }

    public function embedAction(Request $request, Response $response, $station_id = null, $autoplay = false): Response
    {
        $template_vars = ['autoplay' => ($autoplay === 'autoplay')];
        return $this->_getPublicPage($request, $response, 'frontend/public/embed', $template_vars);
    }

    public function embedrequestsAction(Request $request, Response $response): Response
    {
        return $this->_getPublicPage($request, $response, 'frontend/public/embedrequests');
    }

    protected function _getPublicPage(Request $request, Response $response, $template_name, $template_vars = [])
    {
        // Override system-wide iframe refusal
        $response = $response->withoutHeader('X-Frame-Options');

        $station = $request->getStation();

        if (!$station->getEnablePublicPage()) {
            throw new \App\Exception(__('Station not found!'));
        }

        $frontend_adapter = $request->getStationFrontend();

        return $request->getView()->renderToResponse($response, $template_name, $template_vars + [
            'station' => $station,
            'stream_url' => $frontend_adapter->getStreamUrl($station),
        ]);
    }

    public function playlistAction(Request $request, Response $response, $station_id, $format = 'pls'): Response
    {
        $station = $request->getStation();
        $fa = $request->getStationFrontend();

        $stream_urls = $fa->getStreamUrls($station);

        $format = strtolower($format);

        switch ($format) {
            // M3U Playlist Format
            case "m3u":
                $m3u_file = implode("\n", $stream_urls);

{'fraction_non_alphanumeric': 0.14215914378780828, 'fraction_numerical': 0.0020939972080037225, 'mean_word_length': 3.3033033033033035, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 38, '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': '5619154', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1209, 'n_words': 258}