从 TRIAX TSS-400 通道列表生成 M3U 文件,用于其他软件,如 Kodi、VLC 等

问题描述

如何从 SAT-IP 接收器 TRIAX TSS-400 生成 M3U 文件? 在 SAT-Receiver 的 web-GUI 中,我只能导出一个 XML 文件,但不能在 kodi、VLC 等中导入。

解决方法

我最终编写了一个 Powershell 脚本,该脚本通过 UPnP 查找 TRIAX,自动登录并根据需要创建 M3U 文件。 这里的脚本:

# script to generate an M3U file from the TRIAX TSS-400 channel list to be used in other software like Kodi,VLC etc.

cls
$m3uFile = 'c:\temp\triax_channel_list.m3u'

write-host 'reading channel list from TRIAX TSS-400...'
$finder = New-Object -ComObject UPnP.UPnPDeviceFinder
$serverList = $finder.FindByType('urn:schemas-upnp-org:device:MediaServer:1',0)
$triax = $serverList | where {$_.ModelName -eq 'TSS400'}
$triaxIp = [regex]::Match($triax.PresentationURL,'(?<=//).*?(?=:)').value

$url = "http://$triaxIp/exportChannelList"
$response = Invoke-WebRequest -Uri $url
[xml]$xml = $response.ToString()

$m3u = [System.Collections.Generic.List[string]]::new()
$m3u.Add('#EXTM3U')
foreach($c in $xml.channelTable.channel) {
    $m3u.Add([string]::Concat('#EXTINF:-1,',$c.name))
    $m3u.Add([string]::Concat("http://$triaxIp/dlna/?type=DVB-S-AUTO&src=",$c.src,'&freq=',$c.freq,'&pol=',$c.pol,'&sr=',$c.sr,'&pids=',$c.pids))
}
$m3u | out-file $m3uFile -Force -Encoding utf8
write-host "file '$m3uFile' was generated."
'done.'