controllers/DownloadController.php
public function download(Request $request, Response $response)
    {
        $url = $request->getQueryParam('url');

        if (isset($url)) {
            $this->video = new Video($url, $this->getFormat($request), $this->getPassword($request));

            try {
                if ($this->config->convert && $request->getQueryParam('audio')) {
                    // Audio convert.
                    return $this->getAudioResponse($request, $response);
                } elseif ($this->config->convertAdvanced && !is_null($request->getQueryParam('customConvert'))) {
                    // Advance convert.
                    return $this->getConvertedResponse($request, $response);
                }

                // Regular download.
                return $this->getDownloadResponse($request, $response);
            } catch (PasswordException $e) {
                return $response->withRedirect(
                    $this->container->get('router')->pathFor('info').'?'.http_build_query($request->getQueryParams())
                );
            } catch (Exception $e) {
                $response->getBody()->write($e->getMessage());

                return $response->withHeader('Content-Type', 'text/plain')->withStatus(500);
            }
        } else {
            return $response->withRedirect($this->container->get('router')->pathFor('index'));
        }
    }
public function download(Request $request, Response $response)
    {
        $url = $request->getQueryParam('url');

        if (isset($url)) {
            $this->video = new Video($url, $this->getFormat($request), $this->getPassword($request));

            try {
                if ($this->config->convert && $request->getQueryParam('audio')) {
                    // Audio convert.
                    return $this->getAudioResponse($request, $response);
                } elseif ($this->config->convertAdvanced && !is_null($request->getQueryParam('customConvert'))) {
                    // Advance convert.
                    return $this->getConvertedResponse($request, $response);
                }

                // Regular download.
                return $this->getDownloadResponse($request, $response);
            } catch (PasswordException $e) {
                return $response->withRedirect(
                    $this->container->get('router')->pathFor('info').'?'.http_build_query($request->getQueryParams())
                );
            } catch (Exception $e) {
                $response->getBody()->write($e->getMessage());

                return $response->withHeader('Content-Type', 'text/plain')->withStatus(500);
            }
        } else {
            return $response->withRedirect($this->container->get('router')->pathFor('index'));
        }
    }
public function download ( Request $ request , Response $ response ) { $ url = $ request -> getQueryParam ( 'url' ) ; if ( isset ( $ url ) ) { $ this -> video = new Video ( $ url , $ this -> getFormat ( $ request ) , $ this -> getPassword ( $ request ) ) ; try { if ( $ this -> config -> convert && $ request -> getQueryParam ( 'audio' ) ) { // Audio convert. return $ this -> getAudioResponse ( $ request , $ response ) ; } elseif ( $ this -> config -> convertAdvanced && ! is_null ( $ request -> getQueryParam ( 'customConvert' ) ) ) { // Advance convert. return $ this -> getConvertedResponse ( $ request , $ response ) ; } // Regular download. return $ this -> getDownloadResponse ( $ request , $ response ) ; } catch ( PasswordException $ e ) { return $ response -> withRedirect ( $ this -> container -> get ( 'router' ) -> pathFor ( 'info' ) . '?' . http_build_query ( $ request -> getQueryParams ( ) ) ) ; } catch ( Exception $ e ) { $ response -> getBody ( ) -> write ( $ e -> getMessage ( ) ) ; return $ response -> withHeader ( 'Content-Type' , 'text/plain' ) -> withStatus ( 500 ) ; } } else { return $ response -> withRedirect ( $ this -> container -> get ( 'router' ) -> pathFor ( 'index' ) ) ; } }
Redirect to video file.

@param Request  $request  PSR-7 request
@param Response $response PSR-7 response

@return Response HTTP response
Redirect to video file .