controllers/DownloadController.php
private function getDownloadResponse(Request $request, Response $response)
    {
        try {
            $videoUrls = $this->video->getUrl();
        } catch (EmptyUrlException $e) {
            /*
            If this happens it is probably a playlist
            so it will either be handled by getStream() or throw an exception anyway.
             */
            $videoUrls = [];
        }
        if (count($videoUrls) > 1) {
            return $this->getRemuxStream($request, $response);
        } elseif ($this->config->stream && (isset($this->video->entries) || $request->getQueryParam('stream'))) {
            return $this->getStream($request, $response);
        } else {
            if (empty($videoUrls[0])) {
                throw new Exception(_("Can't find URL of video."));
            }

            return $response->withRedirect($videoUrls[0]);
        }
    }
private function getDownloadResponse(Request $request, Response $response)
    {
        try {
            $videoUrls = $this->video->getUrl();
        } catch (EmptyUrlException $e) {
            /*
            If this happens it is probably a playlist
            so it will either be handled by getStream() or throw an exception anyway.
             */
            $videoUrls = [];
        }
        if (count($videoUrls) > 1) {
            return $this->getRemuxStream($request, $response);
        } elseif ($this->config->stream && (isset($this->video->entries) || $request->getQueryParam('stream'))) {
            return $this->getStream($request, $response);
        } else {
            if (empty($videoUrls[0])) {
                throw new Exception(_("Can't find URL of video."));
            }

            return $response->withRedirect($videoUrls[0]);
        }
    }
private function getDownloadResponse ( Request $ request , Response $ response ) { try { $ videoUrls = $ this -> video -> getUrl ( ) ; } catch ( EmptyUrlException $ e ) { /*
            If this happens it is probably a playlist
            so it will either be handled by getStream() or throw an exception anyway.
             */ $ videoUrls = [ ] ; } if ( count ( $ videoUrls ) > 1 ) { return $ this -> getRemuxStream ( $ request , $ response ) ; } elseif ( $ this -> config -> stream && ( isset ( $ this -> video -> entries ) || $ request -> getQueryParam ( 'stream' ) ) ) { return $ this -> getStream ( $ request , $ response ) ; } else { if ( empty ( $ videoUrls [ 0 ] ) ) { throw new Exception ( _ ( "Can't find URL of video." ) ) ; } return $ response -> withRedirect ( $ videoUrls [ 0 ] ) ; } }
Get approriate HTTP response to download query.
Depends on whether we want to stream, remux or simply redirect.

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

@return Response HTTP response
Get approriate HTTP response to download query . Depends on whether we want to stream remux or simply redirect .