jemand anders
Erfahrenes Mitglied
Hallo,
ich versuche auf einem Linux-System mit PHP Videofiles mittels yt-dlp herunterzulagen, d. h. yt-dlp muss installiert sein.
Die möglichen Formate zeigt er auch an in einem JSON-Objekt, das ich in der Anwendung auswerten kann.
Das Herunterladen selbst klappt allerdings nicht, und sehe nicht, wo das Problem ist.
Vielleicht hat jemand eine Idee. Vielen Dank.
Freundl. Grüße
Gibt man $shell_exec in der Konsole ein, ist die Ausgabe wesentlich umfangreicher als das, was man über php erhält, wenn man es dort via echo ausgibt.
ich versuche auf einem Linux-System mit PHP Videofiles mittels yt-dlp herunterzulagen, d. h. yt-dlp muss installiert sein.
Die möglichen Formate zeigt er auch an in einem JSON-Objekt, das ich in der Anwendung auswerten kann.
Das Herunterladen selbst klappt allerdings nicht, und sehe nicht, wo das Problem ist.
Vielleicht hat jemand eine Idee. Vielen Dank.
Freundl. Grüße
HTML:
Im Browser im URL-Feld eingeben (Localhost):
Formate: http://localhost/yt-dlp.php?url=https://www.youtube.com/watch?v=Sp1S267bM8Q
Download: http://localhost/yt-dlp.php?url=https://www.youtube.com/watch?v=Sp1S267bM8Q&format_id=230
PHP:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
$DOWNLOAD_DIRECTORY = " --paths '.' ";
$url = htmlspecialchars($_GET["url"]);
$_format_id = "";
if(isset($_GET["format_id"])) {
$_format_id = htmlspecialchars($_GET["format_id"]);
}
$format_id = ($_format_id!=="") ? ' -f ' . $_format_id . $DOWNLOAD_DIRECTORY : ' --dump-json ';
$shell_exec = 'yt-dlp --write-description --no-post-overwrite --rm-cache-dir --write-thumbnail --no-warnings --trim-filenames 200 ' . $format_id . $url;
$output = shell_exec($shell_exec);
echo ($output);
?>
Gibt man $shell_exec in der Konsole ein, ist die Ausgabe wesentlich umfangreicher als das, was man über php erhält, wenn man es dort via echo ausgibt.
Code:
<!-- SOLL (via Konsole)
yt-dlp --write-description --no-post-overwrite --rm-cache-dir --write-thumbnail --no-warnings --trim-filenames 200 -f 230 --paths '.' https://www.youtube.com/watch?v=Sp1S267bM8Q
Removing cache dir /home/peter/.cache/yt-dlp ...
[youtube] Extracting URL: https://www.youtube.com/watch?v=Sp1S267bM8Q
[youtube] Sp1S267bM8Q: Downloading webpage
[youtube] Sp1S267bM8Q: Downloading tv player API JSON
[youtube] Sp1S267bM8Q: Downloading ios player API JSON
[youtube] Sp1S267bM8Q: Downloading player 20830619
[youtube] Sp1S267bM8Q: Downloading m3u8 information
[info] Sp1S267bM8Q: Downloading 1 format(s): 230
[info] Writing video description to: ./Unglaubliche Bauwerke auf Bergen: Wie Wurde Das Gebaut? [Sp1S267bM8Q].description
[info] Downloading video thumbnail 41 ...
[info] Writing video thumbnail 41 to: ./Unglaubliche Bauwerke auf Bergen: Wie Wurde Das Gebaut? [Sp1S267bM8Q].webp
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 273
[download] Destination: ./Unglaubliche Bauwerke auf Bergen: Wie Wurde Das Gebaut? [Sp1S267bM8Q].mp4
[download] 100% of 45.79MiB in 00:00:25 at 1.80MiB/s
[FixupM3u8] Fixing MPEG-TS in MP4 container of "./Unglaubliche Bauwerke auf Bergen: Wie Wurde Das Gebaut? [Sp1S267bM8Q].mp4"
-->
<!-- IST (via PHP)
Removing cache dir /var/lib/wwwrun/.cache/yt-dlp ...
[youtube] Extracting URL: https://www.youtube.com/watch?v=Sp1S267bM8Q
[youtube] Sp1S267bM8Q: Downloading webpage [youtube] Sp1S267bM8Q: Downloading tv player API JSON
[youtube] Sp1S267bM8Q: Downloading ios player API JSON
[youtube] Sp1S267bM8Q: Downloading player 20830619
[youtube] Sp1S267bM8Q: Downloading m3u8 information
[info] Sp1S267bM8Q: Downloading 1 format(s): 230
[info] Writing video description to: ./Unglaubliche Bauwerke auf Bergen: Wie Wurde Das Gebaut? [Sp1S267bM8Q].description
-->
Zuletzt bearbeitet: