Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapper doesn't return all videos from Instagram carousel #258

Open
mostafa-norouzi opened this issue Dec 6, 2024 · 5 comments
Open

Wrapper doesn't return all videos from Instagram carousel #258

mostafa-norouzi opened this issue Dec 6, 2024 · 5 comments

Comments

@mostafa-norouzi
Copy link
Contributor

mostafa-norouzi commented Dec 6, 2024

Hi,
I have below sample code to fetch videos from Instagram carousel :


  $yt = new YoutubeDl();

    $yt->debug(function ($type, $buffer) {

        if (\Symfony\Component\Process\Process::ERR === $type) {
            error_log ('ERR> ' . $buffer);
        }

    });

    $options = Options::create()
        ->downloadPath($folder)
        ->writeThumbnail(true)
        ->restrictFileNames(true)
        ->limitRate('2M')
        ->retries('2')
        ->userAgent('Mozilla/5.0 (Android 14; Mobile; rv:128.0) Gecko/128.0 Firefox/128.0')
        ->mergeOutputFormat('mp4')
        ->remuxVideo('mp4')
        ->output("%(title)s.$quality.%(ext)s")
        ->url($url);

    $collection = $yt->download(
        $options
    );


    foreach ($collection->getVideos() as $video) {
        if ($video->getError() !== null) {

           // $reply->msg = $video->getError();

        } else {
            error_log($video->getFile());
        }
    }

When I check the output folder on disk, there are three videos but PHP [foreach loop] only logs last one. So how can I get path of others?

@norkunas
Copy link
Owner

norkunas commented Dec 6, 2024

If you would log everything in debug mode, what does it show?

@mostafa-norouzi
Copy link
Contributor Author

This is the whole log :


 [Instagram] Extracting URL: https://www.instagram.com/p/C4GhVSIqClB
 [Instagram] C4GhVSIqClB: Setting up session
 [Instagram] C4GhVSIqClB: Downloading JSON metadata
 [download] Downloading playlist: Post by birdsonearth
 [info] Writing playlist metadata as JSON to: public_html/youtube/bot/files/61836014/1733558916.Post_by_birdsonearth.360.info.json
 [info] There are no playlist thumbnails to download
 [Instagram] Playlist Post by birdsonearth: Downloading 2 items of 2
 [download] Downloading item 1 of 2
 [info] C4GhR8sqVB3: Downloading 1 format(s): 0
 [info] Downloading video thumbnail 0 ...
 [info] Writing video thumbnail 0 to: public_html/youtube/bot/files/61836014/1733558916.Video_1.360.jpg
 [info] Writing video metadata as JSON to: public_html/youtube/bot/files/61836014/1733558916.Video_1.360.info.json
 [download] Destination: public_html/youtube/bot/files/61836014/1733558916.Video_1.360.mp4
 
[download]   0.1% of  684.84KiB at  Unknown B/s ETA Unknown

[download]   0.4% of  684.84KiB at    1.45MiB/s ETA 00:00  
[download]   1.0% of  684.84KiB at    1.80MiB/s ETA 00:00
[download]   2.2% of  684.84KiB at    1.49MiB/s ETA 00:00
[download]   4.5% of  684.84KiB at    1.86MiB/s ETA 00:00
[download]   9.2% of  684.84KiB at    1.96MiB/s ETA 00:00
[download]  18.5% of  684.84KiB at    1.96MiB/s ETA 00:00
[download]  37.2% of  684.84KiB at    1.98MiB/s ETA 00:00
[download]  74.6% of  684.84KiB at    1.99MiB/s ETA 00:00
[download] 100.0% of  684.84KiB at    1.99MiB/s ETA 00:00
[download] 100% of  684.84KiB in 00:00:05 at 127.53KiB/s 
[VideoRemuxer] Not remuxing media file "public_html/youtube/bot/files/61836014/1733558916.Video_1.360.mp4"; already is in target format mp4
[download] Downloading item 2 of 2
[info] C4GhTZRKQL_: Downloading 1 format(s): 0
[info] Downloading video thumbnail 0 ...

[info] Writing video thumbnail 0 to: public_html/youtube/bot/files/61836014/1733558916.Video_2.360.jpg
[info] Writing video metadata as JSON to: public_html/youtube/bot/files/61836014/1733558916.Video_2.360.info.json
[download] Destination: public_html/youtube/bot/files/61836014/1733558916.Video_2.360.mp4

[download]   0.1% of    1.05MiB at  914.59KiB/s ETA 00:01
[download]   0.3% of    1.05MiB at    1.54MiB/s ETA 00:00
[download]   0.7% of    1.05MiB at    1.82MiB/s ETA 00:00
[download]   1.4% of    1.05MiB at    1.42MiB/s ETA 00:00
[download]   2.9% of    1.05MiB at    1.95MiB/s ETA 00:00
[download]   5.9% of    1.05MiB at    1.97MiB/s ETA 00:00
[download]  11.9% of    1.05MiB at    1.98MiB/s ETA 00:00
[download]  23.8% of    1.05MiB at    1.98MiB/s ETA 00:00
[download]  47.7% of    1.05MiB at    1.99MiB/s ETA 00:00
[download]  95.5% of    1.05MiB at    1.99MiB/s ETA 00:00
[download] 100.0% of    1.05MiB at    1.99MiB/s ETA 00:00
[download] 100% of    1.05MiB in 00:00:05 at 192.61KiB/s 
[VideoRemuxer] Not remuxing media file "public_html/youtube/bot/files/61836014/1733558916.Video_2.360.mp4"; already is in target format mp4
[info] Writing updated playlist metadata as JSON to: public_html/youtube/bot/files/61836014/1733558916.Post_by_birdsonearth.360.info.json
[download] Finished downloading playlist: Post by birdsonearth

Do you have any idea?

@norkunas
Copy link
Owner

norkunas commented Dec 7, 2024

This library has only tests for youtube playlists, as it was never tested with other providers, so this will need some updates.
Basically currently it is always expected that yt-dl will print [provider] id: Downloading webpage line before starting video download or [download] Destination: path_to_file when it was completed, so basically this always find only destination part and overrides previous one. But I won't be able to put some time on this for now.

@mostafa-norouzi
Copy link
Contributor Author

mostafa-norouzi commented Dec 7, 2024

I get that.

You suggest I make a temporary folder in each request and create a list of all videos on it or just check the output log and retrieve a list from it? I mean which strategy is more trusted?

@norkunas
Copy link
Owner

norkunas commented Dec 7, 2024

I'd suggest to contribute and fix this :)

Depends on what are your needs. If for you only files are enough, then yes, easy solution would be to scan in temporary path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants