@@ -96,7 +96,7 @@ function parseRss(feedUrl: string, rss: Record<string, unknown>): ValidationResu
9696 title : title || "Untitled RSS Feed" ,
9797 description : stringValue ( channel . description ) ,
9898 homepageUrl : linkValue ( channel . link ) ,
99- kind : detectRssKind ( channel ) ,
99+ kind : detectRssKind ( channel , items ) ,
100100 language : stringValue ( channel . language ) ,
101101 imageUrl : imageValue ( channel . image ) ,
102102 lastPublishedAt : newestDate ( [ stringValue ( channel . lastBuildDate ) , stringValue ( channel . pubDate ) , ...sampleItems . map ( ( item ) => item . publishedAt ) ] ) ,
@@ -132,10 +132,21 @@ function parseAtom(feedUrl: string, feed: Record<string, unknown>): ValidationRe
132132 } ;
133133}
134134
135- function detectRssKind ( channel : Record < string , unknown > ) : FeedKind {
135+ function detectRssKind ( channel : Record < string , unknown > , items : Record < string , unknown > [ ] ) : FeedKind {
136136 if ( channel . itunes || channel [ "itunes:author" ] || channel . enclosure ) {
137137 return "podcast" ;
138138 }
139+ const hasMediaEnclosure = items . some ( ( item ) =>
140+ asArray ( item . enclosure )
141+ . filter ( isRecord )
142+ . some ( ( enclosure ) => {
143+ const type = stringValue ( enclosure . type ) ?. toLowerCase ( ) ;
144+ return type ?. startsWith ( "audio/" ) || type ?. startsWith ( "video/" ) ;
145+ } )
146+ ) ;
147+ if ( hasMediaEnclosure ) {
148+ return "podcast" ;
149+ }
139150 return "blog" ;
140151}
141152
0 commit comments