Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Youtube VideoInfo script no longer working #421

Closed
sunil11475 opened this issue Oct 15, 2019 · 9 comments
Closed

Youtube VideoInfo script no longer working #421

sunil11475 opened this issue Oct 15, 2019 · 9 comments

Comments

@sunil11475
Copy link

sunil11475 commented Oct 15, 2019

From Last month YouTube get VideoInfo no longer working. I have tested different video info code and curl no getting any information.

Error 01
No format stream map found - was the video id correct?

Error 02
Fatal error: Uncaught Error: Call to a member function getUrl() on null in /MYHOSTPATH/httpd.www/app/youtube/src/Application/ControllerAbstract.php:252 Stack trace: #0 /MYHOSTPATH/httpd.www/app/youtube/src/Application/ResultController.php(101): YoutubeDownloader\Application\ControllerAbstract->getDownloadUrlByFormat(Object(YoutubeDownloader\Provider\Youtube\VideoInfo), 'ipad') #1 /MYHOSTPATH/httpd.www/app/youtube/src/Application/App.php(83): YoutubeDownloader\Application\ResultController->execute() #2 /MYHOSTPATH/httpd.www/app/youtube/getvideo.php(23): YoutubeDownloader\Application\App->runWithRoute('results') #3 {main} thrown in /MYHOSTPATH/httpd.www/app/youtube/src/Application/ControllerAbstract.php on line 252

I have changed the server and it worked but after 2 days it stop again. If you think proxy can solve this issue then please check the below error -

Error 03
Fatal error: Uncaught Error: Call to a member function getType() on null in /MYHOSTPATH/httpd.www/app/youtube/src/Application/ResultController.php:91 Stack trace: #0 /MYHOSTPATH/httpd.www/app/youtube/src/Application/App.php(83): YoutubeDownloader\Application\ResultController->execute() #1 /MYHOSTPATH/httpd.www/app/youtube/getvideo.php(23): YoutubeDownloader\Application\App->runWithRoute('results') #2 {main} thrown in /MYHOSTPATH/httpd.www/app/youtube/src/Application/ResultController.php on line 91

Please let me know if you have any solution.

@sunil11475
Copy link
Author

Is anybody have idea how to fix this issue?

@zannix
Copy link

zannix commented Oct 18, 2019

Figured it out.

  1. In Provider.php script, method provide() switch back to using

$video_info_url = 'https://www.youtube.com/get_video_info?&video_id=' . $input . '&asv=3&el=detailpage&hl=en_US'

instead of

$video_info_url = 'https://www.youtube.com/get_video_info?&video_id=' . $input . '&asv=3&hl=en_US';

  1. Seems like video_info no longer contains video_id, which is why we need to pass it in manually to createFromStringWithOptions() method of VideoInfo.php like this:
public static function createFromStringWithOptions($string, array $options, $video_id)
    {
        $default = [
            'decipher_signature' => false,
        ];

        foreach ($default as $key => $value) {
            if (! array_key_exists($key, $options)) {
                $options[$key] = $value;
            }
        }

        parse_str($string, $video_info);

        $video_info["video_id"] = $video_id;

        return new self($video_info, $options);
    }

  1. Now, back in Provider.php script in method provide() you would call the method VideoInfo::createFromStringWithOptions like this:

$video_info = VideoInfo::createFromStringWithOptions( $response->getBodyAsString(), $this->options, $input );

The $input variable should contain our youtube ID if we are passing it in when calling the script.

@jeckman
Copy link
Owner

jeckman commented Oct 18, 2019

If this truly works, could you make a pull request so we can merge the changes in?

@zannix
Copy link

zannix commented Oct 18, 2019

I've never done a pull request before, but I'll do my best :)

@Emmanuelasika
Copy link

If this truly works, could you make a pull request so we can merge the changes in?

Hello, the script stopped workig.. keeps saying "Error in video ID: HTTP is not supported.
"

@zannix
Copy link

zannix commented Oct 19, 2019

Created a PR, #422

@jeckman
Copy link
Owner

jeckman commented Oct 19, 2019

If this truly works, could you make a pull request so we can merge the changes in?

Hello, the script stopped workig.. keeps saying "Error in video ID: HTTP is not supported.
"

@Emmanuelasika that was solved some time ago - you'll need to grab the latest code, not just the latest release - it's also not related to this thread

@sunil11475
Copy link
Author

sunil11475 commented Oct 24, 2019

Figured it out.

  1. In Provider.php script, method provide() switch back to using

$video_info_url = 'https://www.youtube.com/get_video_info?&video_id=' . $input . '&asv=3&el=detailpage&hl=en_US'

instead of

$video_info_url = 'https://www.youtube.com/get_video_info?&video_id=' . $input . '&asv=3&hl=en_US';

  1. Seems like video_info no longer contains video_id, which is why we need to pass it in manually to createFromStringWithOptions() method of VideoInfo.php like this:
public static function createFromStringWithOptions($string, array $options, $video_id)
    {
        $default = [
            'decipher_signature' => false,
        ];

        foreach ($default as $key => $value) {
            if (! array_key_exists($key, $options)) {
                $options[$key] = $value;
            }
        }

        parse_str($string, $video_info);

        $video_info["video_id"] = $video_id;

        return new self($video_info, $options);
    }
  1. Now, back in Provider.php script in method provide() you would call the method VideoInfo::createFromStringWithOptions like this:

$video_info = VideoInfo::createFromStringWithOptions( $response->getBodyAsString(), $this->options, $input );

The $input variable should contain our youtube ID if we are passing it in when calling the script.

I have update code on server. I updated code as you commented but i was getting below error -

Fatal error: Uncaught Error: Call to undefined method YoutubeDownloader\Http\Response::getBodyAsString() in /Domain/app/youtube/src/Provider/Youtube/Provider.php:168 Stack trace: #0

So i have change your below code

$video_info = VideoInfo::createFromStringWithOptions( $response->getBodyAsString(), $this->options, $input );

to

$video_info = VideoInfo::createFromStringWithOptions( $response->getBody()->__toString(), $this->options, $input );

getBodyAsString() error gone but this error came back -

Fatal error: Uncaught Error: Call to a member function getType() on null in /MYHOSTPATH/httpd.www/app/youtube/src/Application/ResultController.php:91 Stack trace: #0
....

@jeckman
Copy link
Owner

jeckman commented Jan 18, 2020

dupe of #396

@jeckman jeckman closed this as completed Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants