<?php

namespace App\Download\Downloader;

use App\Message\DownloadMessage;
use App\Message\DownloadMovieMessage;
use App\Message\DownloadTvShowMessage;

class WgetDownloader implements DownloaderInterface
{

    /**
     * @inheritDoc
     * SSHs into the NAS and performs the download.
     * This way retains the fast DL speed on the NAS.
     */
    public function download(string $baseDir, string $title, string $url, ?int $downloadId): void
    {
        // SSHs into the NAS, cds into movies dir, makes new dir based on filename, cds into that dir, downloads movie
        system(sprintf(
            'sh /var/www/bash/app/wget_download.sh "%s" "%s" "%s"',
            $baseDir,
            $title,
            $url
        ));
    }
}