From 74f16db39b01caac1c99cb692d2900e16f8b83b8 Mon Sep 17 00:00:00 2001 From: waska14 Date: Tue, 5 Oct 2021 18:39:36 +0400 Subject: [PATCH] Include playlist index --- src/Overrides/YoutubeDl/YoutubeDl.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Overrides/YoutubeDl/YoutubeDl.php b/src/Overrides/YoutubeDl/YoutubeDl.php index c51c419..7ba18ff 100644 --- a/src/Overrides/YoutubeDl/YoutubeDl.php +++ b/src/Overrides/YoutubeDl/YoutubeDl.php @@ -76,14 +76,21 @@ public function getQuietUrl(string $url): ?string public function getData(string $videoUrl): ?array { if (!Cache::get($videoUrl)) { - $cookieParams = []; + $params = []; if ($cookiePath = config('laravel-youtube-converter.cookies_path')) { - $cookieParams = [ + $params = [ '--cookies', $cookiePath ]; } - $process = $this->processBuilder->build($this->binPath, $this->pythonPath, array_merge($cookieParams, [ + // Include playlist index + try { + parse_str(parse_url($videoUrl)['query'], $query); + if (Arr::has($query, 'index')) { + $params = array_merge($params, ['--playlist-items', $query['index']]); + } + } catch (\Throwable $e) {} + $process = $this->processBuilder->build($this->binPath, $this->pythonPath, array_merge($params, [ '-f', 'best', '--get-url',