{{ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" | htmlUnescape | safeHTML }}
<rss version="2.0"
     xmlns:podcast="https://podcastindex.org/namespace/1.0"
     xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
     xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:sy="https://purl.org/rss/1.0/modules/syndication/"
     xmlns:content="https://purl.org/rss/1.0/modules/content/"
     xmlns:dc="https://purl.org/dc/elements/1.1/"
    >
  <channel>
    <title>{{ $.Site.Title }}</title>
    <atom:link href="{{ "interview/index.xml" | absURL }}" rel="self" type="application/rss+xml" />
    <link>{{ .Site.BaseURL }}</link>
    <description>{{ .Site.Params.feed.itunes_summary | truncate 4000 ""}}</description>
    <lastBuildDate>{{ dateFormat "Mon, 2 Jan 2006 15:04:05 -0700" .Date }}</lastBuildDate>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <language>{{ .Site.Params.feed.language | default .Site.LanguageCode }}</language>
    <copyright>{{ .Site.Params.feed.copyright }}</copyright>
    {{ with .Site.Params.feed.itunes_subtitle }}<itunes:subtitle>{{ . }}</itunes:subtitle>{{ end }}
    <itunes:author>{{ .Site.Params.feed.itunes_author }}</itunes:author>
    <itunes:type>episodic</itunes:type>
    <googleplay:author>{{ .Site.Params.feed.itunes_author }}</googleplay:author>
    <googleplay:email>{{ .Site.Params.feed.itunes_owner_email }}</googleplay:email>
    <itunes:summary>{{ .Site.Params.feed.itunes_summary | truncate 4000 ""}}</itunes:summary>
    <googleplay:description>{{ .Site.Params.feed.itunes_summary | truncate 4000 ""}}</googleplay:description>
    <itunes:owner>
      <itunes:name>{{ .Site.Params.feed.itunes_owner_name }}</itunes:name>
      <itunes:email>{{ .Site.Params.feed.itunes_owner_email }}</itunes:email>
    </itunes:owner>
    <itunes:image href="{{ .Site.Params.feed.itunes_image }}" />
    <googleplay:image href="{{ .Site.Params.feed.itunes_image }}"></googleplay:image>
    <image>
      <url>{{ .Site.Params.feed.itunes_image }}</url>
      <title>{{ $.Site.Title }}</title>
      <link>{{ .Site.BaseURL }}</link>
    </image>
    <itunes:category text="{{ .Site.Params.feed.itunes_top_category }}">
      {{ with .Site.Params.feed.itunes_first_sub_category -}}
      <itunes:category text="{{ . }}" />
      {{- end -}}
      {{- with .Site.Params.feed.itunes_second_sub_category -}}
      <itunes:category text="{{ . }}" />
      {{- end -}}
    </itunes:category>
    {{- if isset .Site.Params.feed "explicit" -}}
    <itunes:explicit>{{ .Site.Params.feed.explicit }}</itunes:explicit>
    <googleplay:explicit>{{ .Site.Params.feed.explicit }}</googleplay:explicit>
    {{- end -}}
    <generator>Hugo -- gohugo.io</generator>
    {{- range (where ( where .Site.Pages "Type" "interview") ".Params.upcoming" "!=" true) -}}
      {{ if isset .Params "podcast_file" }}
        <item>          
          {{ if and (isset .Site.Params "episode_number_style") (.Params.episode) }}
            {{ if eq .Site.Params.episode_number_style "parens" }}
              <title>{{ title .Title }} ({{ with .Site.Params.episode_number_prefix }}{{ . }}{{ end }}{{ .Params.episode }})</title>
            {{ else if eq .Site.Params.episode_number_style "brackets" }}
              <title>{{ title .Title }} [{{ with .Site.Params.episode_number_prefix }}{{ . }}{{ end }}{{ .Params.episode }}]</title>
            {{ else if eq .Site.Params.episode_number_style "dash" }}
              <title>{{ title .Title }} - {{ with .Site.Params.episode_number_prefix }}{{ . }}{{ end }}{{ .Params.episode }}</title>
            {{ else }}
              <title>{{ title .Title }}</title>
            {{ end }}
          {{ else }}
            <title>{{ title .Title }}</title>
          {{ end }}
          <link>{{ .Permalink }}</link>
          <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} </pubDate>
          <dc:creator>{{ .Site.Params.itunes_author }}</dc:creator>
          <guid>{{- if isset .Params "guid" -}}{{ .Params.guid }}{{- else -}}{{ .Site.Params.media_prefix }}{{ .Params.podcast_file }}{{- end -}}</guid>
          <itunes:author>
          {{- if isset .Params "hosts" -}}
            {{ $hosts := (.Params.hosts) }}
            {{ $len := (len $hosts) }}
            {{ range $index, $element := $hosts }}
              {{ range where (where $.Site.Pages "Type" "contributor" ) ".File.BaseFileName" "=" . }}
                {{- if eq $len 1 -}}
                  {{ .Title }}
                {{- else -}}
                  {{- if eq (add $index 1) $len }}
                    and {{ .Title }}
                  {{- else -}}
                    {{- if eq $len 2 -}}
                      {{ printf "%s " .Title }}
                    {{- else -}}
                      {{ printf "%s, " .Title }}
                    {{- end -}}
                  {{- end -}}
                {{- end -}}
              {{ end }}
            {{- end -}}
          {{- else -}}
            {{ .Site.Params.feed.itunes_author }}
          {{- end -}}
          </itunes:author>
          {{ with .Params.episode }}
          <itunes:episode>{{ . }}</itunes:episode>
          {{ end }}
        <itunes:title>{{ title .Title }}</itunes:title>
        {{"<itunes:subtitle><![CDATA[" | safeHTML }}
        {{ with .Params.subtitle }}
        {{ . | plainify | truncate 243 "..." }}
        {{ else }}
        {{ .Description | plainify | truncate 243 "..." }}
        {{ end }}
        {{"]]></itunes:subtitle>" | safeHTML}}
        <itunes:summary>{{  (.Description | markdownify | plainify) }}</itunes:summary>
        <description>{{ .Description  | markdownify | plainify  }}</description>
        <googleplay:description>{{ .Description  | markdownify | plainify }}</googleplay:description>
        {{ "<content:encoded><![CDATA[" | safeHTML }}{{ .Content | safeHTML }}{{"]]></content:encoded>" | safeHTML}}
          {{- with .Params.episode_image -}}
          <itunes:image href="{{ . | absURL }}"></itunes:image>
          <googleplay:image href="{{ . | absURL }}"></googleplay:image>
          {{- end -}}
          <enclosure url="{{ .Site.Params.media_prefix }}{{ .Params.podcast_file }}" {{with .Params.podcast_bytes}}length="{{ . }}"{{ end }} type="audio/mpeg" />
          {{- with .Params.podcast_duration -}}<itunes:duration>{{ . }}</itunes:duration>{{- end -}}
          {{- with .Params.explicit -}}
          <itunes:explicit>{{ if (or (eq . "yes") (eq . "true")) }}true{{ else }}false{{ end }}</itunes:explicit>
          <googleplay:explicit>{{ if (or (eq . "yes") (eq . "true")) }}yes{{ else }}no{{ end }}</googleplay:explicit>
          {{- end -}}
        </item>
      {{- end -}}
    {{- end -}}
  </channel>
</rss>
