Need help figuring out issues with my website

Hello guys! i am a amatuer coder and fairly new to website creating and stuff! I currently added another page to my website and inserted a youtube downloader script that functions well until you press download, once you press that it redirects you and gives you a HTTP 500 error and then when i checked what the error was it showed this: Fatal error : Uncaught Exception in /home/vol11_1/epizy.com/epiz_27917024/htdocs/video downloader/src/Http/CurlClient.php:203 Stack trace: #0 /home/vol11_1/epizy.com/epiz_27917024/htdocs/video downloader/src/Http/CurlClient.php(113): YoutubeDownloader\Http\CurlClient->getHttpResponseFromCurl(Resource id #52, Array) #1 /home/vol11_1/epizy.com/epiz_27917024/htdocs/video downloader/src/Http/CurlClient.php(76): YoutubeDownloader\Http\CurlClient->sendRequest(Object(YoutubeDownloader\Http\Request)) #2 /home/vol11_1/epizy.com/epiz_27917024/htdocs/video downloader/src/Application/ControllerAbstract.php(105): YoutubeDownloader\Http\CurlClient->send(Object(YoutubeDownloader\Http\Request), Array) #3 /home/vol11_1/epizy.com/epiz_27917024/htdocs/video downloader/src/Application/ResultController.php(174): YoutubeDownloader\Application\ControllerAbstract->getSize(‘’, Object(YoutubeDownloader\Config), Object(YoutubeDownloader\Toolkit)) #4 /home/vol11_1/epizy.com/epiz_27917024/htdocs/video downloader/src/Application/App.php(83): YoutubeDow in /home/vol11_1/epizy.com/epiz_27917024/htdocs/video downloader/src/Http/CurlClient.php on line 206
and when i removed that line of code it kept showing more faulty code in that same script so can someone please help me fix this error? thanks!! :smiley:

First of all, we would have to see your script. We can’t tell what’s going on because we need to see the code that’s causing the problem.

Second of all, downloading Youtube videos is illegal, so I don’t think Infinityfree will take to your website nicely (suspension).

2 Likes
  1. even if the downloader is just for personal use?
  2. here is the script for the Curl client file:
<?php

namespace YoutubeDownloader\Http;

                    // use Psr\Http\Client\ClientInterface;
                    use Psr\Http\Message\RequestInterface;
                    use Psr\Http\Message\ResponseInterface;
                    use Psr\Http\Message\UriInterface;

                    // use Psr\Http\Message\RequestFactoryInterface;

                    /**
                     * A curl http client instance
                     */
                    class CurlClient implements Client /* , ClientInterface, RequestFactoryInterface */
                    {
                        private $curlOptions = [];

                        /**
                         * Factory for a new fullfeatured Request
                         *
                         * <@>param string      $method  HTTP method
                         * <@>param string      $target  The target url for this request
                         * <@>param array       $headers Request headers
                         * <@>param string|null $body    Request body
                         * <@>param string      $version Protocol version
                         *
                         * <@>return Request
                         */
                        public function createFullRequest($method, $target, array $headers = [], $body = null, $version = '1.1')
                        {
                            $request = $this->createRequest($method, $target)
                                ->withProtocolVersion($version)
                                ->withBody(new StringStream($body));

                            foreach ($headers as $name => $value) {
                                $request = $request->withAddedHeader($name, $value);
                            }

                            return $request;
                        }

                        /**
                         * Sends a Request and returns a Response
                         *
                         * $options can be used to set client specific data per request, like curl options
                         *
                         * <@>param Request $request,
                         * <@>param array   $options  client specific options for a client instance
                         *
                         * <@>return Response
                         */
                        public function send(RequestInterface $request, array $options = [])
                        {
                            // Save curl options in class property, because PSR-18 sendRequest() has no 2nd argument
                            $this->curlOptions = $this->createCurlOptions($request, $options);

                            return $this->sendRequest($request);
                        }

                        /**
                         * Create a new request.
                         *
                         * <@>TODO Make this public to implement PSR-17 RequestFactoryInterface
                         *
                         * <@>param string              $method the HTTP method associated with the request
                         * <@>param UriInterface|string $uri    the URI associated with the request
                         *
                         * <@>return Psr\Http\Message\RequestInterface
                         */
                        private function createRequest($method, $uri)
                        {
                            if ($uri instanceof UriInterface) {
                                $uri = $uri->__toString();
                            }

                            return new Request($method, $uri);
                        }

                        /**
                         * Sends a PSR-7 request and returns a PSR-7 response.
                         *
                         * <@>TODO make this public to implement PSR-18 HTTP Client
                         *
                         * <@>param RequestInterface $request
                         *
                         * <@>throws \Psr\Http\Client\ClientExceptionInterface if an error happens while processing the request
                         *
                         * <@>return ResponseInterface
                         */
                        private function sendRequest(RequestInterface $request)
                        {
                            $curl_handler = curl_init();

                            $http_response = $this->getHttpResponseFromCurl($curl_handler, $this->curlOptions);

                            curl_close($curl_handler);

                            return $this->createResponseFromHttp($http_response);
                        }

                        /**
                         * create an array with curl options
                         *
                         * <@>param Request $request,
                         * <@>param array   $options  client specific options for a client instance
                         *
                         * <@>return array the curl options
                         */
                        private function createCurlOptions(Request $request, array $options = [])
                        {
                            $default_options = [
                                CURLOPT_URL => $request->getRequestTarget(),
                                CURLOPT_CUSTOMREQUEST => $request->getMethod(),
                                CURLOPT_HEADER => true,
                                CURLOPT_RETURNTRANSFER => true,
                                CURLOPT_CONNECTTIMEOUT => 3,
                                CURLOPT_FOLLOWLOCATION => true,
                            ];

                            switch ($request->getProtocolVersion()) {
                                case '1.1':
                                    $default_options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;

                                    break;

                                case '2.0':
                                    $default_options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;

                                    break;

                                default:
                                    $default_options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;

                                    break;
                            }

                            foreach ($request->getHeaders() as $name => $values) {
                                foreach ($values as $value) {
                                    $default_options[CURLOPT_HTTPHEADER][] = $name . ': ' . $value;
                                }
                            }

                            $curl_options = (isset($options['curl'])) ? $options['curl'] : [];

                            if (! is_array($curl_options)) {
                                // Curls options must be an array
                                $curl_options = [];
                            }

                            return array_replace($default_options, $curl_options);
                        }

                        /**
                         * get the raw http response from a curl handler
                         *
                         * <@>param resource $curl_handler The curl handler
                         * <@>param array    $options      the curl options
                         *
                         * <@>return string
                         */
                        private function getHttpResponseFromCurl($curl_handler, array $curl_options = [])
                        {
                            $curl_returns_response = ((bool) $curl_options[CURLOPT_RETURNTRANSFER] === true);

                            curl_setopt_array($curl_handler, $curl_options);

                            // enable output buffer if needed
                            if (! $curl_returns_response) {
                                ob_start();
                            }

                            $curl_response = curl_exec($curl_handler);

                            // enable output buffer if needed
                            if (! $curl_returns_response) {
                                $body = ob_get_contents();
                                ob_end_clean();
                            } else {
                                $body = $curl_response;
                            }

                            // Handle errors
                            if ($curl_response === false) {
                                $e = new \Exception(curl_error($curl_handler));
                                curl_close($curl_handler);

                                throw new \RuntimeException('A curl error occurs while execute the curl handler.', $e->getCode(), $e);
                            }

                            return $body;
                        }

                        /**
                         * create an Response from a raw http response
                         *
                         * <@>param string $http_response The http response
                         *
                         * <@>return Response
                         */
                        private function createResponseFromHttp($http_response)
                        {
                            $response_parts = explode("\r\n\r\n", $http_response);
                            $raw_headers = explode("\r\n", $response_parts[0]);

                            $status_parts = $this->parseStatusCodeLine(array_shift($raw_headers));

                            $response = new Response(
                                $status_parts['code'],
                                [],
                                str_replace($response_parts[0] . "\r\n\r\n", '', $http_response),
                                $status_parts['protocol'],
                                $status_parts['phrase']
                            );

                            foreach ($raw_headers as $raw_header) {
                                $header = explode(': ', $raw_header);
                                $response = $response->withAddedHeader($header[0], $header[1]);
                            }

                            return $response;
                        }

                        /**
                         * Parse the status code line
                         *
                         * Examples:
                         * 'HTTP/1.1 200 OK'
                         * 'HTTP/1.1 404 Not Found'
                         *
                         * <@>param string $line
                         *
                         * <@>return string[] An array with code, phrase and protocol keys
                         */
                        private function parseStatusCodeLine($line)
                        {
                            $raw_status_parts = explode(' ', $line);

                            $protocol_version_parts = explode('/', array_shift($raw_status_parts));

                            return [
                                'code' => array_shift($raw_status_parts),
                                'phrase' => implode(' ', $raw_status_parts),
                                'protocol' => $protocol_version_parts[1],
                            ];
                        }
                    }

and also here is the link to the main file that i used for it: GitHub - jeckman/YouTube-Downloader: PHP script for downloading videos from youtube; also parsing youtube feed into RSS enclosures for podcatchers

Ah, ok. I can’t really read it, but to answer your first question - yes, it is illegal.

Even if it’s for personal use, pretty much anyone can come and download videos using your program. Also, it is still illegal to use for personal use in a way like that, and I don’t think InfinityFree wants to get sued.

oh ok! should i delete it or what? also may i ask why there are thousands if not millions of youtube video downloaders out there? and also according to google, youtube has shown no desire to penalize users for downloading videos. so why would they notice me imbetween the others?

True, true.

But sometimes, being a good person is doing what is right, even amidst the wrong.

Maybe not delete it, but I would recommend taking it off of InfinityFree if it’s hosted on there.

You could always use it to gain knowledge on how it works.

would it work out if i basically make it private? like remove it from the main website and keep it for personal use?

I still don’t recommend using it at all, but rather use it for educational purposes (AKA, studying it and not using it).

I used to download music from youtube that way, and I deleted all of them because I realized that it was wrong.

Just don’t use it in general. I know it may be tempting, but it’s best to be safe rather than be sorry (jail/fines, or both!).

alright then! imma just keep it around to mess around with it and stuff but i did do some more research on youtubes course of action for this type of thing and interestingly enough youtube doesnt really care about the youtube video downloader websites unless they are used to download copyrighted videos without permission then they would care

Ok, but be cautious!

Don’t say I didn’t warn you :wink:

alright man! thanks anyways! have a great rest of your day then

Embed is allowed because you did not copy or modify anyone’s video
nor is it stored on your site…rather, it is executed on youtube via embed code (content through their streaming service)

If a video creator leaves the embed functionality enabled for a video, that person has agreed to allow other people to share that video on other mediums (including websites) without YouTube’s prior written permission according to YouTube’s Terms of Service.

If a video creator, on the other hand, disables embed functionality for a video, that person does not grant public use of a video, and per YouTube’s Terms of Service, anyone wishing to share that video on any medium would require prior written permission from YouTube.

But you are not allowed to disassemble or create new versions of someone’s work
and that’s exactly what youtube downloader does
YT terms of this license prohibit downloading content for storage, distribution, or offline viewing.

And what you want to do also violate InfinityFree TOS

5 Likes

The last part was what I was trying to say :smiley:

1 Like

well, i am going to delete it later on today because my PC is currently being kinda slow and my wifi is also pretty slow right now so yea

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.