mirror of
https://github.com/junguler/m3u-radio-music-playlists.git
synced 2024-11-11 01:10:27 +00:00
92f6b5ce4a
this was initially meant as a way of removing dead links but from a few tests i've made they were not that many to remove and the time it took was not worth it, i'm willing to apply this script if you have found a folder that has an unusal amount of dead links in it but otherwise this will just sit here not being used
16 lines
770 B
Bash
Executable File
16 lines
770 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# replace spaces in files with an underline
|
|
for i in *.m3u ; do sed -i 's/ /_/g' $i ; done
|
|
|
|
# check for none 200 response coded links
|
|
for i in *.m3u ; do for j in $(cat $i) ; do wget -S --spider -q -t 1 --max-redirect 0 $j 2>&1 | grep "HTTP/" | awk '{print $2}' | (cat ; echo $j ;) | paste -s -d " " >> A-$i ; echo -e "$i - $j" ; done ; done
|
|
|
|
# find links that have 200 response code and remove others
|
|
for i in A-*.m3u ; do cat $i | grep -B1 "200 " | sed -e 's/200 //g' -e 's/_/ /g' | awk 'length>3' | grep -A1 "#" | sed 's/ , /,/g' > A$i ; done
|
|
|
|
# remove extra fluff from file names
|
|
for i in AA-*.m3u ; do mv $i $(echo $i | sed 's/AA-//') ; done
|
|
|
|
# make the m3u files proper again by adding the header
|
|
for i in *.m3u ; do sed -i '1s/^/#EXTM3U\n/' $i ; done |