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?

MichaelBelgium commented 2 years ago

You mean this one?

EDIT: oh you mean v2 of norkunas?

oneandonlyjason commented 2 years ago

I think so. The Readme to https://github.com/norkunas/youtube-dl-php shows that the dev-master Version also supports yt-dlp because yt-dlp and youtube-dl have slighty different Outputs i think Comment

I tried to install the dev-master Version and replace the Stable Version that this Script uses but then it throws the Error i posted above.

Dont really know if you can do anything to support the dev-master Version before he Uploads a Stable Version, but would be nice if you can look into it because youtube-dl is pretty dead now that the Maintainer no longer is active

oneandonlyjason commented 2 years ago

@MichaelBelgium Norkunas Released a Stable V2 Version which now Supports yt-dlp. From a look at the Code i guess the Script doesnt Support it out of the Box because we have no way to say which Command Line Tool (YT-DLP or Youtube-Dl) we want to use. Can we please get Support for V2 of Norkunas? This would really be nice.

Thanks in Advance

MichaelBelgium commented 2 years ago

@oneandonlyjason Yes will look into it this week

dennorske commented 2 years ago

Let me know if you need something on the docker side afterwards @MichaelBelgium 😊

MichaelBelgium commented 2 years ago

So I've been testing out youtube-dl-php V2 and there's something wrong with it .. it takes extremely long to download/convert a video, which is unusual. The api call returns a timeout as it takes so long. Not sure what the problem is

Let me know if you need something on the docker side afterwards @MichaelBelgium 😊

Yes I will!

oneandonlyjason commented 2 years ago

@MichaelBelgium Thats Strange because it should work normally. At Least the Person in my Linked Issue has not said anything otherwhise. Do you have a Version that i can test if it is slow for me also?

Okay i saw that you have a own Branch for it.

oneandonlyjason commented 2 years ago

@MichaelBelgium Ok i testet the Branch and yeah something Strange is indeed Happening but not with the Download.

I couldn't figure out how to get the script to use yt-dlp, so I installed the normal youtube-dl with fix and tested it. The download was super fast, but then I had several problems.

First, the video was not converted to MP3 although MP3 was selected. And secondly, the download link I got back via JSON contained 2 times /download so /download/download/file.mkv and was therefore invalid.

This was the JSON Reply i got which shows both Problems: Picture

Edit: It makes no difference if I select MP3 or MP4. I always get what youtube-dl downloads which is usually a mkv or a webm file.

MichaelBelgium commented 2 years ago

First, the video was not converted to MP3 although MP3 was selected.

Wtf? I don't have that issue xD This is odd, why are there so many differences

And secondly, the download link I got back via JSON contained 2 times /download so /download/download/file.mkv and was therefore invalid.

Must be something on line 74 but I didn't even touch that?

I always get what youtube-dl downloads which is usually a mkv or a webm file.

Yes thats what i get too, it's not getting an mp3 file, only a mkv or webm. It's strange

oneandonlyjason commented 2 years ago

Must be something on line 74 but I didn't even touch that?

This is my Line so i would say its the Same like you linked: $url = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/".Config::DOWNLOAD_FOLDER;

I tried to set the FFMPEG Path in the File Convert.php to test if that helps but it makes no difference for me. When Looking on HTOP i see the youtube-dl Python Process and as soon this finished i get the JSON Reply with sometimes mp4 sometimes webm sometimes mkv without a FFMPEG Process even starting

MichaelBelgium commented 2 years ago

The example you used as video url isn't available anymore, it's working with another video Also edited

The double slash is coming from dirname($_SERVER['PHP_SELF']) as it's /convert.php so i'd need to change that.

EDIT: if those issues are fixed, i'm back at the original issue - converting/downloading takes way too long. I'm using version 2021.12.17 of youtube-dl

oneandonlyjason commented 2 years ago

The Example is still avaible for me so Strange. But i tested it now with the Changes you did a few Minutes Ago the the convert.php and still have the Same Problem. No MP3 File. I used this Video now: https://www.youtube.com/watch?v=btPJPFnesV4

Edit: And also Still /download/download and i dont really understand why xD

oneandonlyjason commented 2 years ago

EDIT: if those issues are fixed, i'm back at the original issue - converting/downloading takes way too long. I'm using version 2021.12.17 of youtube-dl

That Problem could maybe be that this Version of Youtube-DL still doesnt contain the Throttling Fix. Thats the Reason i want to Switch this to yt-dlp because YT has implemented a Challenge that Throttles your Download Speed drastically when you cant solve the Challenge Correctly.

There are Community Made Fixes that backport fixes of yt-dlp to youtube-dl but with the now inactive Maintainer of youtube-dl this Fixes will probably make it never to the Main Branch and every Change Youtube Makes to the Challenge can break it again

What happens when you try to Download with your Version of youtube-dl on the Command Line?

MichaelBelgium commented 2 years ago

What happens when you try to Download with your Version of youtube-dl on the Command Line?

Huh interesting

youtube-dl --ignore-config --ignore-errors --write-info-json --output="download/%(id)s.%(ext)s" https://www.youtube.com/watch?v=_VeNOH9i06I [youtube] _VeNOH9i06I: Downloading webpage [info] Writing video description metadata as JSON to: download/_VeNOH9i06I.info.json WARNING: Requested formats are incompatible for merge and will be merged into mkv. [download] Resuming download at byte 19594078 [download] Destination: download/_VeNOH9i06I.f137.mp4 [download] 28.8% of 73.74MiB at 45.07KiB/s ETA 19:53

20 minutes for 73MB? 🤣 Ok so this is the throttle thing you mean You're right

oneandonlyjason commented 2 years ago

Yeah Youtube Implemented a Funny Challenge to kill the Downloader Softwares out there, some Videos already provide the Signature you need to get unthrottled other Videos (High Demand Videos) have a Crypted Signature and you need to Solve a Javascript Challenge to get the Right Signature from that, and only then you can load with more than ~45KiB so thats fun.

The Fix i linked above fixes this for youtube-dl but yeah, thats probably never gonna reach the Stable Branch and because of that can never be easy Updated with youtube-dl -U

yt-dlp implements a Javascript Interpreter to solve this Challenge so yeah

But yeah yt-dlp i cant test because i dont know how to set the Binary Path and with the Community Fixed youtube-dl Version i have the Problems with not getting MP3 xD

Edit: Your Last Commit removed the // but i still get /download/download somehow xD

Edit2: I dont believe that yt-dlp or the fixed youtube-dl is the Reason for not getting a MP3, i think there is a change Somewhere in Norkunas V2 but i dont really get where

oneandonlyjason commented 2 years ago

@MichaelBelgium Okay new Stuff i found. I commented out the Block with If mp3 and copied the Stuff for MP3 to the Top. See this Picture. When i make it like this it converts it to MP3 correctly

Seems to Function with all URLS like this: Picture

MichaelBelgium commented 2 years ago

So every youtube-dl version is affected by the throttle untill that pull request gets merged?

Also i think u have 2x download/ as DOWNLOAD_PATH then?

oneandonlyjason commented 2 years ago

So every youtube-dl version is affected by the throttle untill that pull request gets merged?

Exactly. To be more Precise i think there are two fixes right now. The Pull Request that Backports the JS Interp from yt-dlp or a Single File Fix which uses Code from the VLC Project to manually Parse the Challenge (Which can break anytime Youtube changes the Challenge which is the Reason that yt-dlp implements a JS Interp because thats the more Stable Solution.)

Also i think u have 2x download/ as DOWNLOAD_PATH then?

Yeah you can see it in my Picture that the Path returns /download/download but in the Config File it only is /download and it also writes the File to the Correct Directory it just gives it out wrong

And because the Last active Maintainer from youtube-dl is now inactive most People and Projects start to switch to the yt-dlp Fork of youtube-dl

Edit: yt-dlp also changed the way the Best Format gets selected. yt-dlp tries to prefer more modern Codecs like Googles VP9 over a higher Bitrate. So sometimes you get a smaller Overhead File (which reduces the download Time and Load on the Server) without to sacrifice Quality

With YT-DLP:

root@S1 ~ # yt-dlp https://www.youtube.com/watch?v=_VeNOH9i06I [youtube] _VeNOH9i06I: Downloading webpage [youtube] _VeNOH9i06I: Downloading android player API JSON [info] _VeNOH9i06I: Downloading 1 format(s): 248+251 [download] Destination: Victoria Justice - Too F_ckin' Nice (Official Lyric Video) [_VeNOH9i06I].f248.webm [download] 100% of 47.55MiB in 00:01 [download] Destination: Victoria Justice - Too F_ckin' Nice (Official Lyric Video) [_VeNOH9i06I].f251.webm [download] 100% of 2.39MiB in 00:00 [Merger] Merging formats into "Victoria Justice - Too F_ckin' Nice (Official Lyric Video) [_VeNOH9i06I].webm" Deleting original file Victoria Justice - Too F_ckin' Nice (Official Lyric Video) [_VeNOH9i06I].f248.webm (pass -k to keep) Deleting original file Victoria Justice - Too F_ckin' Nice (Official Lyric Video) [_VeNOH9i06I].f251.webm (pass -k to keep)

MichaelBelgium commented 2 years ago

I am SO confused, I can reproduce your mp3 issue, that its not returning an mp3 file And when debugging It looks like the options aren't being set. You can tell u want the best quality and an mp3 file but it's not translating it into the command line for youtube-dl or yt-dlp

$options = Options::create()
            // ->ffmpegLocation('/usr/local/bin/ffmpeg')
            ->output('%(id)s.%(ext)s')
            ->downloadPath(Config::DOWNLOAD_FOLDER)
            ->url($youtubelink);

        if($format == 'mp3')
        {
            $options->extractAudio(true)
                ->audioFormat('mp3')
                ->audioQuality('0');
        }

This code should set these arguments on the command line:

But this is what the $options variable is after setting all the options:

array(109) {
  ["proxy"]=> NULL
  ["socket-timeout"]=> NULL
  ["source-address"]=> NULL
  ["force-ipv4"]=> bool(false)
  ["force-ipv6"]=> bool(false)
  ["geo-verification-proxy"]=> NULL
  ["geo-bypass"]=> bool(false)
  ["no-geo-bypass"]=> bool(false)
  ["geo-bypass-country"]=> NULL
  ["geo-bypass-ip-block"]=> NULL
  ["playlist-start"]=> NULL
  ["playlist-end"]=> NULL
  ["playlist-items"]=> array(0) {}
  ["match-title"]=> NULL
  ["reject-title"]=> NULL
  ["max-downloads"]=> NULL
  ["min-filesize"]=> NULL
  ["max-filesize"]=> NULL
  ["date"]=> NULL
  ["datebefore"]=> NULL
  ["dateafter"]=> NULL
  ["min-views"]=> NULL
  ["max-views"]=> NULL
  ["match-filter"]=> NULL
  ["no-playlist"]=> bool(false)
  ["yes-playlist"]=> bool(false)
  ["age-limit"]=> NULL
  ["limit-rate"]=> NULL
  ["retries"]=> NULL
  ["fragment-retries"]=> NULL
  ["skip-unavailable-fragments"]=> bool(false)
  ["keep-fragments"]=> bool(false)
  ["buffer-size"]=> NULL
  ["no-resize-buffer"]=> bool(false)
  ["http-chunk-size"]=> NULL
  ["playlist-reverse"]=> bool(false)
  ["playlist-random"]=> bool(false)
  ["xattr-set-filesize"]=> NULL
  ["hls-prefer-native"]=> bool(false)
  ["hls-prefer-ffmpeg"]=> bool(false)
  ["hls-use-mpegts"]=> bool(false)
  ["external-downloader"]=> NULL
  ["external-downloader-args"]=> NULL
  ["batch-file"]=> NULL
  ["id"]=> bool(false)
  ["output"]=> string(23) "download/%(id)s.%(ext)s"
  ["autonumber-start"]=> NULL
  ["restrict-filenames"]=> bool(false)
  ["no-overwrites"]=> bool(false)
  ["continue"]=> bool(false)
  ["no-continue"]=> bool(false)
  ["no-part"]=> bool(false)
  ["no-mtime"]=> bool(false)
  ["write-description"]=> bool(false)
  ["write-annotations"]=> bool(false)
  ["load-info-json"]=> NULL
  ["cookies"]=> NULL
  ["cache-dir"]=> NULL
  ["no-cache-dir"]=> bool(false)
  ["rm-cache-dir"]=> bool(false)
  ["write-thumbnail"]=> bool(false)
  ["write-all-thumbnails"]=> bool(false)
  ["skip-download"]=> bool(false)
  ["verbose"]=> bool(false)
  ["write-pages"]=> bool(false)
  ["print-traffic"]=> bool(false)
  ["call-home"]=> bool(false)
  ["no-call-home"]=> bool(false)
  ["encoding"]=> NULL
  ["no-check-certificate"]=> bool(false)
  ["prefer-insecure"]=> bool(false)
  ["user-agent"]=> NULL
  ["referer"]=> NULL
  ["add-header"]=> array(0) {}
  ["sleep-interval"]=> NULL
  ["max-sleep-interval"]=> NULL
  ["format"]=> NULL
  ["youtube-skip-dash-manifest"]=> bool(false)
  ["merge-output-format"]=> NULL
  ["write-sub"]=> bool(false)
  ["write-auto-sub"]=> bool(false)
  ["all-subs"]=> bool(false)
  ["sub-format"]=> NULL
  ["sub-lang"]=> array(0) {}
  ["username"]=> NULL
  ["password"]=> NULL
  ["twofactor"]=> NULL
  ["netrc"]=> bool(false)
  ["video-password"]=> NULL
  ["ap-mso"]=> NULL
  ["ap-username"]=> NULL
  ["ap-password"]=> NULL
  ["extract-audio"]=> bool(false)
  ["audio-format"]=> NULL
  ["audio-quality"]=> NULL
  ["recode-video"]=> NULL
  ["keep-video"]=> bool(false)
  ["no-post-overwrites"]=> bool(false)
  ["embed-subs"]=> bool(false)
  ["embed-thumbnail"]=> bool(false)
  ["add-metadata"]=> bool(false)
  ["metadata-from-title"]=> NULL
  ["xattrs"]=> bool(false)
  ["prefer-avconv"]=> bool(false)
  ["prefer-ffmpeg"]=> bool(false)
  ["ffmpeg-location"]=> NULL
  ["exec"]=> NULL
  ["convert-subs-format"]=> NULL
  ["url"]=> array(1) {
    [0]=>   string(43) "https://www.youtube.com/watch?v=_VeNOH9i06I"
  }
}
  1. extract-audio is not set.
  2. audio-quality is not set.
  3. audio-format is not set.

Why? (and yes, it's going inside the if-statement)

Then ofcourse this happens on the command line:

yt-dlp --ignore-config --ignore-errors --write-info-json --output="%(id)s.%(ext)s" https://www.youtube.com/watch?v=_VeNOH9i06I

The default arguments, as seen on youtube-dl-php, are the first three. Only our output with our download folder is getting set + url.

EDIT: omg it clones the variable in every setter... so i have to do

$options = $options->extractAudio(true)
                ->audioFormat('mp3')
                ->audioQuality('0');

That fixes it.

image

The next problem is that, with yt-dlp, $dl->download($options)->getVideos() is empty, but it does download it

oneandonlyjason commented 2 years ago

EDIT: omg it clones the variable in every setter... so i have to do

That Explains why it works when i set all in the Same Spot like i did with my Message above.

The next problem is that, with yt-dlp, $dl->download($options)->getVideos() is empty, but it does download it

That Strange Exactly this Problem should be fixed in V2 of Norkunas when i Understand it correctly

At least the Issue does say that exactly that was not working before the Fix and now it should be fixed: https://github.com/norkunas/youtube-dl-php/issues/162

oneandonlyjason commented 2 years ago

@MichaelBelgium Ok strange Things happening. I Updated to your newest commit.

This is happening:

  1. The Script correctly Finds and uses yt-dlp instead of youtube-dl
  2. I still get the /download/download error
  3. The Script correctly uses ffmpeg to convert the File to an MP3 BUT the Link im getting in the JSON Reply is the webm file and not the MP3 which is strange because there is no webm File on Disk anymore. It got deleted after ffmpeg convertet it to mp3
MichaelBelgium commented 2 years ago

@MichaelBelgium Ok strange Things happening. I Updated to your newest commit.

This is happening:

  1. The Script correctly Finds and uses yt-dlp instead of youtube-dl
  2. I still get the /download/download error
  3. The Script correctly uses ffmpeg to convert the File to an MP3 BUT the Link im getting in the JSON Reply is the webm file and not the MP3 which is strange because there is no webm File on Disk anymore. It got deleted after ffmpeg convertet it to mp3
  1. 👍
  2. What is your Config::DOWNLOAD_FOLDER set as?
  3. I don't even get to that point because of getVideos() returning nothing, it then says undefined index 0 cuz well it's empty
oneandonlyjason commented 2 years ago

2. What is your Config::DOWNLOAD_FOLDER set as?

In my Config.php? Left it on Standard.

const DOWNLOAD_FOLDER = "download/";

Edit: Everything is complete Standard like its in the Branch right now. Only Stuff that i changed is the Max Video Duration and my Youtube API Key

MichaelBelgium commented 2 years ago

Then how are there 2 download folders? Did you install the project in mywebsite.dev/download ? Then you would have mywebsite.dev/download/download

oneandonlyjason commented 2 years ago

There is only one Download Folder thats the Strange. The Project itself is under /HDDs/ytmp3 and the Downloaded Files correctly are saved in /HDDs/ytmp3/download

Its is own VHost on a Subdomain so the Domain is ytdl.mydomain.net.

That is the Strange Thing. It saves Correctly, so it must know what the Correct Folder is

MichaelBelgium commented 2 years ago

Mhm, does it happen when you convert an existing song or a new one? Or both?

oneandonlyjason commented 2 years ago

I think Both, let me Try

oneandonlyjason commented 2 years ago

Okay really Strange Thing happening right now... Maybe a Logic Error?

I cant really test it right now because of a new Error.... When i try to download a URL i already have downloaded i get the Error that the Script didnt find youtube-dl. It seems like when the File Already Exist it doesnt even try to Find yt-dlp

{ "error": true, "message": "\"youtube-dl\" executable was not found. Did you forgot to configure it's binary path? ex.: $yt->setBinPath('/usr/bin/youtube-dl') ?."

MichaelBelgium commented 2 years ago

It shouldn't even get to that point as the song already exists on the system? It should hit line 79 and not the else block

Or maybe it's about the "pre check" but nothing has to be downloaded with youtube-dl or yt-dlp

oneandonlyjason commented 2 years ago

First Try to Convert a File: image

Second Try with the Same File:

image

oneandonlyjason commented 2 years ago

When Installing youtube-dl (with fix) and the Version from the Master Branch it works at expected. No Double /download no Convert to MP3 But give back a .mkv/mp4/webm Link. All the Problems are definitly from the v2 branch and not from the System

oneandonlyjason commented 2 years ago

@MichaelBelgium I reinstalled everything again and now.... I dont have the Problem with Binary not Found anymore.....

And:

  1. Download gives me: https://mydomain.net/download/download/MYWVKd0ar0.webm
  2. Download for the Same File gives: https://mydomain.net/download/eMYWVKd0ar0.mp3

Edit: Didnt want to Close it wrong Button...

Edit 2: Nvm The Error with no Binary Found is still there, i just had youtube-dl still installed so he used it. When i remove youtube-dl and only have yt-dlp installed it gives me a Binary Not Found Error when i try do redownload a File..... But at least it showed that the Error with double /download goes away when i try it on a already downloaded File

MichaelBelgium commented 2 years ago

Thats so strange. I think you should debug some stuff

  1. In stead of using the index page to convert, go directly to the convert page (eg http://mydomain.devel/convert.php?youtubelink=https://www.youtube.com/watch?v=_VeNOH9i06I
  2. Add some var_dumps in convert.php with die() behind it, aand go step by step to go through the process

Like i'm really curious what $url gives for you, to see where the download/download comes from - so only go to convert.php after you removed existing songs

So after line 76 you could do

//...

$dirname = dirname($_SERVER['PHP_SELF']);
$url = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] .
    ($dirname == '/' ? '' : $dirname) . "/" .
    Config::DOWNLOAD_FOLDER;

var_dump($dirname);
var_dump($url);
die();

//...

Show me the result

oneandonlyjason commented 2 years ago

Show me the result

string(1) "/" string(34) "https://mydomain.net/download/"

I removed only my Domain from it and replaced it with mydomain.net so this is what it gives me

oneandonlyjason commented 2 years ago

Would it help you when i send you the Domain somewhere private? So that you can see for yourself?

MichaelBelgium commented 2 years ago

Show me the result

string(1) "/" string(34) "https://mydomain.net/download/"

I removed only my Domain from it and replaced it with mydomain.net so this is what it gives me

Okay thats 100% correct and gives as expected. So that means $​video​->​getFilename​(); has download/ then?!

Can u confirm by putting

var_dump($file);
die();

After line 94, and remove existing song and previous debug lines

Would it help you when i send you the Domain somewhere private? So that you can see for yourself?

Mhm maybe, but also not really, as i'd need to debug to see for myself. But i don't have access to the files ofcourse

oneandonlyjason commented 2 years ago

string(59) "https://mydomain.net/download/download/_VeNOH9i06I.webm"

MichaelBelgium commented 2 years ago

Okay as expected... This probably also has to do something with V2

But to fix this or trying to reproduce i need to pass after ->getVideos() which still is empty for me (yt-dlp)

What a mess with this throttling ...

EDIT: somehow on my vps youtube-dl isn't affected by the throttling, I mean it does download in kb/s but the filesize of the song is WAY lower? 2.39MiB vs 74MiB

root@server:/var/www/html/YoutubeService/storage/app/public# youtube-dl https://www.youtube.com/watch?v=_VeNOH9i06I --no-playlist --ignore-config --write-info-json --extract-audio --audio-format=mp3 --audio-quality=0 --output="%(id)s.%(ext)s"
[youtube] _VeNOH9i06I: Downloading webpage
[youtube] Downloading just video _VeNOH9i06I because of --no-playlist
[info] Writing video description metadata as JSON to: _VeNOH9i06I.info.json
[download] Destination: _VeNOH9i06I.webm
[download]  76.3% of 2.39MiB at 69.76KiB/s ETA 00:08

If you don't put a direct youtube link to a video it'll download the mp4? and then mp3 too?

EDIT: okay, my stupid ass wasn't using the latest version of norkunas/youtube-dl-php, i was on 2.0.2 while there already was 2.1.1 - now i also have 2 times the download/

EDIT2: okay i fixed the double download issue, now it's the webm that i have too

oneandonlyjason commented 2 years ago

EDIT: okay, my stupid ass wasn't using the latest version of norkunas/youtube-dl-php, i was on 2.0.2 while there already was 2.1.1 - now i also have 2 times the download/

That Version didnt contain the yt-dlp fix yet so yeah xD

EDIT2: okay i fixed the double download issue, now it's the webm that i have too

Nice we are getting somewhere

oneandonlyjason commented 2 years ago

I am now at this status:

On the first download I get a webm file back as URL although it doesn't exist anymore because it was converted to an MP3 by ffmpeg. And on the second download of an already existing song I get:

"error":true, "message":"\"youtube-dl\" executable was not found. Did you forgot to configure it's binary path? ex.: $yt->setBinPath('\/usr\/bin\/youtube-dl') ?."}

as error if no youtube-dl but only yt-dlp is installed.

Can you confirm that it is the same situation for you?

MichaelBelgium commented 2 years ago

@oneandonlyjason The webm issue should be fixed in PR https://github.com/norkunas/youtube-dl-php/pull/175

Can you confirm that it is the same situation for you?

I have both installed but i'll check it out if i uninstall youtube-dl, I'll probably have the same error

EDIT: okay that should be fixed

oneandonlyjason commented 2 years ago

Okay so we need to wait that it gets merged :D

oneandonlyjason commented 2 years ago

So i already tried your PR for Norkunas and it works that i get the mp3. But here is another Problem (Maybe its the Missing Test in the PR but i dont think it is)

First time Converting something:

{ "error": false, "youtube_id": "_VeNOH9i06I", "title": "Victoria Justice - Too Fckin' Nice (Official Lyric Video)", "alt_title": "Too Fckin' Nice", "duration": 153, "file": "https://mydomain.net/download/_VeNOH9i06I.mp3", "uploaded_at": { "date": "2021-06-11 18:05:34.000000", "timezone_type": 3, "timezone": "Europe/Berlin" } }

Second Time trying to convert the already existing song:

{ "error": false, "youtube_id": "_VeNOH9i06I", "title": "Victoria Justice - Too Fckin' Nice (Official Lyric Video)", "alt_title": "Too Fckin' Nice", "duration": 153, "file": "https://mydomain.net/.mp3", "uploaded_at": { "date": "2021-06-11 18:07:32.000000", "timezone_type": 3, "timezone": "Europe/Berlin" } }

as you can see, if i try to Convert a File that is already saved on the Drive the Filename is missing. I only get the typ like .mp3 without a Name in the Front of It. And the /download is of Course also missing because its part of the Name. This happens for mp4 files too

Edit: I think its from this Commit: https://github.com/MichaelBelgium/Youtube-API/commit/a01a7ede16357194115791b9ee70d37e1717554b

Because you switched from id to the complete Result of youtube-dl / yt-dlp and this is empty when the File already exist because it never gets downloaded again.

MichaelBelgium commented 2 years ago

Yeah thats because the output of yt-dlp doesn't tell which file is downloaded. But i think youtube-dl does.

This is the output when it already exists

yt-dlp --ignore-config --ignore-errors --write-info-json --output="download/%(id)s.%(ext)s" --skip-download https://www.youtube.com/watch?v=oDAw7vW7H0c

[youtube] oDAw7vW7H0c: Downloading webpage
[youtube] oDAw7vW7H0c: Downloading android player API JSON
[info] oDAw7vW7H0c: Downloading 1 format(s): 248+251
[info] Writing video metadata as JSON to: download/oDAw7vW7H0c.info.json

EDIT: nope, yt-dlp and youtube-dl outputs the same, it just writes metadata and doesn't know what file gets returned EDIT2: well i can't use $video->getFilename() if it already exists so i put the previous code back

oneandonlyjason commented 2 years ago

I guess this would make the double download error again?

MichaelBelgium commented 2 years ago

No i tested it now and i dont have it. It only happened when downloading non existing videos

oneandonlyjason commented 2 years ago

Alright will make a few test Runs and Report back

oneandonlyjason commented 2 years ago

Maybe it would be good to set the noplaylist Option? Theoretically with a Link like this: https://www.youtube.com/watch?v=6kPHNW8kdcs&list=RD6kPHNW8kdcs&start_radio=1 somebody could otherwhise sent the API in a never Ending Download. Or at least i never saw a YT Radio Mix End

https://github.com/norkunas/youtube-dl-php/blob/master/src/Options.php#L1548

MichaelBelgium commented 2 years ago

My PR has been merged in youtube-dl-php

Maybe it would be good to set the noplaylist Option? Theoretically with a Link like this: https://www.youtube.com/watch?v=6kPHNW8kdcs&list=RD6kPHNW8kdcs&start_radio=1 somebody could otherwhise sent the API in a never Ending Download. Or at least i never saw a YT Radio Mix End

https://github.com/norkunas/youtube-dl-php/blob/master/src/Options.php#L1548

It still only downloads the video and not the playlist

@dennorske I've added a docker build github action and it seems to work. One question for you is: is the github action enough to conclude if docker builds the project correctly? Or can there be more "tests" ?

dennorske commented 2 years ago

Awesome, that should be fine, it will fail and let you know if it doesn't work 👍