Last active
November 10, 2024 20:12
-
-
Save djanix/7cd01e40d42b6fd4f01ece099809b8e4 to your computer and use it in GitHub Desktop.
Filter m3u playlist
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
#!/bin/bash | |
url="http://sample.com" | |
inputFile="input.m3u" | |
outputFileChannels="output-channels.m3u" | |
outputFileMovies="output-movies.m3u" | |
outputFileSeries="output-series.m3u" | |
lineCount=1 | |
previousLine='' | |
regexFilter="NHL\sNETWORK|(\|(EN|US|CA)\|)" | |
#curl -o $inputFile "$url" | |
echo "#EXTM3U" >$outputFileChannels | |
echo "#EXTM3U" >$outputFileMovies | |
echo "#EXTM3U" >$outputFileSeries | |
while read -r p; do | |
if [[ $p =~ ^http ]] && [[ $previousLine =~ $regexFilter ]]; then | |
if [[ $p =~ \/movie\/ ]]; then | |
echo "$previousLine" >> $outputFileMovies | |
echo "$p" >> $outputFileMovies | |
elif [[ $p =~ \/series\/ ]]; then | |
echo "$previousLine" >> $outputFileSeries | |
echo "$p" >> $outputFileSeries | |
else | |
echo "$previousLine" >> $outputFileChannels | |
echo "$p" >> $outputFileChannels | |
fi | |
fi | |
previousLine=$p | |
((lineCount++)) | |
done <$inputFile | |
vlc $outputFileChannels |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment