MichaelBelgium / Youtube-API

A way to host your own API that converts youtube video's to mp3/mp4 and returns a download/stream link and information.
155 stars 49 forks source link

norkunas/youtube-dl-php V2 Support #31

Closed oneandonlyjason closed 2 years ago

oneandonlyjason commented 3 years ago

Hi, i tried to Replace the youtube-dl-php Version that the is used here with the dev-master Version because this Version also Supports yt-dlp.

Sadly i get following Error then.

PHP Fatal error: Uncaught TypeError: Argument 1 passed to YoutubeDl\\YoutubeDl::__construct() must be an instance of YoutubeDl\\Process\\ProcessBuilderInterface or null, array given, called in /HDDs/ytmp3/convert.php on line 67 and defined in /HDDs/ytmp3/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php:55\nStack trace:\n#0 /HDDs/ytmp3/convert.php(67): YoutubeDl\\YoutubeDl->__construct()\n#1 {main}\n thrown in /HDDs/ytmp3/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php on line 55

Can you add Support for this Version aswell?

oneandonlyjason commented 2 years ago

It still only downloads the video and not the playlist

Thats Strange, when i tested this exactly Link (Thats the Reason i posted it) it went into a Download Loop. It Downloaded 10 Files before i Killed the Process

MichaelBelgium commented 2 years ago

Hmm if i use that link it just downloads the video, didn't try with youtube-dl tho

oneandonlyjason commented 2 years ago

image Thats when i use my Link on a freshly new Setup with Empty Download Folder. I let in run for a While and then killed the yt-dlp and ffmpeg process

MichaelBelgium commented 2 years ago

I have this output when using https://www.youtube.com/watch?v=6kPHNW8kdcs&list=RD6kPHNW8kdcs&start_radio=1

youtube] 6kPHNW8kdcs: Downloading webpage
[youtube] 6kPHNW8kdcs: Downloading android player API JSON
[info] 6kPHNW8kdcs: Downloading 1 format(s): 251
[info] Writing video metadata as JSON to: download/6kPHNW8kdcs.info.json
[download] Destination: download/6kPHNW8kdcs.webm

[download]   0.0% of 2.79MiB at Unknown speed ETA Unknown
[download]   0.1% of 2.79MiB at Unknown speed ETA Unknown
[download]   0.2% of 2.79MiB at  5.94MiB/s ETA 00:00     
[download]   0.5% of 2.79MiB at 10.81MiB/s ETA 00:00
[download]   1.1% of 2.79MiB at 870.05KiB/s ETA 00:03
[download]   2.2% of 2.79MiB at  1.03MiB/s ETA 00:02 
[download]   4.4% of 2.79MiB at  1.30MiB/s ETA 00:02
[download]   8.9% of 2.79MiB at  1.94MiB/s ETA 00:01
[download]  17.9% of 2.79MiB at  2.10MiB/s ETA 00:01
[download]  35.8% of 2.79MiB at  2.63MiB/s ETA 00:00
[download]  71.6% of 2.79MiB at  3.65MiB/s ETA 00:00
[download] 100% of 2.79MiB at  3.98MiB/s ETA 00:00  
[download] 100% of 2.79MiB in 00:00               
[ExtractAudio] Destination: download/6kPHNW8kdcs.mp3
Deleting original file download/6kPHNW8kdcs.webm (pass -k to keep)
MichaelBelgium commented 2 years ago

I've edited the laravel version and it seems it's working perfectly

oneandonlyjason commented 2 years ago

Ok thats strange then. Why do i get different behaviour of yt-dlp and youtube-dl-php then you get. With a complete fresh Installation

oneandonlyjason commented 2 years ago

I have this output when using https://www.youtube.com/watch?v=6kPHNW8kdcs&list=RD6kPHNW8kdcs&start_radio=1

youtube] 6kPHNW8kdcs: Downloading webpage
[youtube] 6kPHNW8kdcs: Downloading android player API JSON
[info] 6kPHNW8kdcs: Downloading 1 format(s): 251
[info] Writing video metadata as JSON to: download/6kPHNW8kdcs.info.json
[download] Destination: download/6kPHNW8kdcs.webm

[download]   0.0% of 2.79MiB at Unknown speed ETA Unknown
[download]   0.1% of 2.79MiB at Unknown speed ETA Unknown
[download]   0.2% of 2.79MiB at  5.94MiB/s ETA 00:00     
[download]   0.5% of 2.79MiB at 10.81MiB/s ETA 00:00
[download]   1.1% of 2.79MiB at 870.05KiB/s ETA 00:03
[download]   2.2% of 2.79MiB at  1.03MiB/s ETA 00:02 
[download]   4.4% of 2.79MiB at  1.30MiB/s ETA 00:02
[download]   8.9% of 2.79MiB at  1.94MiB/s ETA 00:01
[download]  17.9% of 2.79MiB at  2.10MiB/s ETA 00:01
[download]  35.8% of 2.79MiB at  2.63MiB/s ETA 00:00
[download]  71.6% of 2.79MiB at  3.65MiB/s ETA 00:00
[download] 100% of 2.79MiB at  3.98MiB/s ETA 00:00  
[download] 100% of 2.79MiB in 00:00               
[ExtractAudio] Destination: download/6kPHNW8kdcs.mp3
Deleting original file download/6kPHNW8kdcs.webm (pass -k to keep)

Did you do this on a Command line? And when yes which arguments did you use?

MichaelBelgium commented 2 years ago

No, i debugged $dl U can see what urs does

$dl->debug(function ($type, $buffer) {
echo $buffer;
});
oneandonlyjason commented 2 years ago

@MichaelBelgium I think i need a little more help, i tried to paste this in Various places inside the convert.php but i then always have a Server Error. I know to little PHP to really understand where this is going to debug it

And thank you really much for all your Help

MichaelBelgium commented 2 years ago

You should put it under line 91, so like

$dl = new YoutubeDl();
$dl->debug(function ($type, $buffer) {
    echo $buffer;
});
oneandonlyjason commented 2 years ago

Did you test it with a direct Request to the convert.php File or over the Panel? Just something i noticed right now. When i do a direct request to the Convert.php File with my Link then it downloads only one File. But when i do it over the Webpanel it starts to download Every Video in this Playlist

Which is strange because the Index does only make a Request to convert.php itself right?

Edit: I used my Network Tab to see the Exact URL the Dashboard does Access and when i access it myself directly it downloads only one File but when it does get requested over the Index File then it starts the Download Loop

MichaelBelgium commented 2 years ago

Yeah i only did a direct request to convert.php, not via index page. The index should just do the same request ...

Lemme check

EDIT: lol wtf, ok .... you're right

oneandonlyjason commented 2 years ago

EDIT: lol wtf, ok .... you're right

Ok xD At least its not me going insane. Just i dont really understand why, When i literally access the Same URL directly it just downloads one

MichaelBelgium commented 2 years ago

It's doing this request to the convert page

convert.php?youtubelink=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D6kPHNW8kdcs%26list%3DRD6kPHNW8kdcs%26start_radio%3D1&format=mp3

Which looks fine afaik, or maybe it's because of the symbols?

oneandonlyjason commented 2 years ago

When i copied the URL the Index Does directly into the URL Bar it just worked fine. But i dont think i can test the Symbol Case, the Browser automatically corrects them

MichaelBelgium commented 2 years ago

This is so strange, but the option --no-playlist fixes it. And it's best to set it i guess, because the api is not for playlists

EDIT: i think this is fully fixed now i guess? And can be merged?

oneandonlyjason commented 2 years ago

Let me check a few URLS quick

oneandonlyjason commented 2 years ago

EDIT: i think this is fully fixed now i guess? And can be merged?

Seems good to go for me