hakanersu / codecourse-downloader

codecourse.com video downloader.
63 stars 15 forks source link

Snippet videos do not download properly #29

Closed ipkpjersi closed 4 years ago

ipkpjersi commented 5 years ago

Hello,

Snippet videos do not seem to be downloading properly:

Thanks.

sagar3506 commented 5 years ago

image downloading in 1kb @hakanersu

hakanersu commented 5 years ago

Can you change this lines to https://github.com/hakanersu/codecourse-downloader/blob/master/src/App.php#L121-L142

try {
                            $url = $this->remote->getRedirectUrl($lesson->link);

                            $this->remote->web->request('GET', $url, [
                                'sink' => $sink,
                                'progress' => function ($dl_total_size, $dl_size_so_far, $ul_total_size, $ul_size_so_far) use ($progressBar, $courseTitle, $lesson) {
                                    $total = \ByteUnits\bytes($dl_total_size)->format('MB');
                                    $sofar = \ByteUnits\bytes($dl_size_so_far)->format('MB');
                                    $percentage = $dl_total_size != '0.00' ? number_format($dl_size_so_far * 100 / $dl_total_size) : 0;
                                    $progressBar->setMessage("Downloading ({$courseTitle}): {$lesson->title} {$sofar}/{$total} ({$percentage}%)", 'status');
                                    // It takes too much time to figure this line. Without advance() it was not update message.
                                    // With  this method i can update message.
                                    $progressBar->display();
                                },
                            ]);
                        } catch (\Exception $e) {
                            //error("Cant download '{$lesson->title}'. Do you have active subscription?");
                            dd($e->getMessage());
                            continue;
                        } catch (GuzzleException $e) {
                            dd($e->getMessage());
                            continue;
                            //error("Cant download '{$lesson->title}'. Do you have active subscription?");
                        }
sagar3506 commented 5 years ago

no i didn`t check that ok wait i change that btw thanks for help

On Thu, Apr 4, 2019 at 12:48 PM Hakan ERSU notifications@github.com wrote:

Can you change this lines to https://github.com/hakanersu/codecourse-downloader/blob/master/src/App.php#L121-L142

try { $url = $this->remote->getRedirectUrl($lesson->link); $this->remote->web->request('GET', $url, [ 'sink' => $sink, 'progress' => function ($dl_total_size, $dl_size_so_far, $ul_total_size, $ul_size_so_far) use ($progressBar, $courseTitle, $lesson) { $total = \ByteUnits\bytes($dl_total_size)->format('MB'); $sofar = \ByteUnits\bytes($dl_size_so_far)->format('MB'); $percentage = $dl_total_size != '0.00' ? number_format($dl_size_so_far * 100 / $dl_total_size) : 0; $progressBar->setMessage("Downloading ({$courseTitle}): {$lesson->title} {$sofar}/{$total} ({$percentage}%)", 'status'); // It takes too much time to figure this line. Without advance() it was not update message. // With this method i can update message. $progressBar->display(); }, ]); } catch (\Exception $e) { //error("Cant download '{$lesson->title}'. Do you have active subscription?"); dd($e->getMessage()); continue; } catch (GuzzleException $e) { dd($e->getMessage()); continue; //error("Cant download '{$lesson->title}'. Do you have active subscription?"); }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hakanersu/codecourse-downloader/issues/29#issuecomment-479780291, or mute the thread https://github.com/notifications/unsubscribe-auth/AI-sGI8MpUpzY9yigflt9wcELK0GC5Vaks5vdadLgaJpZM4Zga7a .

hakanersu commented 5 years ago

I can make it stop when $dl_total_size is 1kb or skip.

ralbear commented 5 years ago

I have a problem with snippets as well but now, in my case, any file was downloaded. The process skip the file directly without any error only:

All videos downloaded for course: cleanly-iterating-over-javascript-objects
   0/0  [>---------------------------]   0%

The snippets have a different page, so i guest the problem came from there.

I will work in a PR when i have a bit of time.

hakanersu commented 5 years ago

@ralbear I am appreciated any pr.

ralbear commented 5 years ago

That's my plan, now lets see if i have a moment to do that! 😄

hakanersu commented 4 years ago

it must be fixed with latest update.