<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Podcast;

class PodcastSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $name = 'No Agenda';
        $description = 'No Agenda, a show where former VJ Adam Curry and columnist John C. Dvorak,
            two experts from the media industry, have a conversation about politics. Twice a week they
            deconstruct the news cycle and give insights into the narrative of the mainstream media,
            political campaigns and the government.';
        $website = 'https://noagendashow.net';
        $slug = 'no-agenda';
        $feed = 'http://feed.nashownotes.com/rss.xml';
        $added = '2007-10-26 15:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);

        $name = 'Nick the Rat';
        $description = 'A paranoid cartoon rat that plays music on a paranormal podcast. Also takes calls! 
            +19177195923';
        $website = 'http://nicktherat.com';
        $slug = 'nick-the-rat';
        $feed = 'http://nicktherat.com/radio/rss.xml';
        $added = '2017-01-31 20:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);

		$name = 'Podcasting 2.0';
        $description = 'The Podcast Index presents Podcasting 2.0 - Upgrading Podcasting';
        $website = 'http://podcastindex.org';
        $slug = 'podcasting-2-point-0';
        $feed = 'https://feeds.podcastindex.org/pc20.xml';
        $added = '2021-12-31 20:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);
		
		$name = 'Curry and the Keeper';
        $description = 'Tina and Adam Curry embarked on this podcast to talk about wine. Living in the heart of the 
            Hill Country, they set out to visit all the wineries and discuss their experiences. As life would have it, 
            the podcast evolved and now includes much more. Every show begins with opening a bottle of wine (it 
            usually has to “open up”) and then navigates to stories of their marriage, lives, faith and of course, 
            their dog, Phoebe. Join them on this journey as they laugh, live and love life.';
        $website = 'https://www.curryandthekeeper.com';
        $slug = 'curry-and-the-keeper';
        $feed = 'http://feed.nashownotes.com/catkrss.xml';
        $added = '2021-12-02 20:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);

        $name = 'That Larry Show';
        $description = 'Truth lives at That LARRY SHOW, a weekly sojourn at the crossroads of madness and enlightenment.
            With LARRY in your life, you\'ll Take No Sh*t, and laugh your way to victory.';
        $website = 'http://thatlarryshow.com/';
        $slug = 'that-larry-show';
        $feed = 'http://thatlarryshow.com/feed/podcast/';
        $added = '2016-12-13 20:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);

        $name = 'DH Unplugged';
        $description = 'DH Unplugged is a weekly discussion of news in the financial markets featuring columnist
            John C. Dvorak and money manager Andrew Horowitz.';
        $website = 'https://www.dhunplugged.com/';
        $slug = 'dh-unplugged';
        $feed = 'http://feeds2.feedburner.com/dhunplugged';
        $added = '2008-09-16 20:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);

        $name = 'Bowl After Bowl';
        $description = 'Bowl After Bowl is Sir Spencer and Dame DuhLaurien\'s weekly clothing-optional 
            potcast with a focus on drug law reform and community disorganizing.';
        $website = 'https://bowlafterbowl.com/';
        $slug = 'bowl-after-bowl';
        $feed = 'https://feed.podbean.com/bowlafterbowl/feed.xml';
        $added = '2014-12-20 20:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);

        $name = 'Randumb Thoughts';
        $description = 'Randumb Thoughts is an essay podcast by No Agenda producer Darren O’Neill.
            Life is a lot like taking candy from a gorilla';
        $website = 'http://randumbthoughts.com/';
        $slug = 'randumb-thoughts';
        $feed = 'http://randumbthoughts.com/index.php/feed/podcast/';
        $added = '2017-05-30 20:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);
		
		$name = 'Planet Rage';
		$description = 'Planet Rage is a podcast hosted by Larry Bleidner and Darren O’Neill.';
		$website = 'https://planetrage.show/';
		$slug = 'planet-rage';
		$feed = 'https://planetrage.show/feed/podcast/';
		$added = '2021-08-30 20:00:00';
		$this->createPodcast($name, $description, $website, $slug, $feed, $added);
		

        $name = 'OO Show';
        $description = 'The "Double O" hosted by RynoTheBearded playing the greatest Creative Commons hits.';
        $website = 'http://ryno.cc/';
        $slug = 'oo-show';
        $feed = 'http://rynothebearded.com/feed/podcast/';
        $added = '2012-11-11 20:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);
		
        $name = 'Hog Story';
        $description = 'Hog Story is simply a conversation between Carolyn Blaney and John Fletcher.  
            No topic is off limits.';
        $website = 'http://hogstory.net';
        $slug = 'hog-story';
        $feed = 'https://hogstory.net/feed/podcast';
        $added = '2019-02-22 20:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);

        $name = 'Rare Encounter';
        $description = 'AbleKirby and coldacid converse on anime they watch, books and manga they read, games they play, 
            and all the tech stuff that they come across.';
        $website = 'http://rareencounter.net';
        $slug = 'rare-encounter';
        $feed = 'https://rareencounter.net/external.php?name=RSS';
        $added = '2020-07-16 20:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);

        $name = 'Unrelenting';
        $description = 'The Unrelenting Podcast is hosted by Gene Naftulvev and Darren O’Neill. It covers politics, technology, pop-culture, and more!';
        $website = 'http://unrelenting.show';
        $slug = 'unrelenting';
        $feed = 'https://www.unrelenting.show/feed/podcast/';
        $added = '2021-10-29 20:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);

        $name = 'The Boostagram Ball';
        $description = 'The First Podcast with Value4Value Music hosted by Adam Curry';
        $website = 'https://boostagramball.com';
        $slug = 'boostagram-ball';
        $feed = 'https://mp3s.nashownotes.com/bballrss.xml';
        $added = '2023-07-29 20:00:00';
        $this->createPodcast($name, $description, $website, $slug, $feed, $added);            
    }

    private function createPodcast($name, $description, $website, $slug, $feed, $added) {
        $podcast = Podcast::where('name', $name)->first();
        if (!$podcast) {
            $podcast = Podcast::factory()->state([
                'name' => $name,
                'description' => preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $description)),
                'slug' => $slug,
                'website' => $website,
                'feed' => $feed,
                'published' => true,
                'added_at' => $added,

            ])->create();
            $this->command->info('Podcast: ' . $podcast->name 
                . ' added with the slug "' 
                . $podcast->slug 
                . '" and the id ' 
                . $podcast->id . '.');
        } else {
            $this->command->comment('Podcast: ' 
                . $podcast->name 
                . ' already exists with the slug "' 
                . $podcast->slug 
                . '" and the id ' 
                . $podcast->id . '.');
        }
    }

}
