Podcast のフィードを生成する PowerShell スクリプト
2???????USB ?????? AM/FM ????????????????????????????????? AM ???????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????Podcast ??????????????????????Podcast ????????????????????????????????????????? RSS ???????????????? Windows PowerShell ? Podcast ??????????????????????
?????
- ????????????????????
- Windows PowerShell (1.0 or 2.0)
- .NET Framework 3.5 ??
- IIS ??? Web ????
- Podcast ???????????????????????
????(?????)
- PowerShell ? RSS ???????????
????Podcast ????????????????????????????e:\radio ?????????????????
?????????????????Podcast ? RSS ????????????????
????????
- RSS ????????? .NET Framework ????????????????? .NET Framework 3.5 ?????????
- ?????????????????????????
System.ServiceModel.Syndication ??????????????????? - ?????????????$progs ??????????????????
- ??????????????????????????????????????????????????? RSS ????????????????????????????????(??????????????????????????????????)
[Reflection.Assembly]::LoadWithPartialName("System.ServiceModel.Web") |
Out-Null
$sss = "System.ServiceModel.Syndication."
$progs = @{
TitleE = "EIKAIWA"
TitleJ = "??????"
}, @{
TitleE = "CHARO"
TitleJ = "???"
}
$mp3dir = "E:\radio"
?? RSS ??????????System.ServiceModel.Syndication.SyndicationFeed ?????? $feed ???????????????????????????????????????????????$feed ??????????????
0..($progs.count-1) | foreach {
$feed = new-object ($sss + "SyndicationFeed")
$feed.LastUpdatedTime = [DateTimeOffset]::Now
$prog = $progs[$_]["TitleJ"]
$feed.Title = $prog
?????????????????????????????????
- $mp3dir ????????$prog ??????????????????????????????????????????????
- ??????? System.ServiceModel.Syndication.SyndicationItem ?????????????????????????
- ??????????????? (extension) ?????????????????????????????????????????????????
- ????????? (CreationTime) ????????????????
- System.ServiceModel.Syndication.TextSyndicationContent ???????????????????????????????
dir ("{0}\*{1}*" -f $mp3dir, $prog) | sort LastWriteTime -desc | `
foreach {
$title = ($_.name.replace($_.extension,""))
$item = new-object ($sss + "SyndicationItem")
$item.Title = $title
$item.PublishDate = $_.CreationTime
$item.Content = new-object ($sss + "TextSyndicationContent") $title
????? Podcast ?????????
- System.ServiceModel.Syndication.SyndicationLink ?????????????????????????????????? SyndicationItem ???????????????
- Podcast ??????????????????? URL ? $link.Uri ??????????????????????????????????? IIS ?????
https://localhost/podcast/????? ??????????????
$link = new-object System.ServiceModel.Syndication.SyndicationLink
$link.Uri = "https://localhost/podcast/{0}" -f $_.name
$link.Length = $_.length
$link.MediaType = "audio/mpeg"
$link.RelationshipType = "enclosure"
$item.Links.Add($link)
$feed.items.add($item)
}
??? Podcast ?? RSS ????????????????? $feed ????????????????????????????
- ?????RSS 2.0 ???????????
System.ServiceModel.Syndication.Rss20FeedFormatter ??????????? - ”??????”.xml ????????????????????????????????
$rssFormatter = new-object ($sss + "Rss20FeedFormatter") $feed
$rssFile = "{0}\{1}.xml" -f $mp3dir, $progs[$_]["TitleE"]
$rssWriter = [System.Xml.XmlWriter]::Create($rssFile)
$rssFormatter.WriteTo($rssWriter);
$rssWriter.close()
}
????? XML ???????????RSS ??????????
???????? XML ??????? Podcast ?????????????https://.. ???? URL ??????????????????????? IIS ????????????http(s) ?????????????????
- IIS ??????????????????????
- ?????????????????? $link.Uri???? XML ????? <enclosure> ??? URL ?????????????????
???????? XML ????? http(s) ????????????????????????????????
???? RSS ?????????????????????????????????????????????????????????(??????????????????????????????????????)
??????????????????????????? Podcast ????????????
iTunes ??????????? Podcast ? URL ?????????????
Winamp ???????????? > Podcast ?????? > ?????????????????(????????)
???????????????? Podcast ??????????????????????????????????????????????????????????????????????????????
????? Windows PowerShell ? .NET Framework ??????????30?????????? Podcast ????????????????????????????? XML ????????????Windows PowerShell ???????????
? ???????????????????????????????????????????????????????? System.ServiceModel.Syndication ??????????????????????