summaryrefslogtreecommitdiff
path: root/app/Console
diff options
context:
space:
mode:
Diffstat (limited to 'app/Console')
-rw-r--r--app/Console/Commands/ScrapeYoutube.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/app/Console/Commands/ScrapeYoutube.php b/app/Console/Commands/ScrapeYoutube.php
new file mode 100644
index 0000000..ce64d3f
--- /dev/null
+++ b/app/Console/Commands/ScrapeYoutube.php
@@ -0,0 +1,57 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Youtube\Service;
+use Illuminate\Console\Command;
+
+class ScrapeYoutube extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'scrape:youtube { url } { 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()
+ {
+ $url = $this->argument('url');
+ $format = $this->argument('format');
+
+ $service = new Service($url, $this->output);
+
+ if ($format == 'video') {
+ $video = $service->downloadVideo('video');
+ } elseif ($format == 'audio') {
+ $video = $service->downloadAudio('audio');
+ }
+
+ $this->info('Download of ' . $video->getTitle() . ' complete!');
+
+ return Command::SUCCESS;
+ }
+
+}