Skip to content

Instantly share code, notes, and snippets.

@Bigous
Last active January 8, 2022 00:14
Show Gist options
  • Save Bigous/b557866869b4eb562f11ca11f48443be to your computer and use it in GitHub Desktop.
Save Bigous/b557866869b4eb562f11ca11f48443be to your computer and use it in GitHub Desktop.
PowerShell to filter m3u HD tv only
Select-String .\file.m3u -Context 0,1 -Pattern "^(#EXTINF:.*\bHD$)|(#EXTM3U)|(#EXT-X-SESSION-DATA)" |
foreach {
$_.Line
if($_.Line -match "^#EXTINF:.*\bHD$") { $_.Context.PostContext[0] }
} > .\file_hd.m3u
@Bigous
Copy link
Author

Bigous commented Jan 8, 2022

Second implementation:

Select-String .\file.m3u -Context 0,1 -Pattern "^(#EXTINF:.*\bHD$)|(#EXTM3U)|(#EXT-X-SESSION-DATA)" | 
  foreach {
    $_.Line
    if($_.Line -match "^#EXTINF:.*\bHD$") { $_.Context.PostContext[0] }
  } > .\file_hd.m3u

It takes ~480 ms on a file with ~200000 lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment