summaryrefslogtreecommitdiff
path: root/app/Console/Commands/ScrapeUrlFile.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Console/Commands/ScrapeUrlFile.php')
-rw-r--r--app/Console/Commands/ScrapeUrlFile.php48
1 files changed, 10 insertions, 38 deletions
diff --git a/app/Console/Commands/ScrapeUrlFile.php b/app/Console/Commands/ScrapeUrlFile.php
index f4f114b..e9472d2 100644
--- a/app/Console/Commands/ScrapeUrlFile.php
+++ b/app/Console/Commands/ScrapeUrlFile.php
@@ -9,35 +9,9 @@ use Illuminate\Support\Facades\Storage;
class ScrapeUrlFile extends Command
{
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
protected $signature = 'scrape:urls { filename } { format }';
-
- /**
- * The console command description.
- *
- * @var string
- */
protected $description = 'Scrape a youtube for videos';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
-
- /**
- * Execute the console command.
- *
- * @return mixed
- */
public function handle()
{
$filename = $this->argument('filename');
@@ -48,23 +22,21 @@ class ScrapeUrlFile extends Command
foreach ($urls as $url) {
$service = new Service($url, $this->output);
- if ($format == 'video') {
- $service->downloadVideo('video');
- } elseif ($format == 'audio') {
- $service->downloadAudio('audio');
+ if ($service->modelExists($url)) {
+ $this->info("Skipping $url. Exists in db!");
+ continue;
}
- $video_model = Video::create(
- [
- 'path' => $service->getFullPath()
- ]
- );
+ if ($service->createModel($format)) {
+ $this->info("Download {$service->getTitle()} from $url!");
+ } else {
+ $this->info('Skipping ' . $url . '. ' . ucfirst($format) . ' file already exists!');
+ continue;
+ }
- $this->info('Download of ' . $service->getTitle() . ' complete!');
+ $this->info("Download {$service->getTitle()} from $url!");
}
-
-
return Command::SUCCESS;
}