Created
October 7, 2021 02:11
-
-
Save jwmoss/194fbcfc43b69a66f3a0f608f848bcad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Search-M3UFile { | |
[CmdletBinding()] | |
param ( | |
[string[]] | |
$Filter, | |
[string] | |
$Path | |
) | |
begin { | |
$preload = Get-Content $Path | |
$regex_filter = ($filter | ForEach-Object { | |
[regex]::escape($_) | |
} | |
) –join "|" | |
} | |
process { | |
## Preload the variable with said M3U content. | |
## Start loading the Arrays used to build the menu | |
$TSLinkArray = $preload | Select-String '^.*\.ts$' | |
$StreamData = $preload | Select-String '(?<=tvg-name=")[^"]+' | ForEach-Object { $_.Matches.Value } | |
$Group = $preload | Select-String '(?<=group-title=")[^"]+' | ForEach-Object { $_.Matches.Value } | |
## Setup Array for loading Menus Properly | |
$linkdata = if ($TSLinkArray.count -eq $StreamData.count) { | |
for ($i = 1; $i -le $StreamData.count; $i++) { | |
[pscustomobject]@{ | |
StreamLink = $TSLinkArray[$i] | |
StreamData = $StreamData[$i] | |
Group = $Group[$i] | |
} | |
} | |
} | |
$linkdata | | |
Where-Object {$PSItem.StreamData -match $regex_filter} | |
} | |
End { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment