Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Youtube Video not downloading. A webpage download instead [closed]

$
0
0

I am creating a youtube video downlaoding project. I have fetched the video detail with Youtube API. But on trying to download the video. A webpage downloads instead of video.

I am using Laravel for this project. This is my controller code below for downloading the video.

public function DownloadVideo($videoId)    {        $videoUrl = "https://www.youtube.com/watch?v={$videoId}";        $filename = "video_{$videoId}.mp4";    if (Storage::exists($filename)) {        $filePath = Storage::path($filename);        return response()->download($filePath, $filename, ['Content-Type' => 'video/mp4',        ], 'inline');    }    }

Tried to log the file content and filepath

 if (Storage::exists($filename)) {        $filePath = Storage::path($filename);        Log::info("File path: $filePath");        Log::info("File content: " . file_get_contents($filePath));        return response()->download($filePath, $filename, [], 'inline');    }

in file content i got web page code.


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>