使用Powershell下载播客

本文介绍了一种使用PowerShell在Windows 7中快速下载播客的方法。作者分享了一个用时约5分钟编写的简单脚本,该脚本可以从RSS源下载所有播客。他还提到了PowerShell的其他功能,如远程处理和可视脚本编辑器,并提醒初次使用者需要调整执行策略以运行脚本。
摘要由CSDN通过智能技术生成

A number of people have mentioned to me that they didn't realize that Powershell is included by default in Windows 7. If you haven't yet jumped on the Powershell bandwagon, this is a good time. Powershell 2 includes a bunch of cool features like remoting (kind of like SSH) as well as a visual IDE for writing, editing and interactively debugging Powershell scripts.

许多人向我提到,他们没有意识到Windows 7中默认包含Powershell ,如果您还没有赶上Powershell潮流,那么现在是个好时机。 Powershell 2包括许多很酷的功能,例如远程处理(有点像SSH)以及用于编写,编辑和交互式调试Powershell脚本的可视IDE。

Windows PowerShell ISE (2)

Powershell great for system administration, but I mostly use it for quick and dirty "portable" apps that I don't feel like writing C#/VB for. Plus, I'm using .NET anyway, so it's all the same.

Powershell非常适合系统管理,但是我主要将它用于我不想为其编写C#/ VB的快速而又肮脏的“便携式”应用程序。 另外,无论如何我都在使用.NET,所以都一样。

I wanted to download all my podcasts with Powershell, so I wrote this quick script in about 5 minutes. Other improvements I (or preferably you) could make to it could be: check the file size against the enclosure and re-download partials, rename the files to included a version of the title, include a progress bar.

我想使用Powershell下载所有播客,所以我在大约5分钟的时间内编写了此快速脚本。 我(或最好是您)可以做的其他改进可能是:对照附件检查文件大小,然后重新下载部分文件,将文件重命名为包括标题的版本,包括进度条。

Here's what I came up with. Perhaps you'll find it useful if you're not an iTunes/Zune person:

这是我想出的。 如果您不是iTunes / Zune用户,也许您会发现它很有用:

cd "C:\users\scottha\desktop\Hanselminutes Complete Download"
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$a = ([xml](new-object net.webclient).downloadstring("http://feeds.feedburner.com/HanselminutesCompleteMP3"))
$a.rss.channel.item | foreach{
$url = New-Object System.Uri($_.enclosure.url)
$file = $url.Segments[-1]
$file
if (!(test-path $file))
{
(New-Object System.Net.WebClient).DownloadFile($url, $file)
}
}

Of course you'll want to change the first line and the RSS Feed URL as you like.

当然,您需要根据需要更改第一行和RSS Feed URL。

If you've never used Powershell before, note that it's locked down from running scripts be default. You'll need to run it as Administrator once and run

如果您以前从未使用过Powershell,请注意,默认情况下,它将无法运行脚本。 您需要以管理员身份运行一次并运行

Set-ExecutionPolicy unrestricted

This opens it up to run scripts, but it's not only VBS, the scripts won't run if you double-click them. You need to run powershell then type the name of your script to run it:

这将打开它来运行脚本,但不仅是VBS,如果双击它们,脚本将无法运行。 您需要运行powershell,然后键入脚本名称以运行它:

.\myscript.ps1

You can always set the execution policy back if it bothers you.

如果执行策略困扰您,您可以随时将其重新设置。

Hope this primitive mass podcast enclosure downloader is useful.

希望这个原始的大规模Podcast附件下载器有用。

翻译自: https://www.hanselman.com/blog/download-podcasts-with-powershell

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值