-
Notifications
You must be signed in to change notification settings - Fork 43
55 lines (48 loc) · 1.67 KB
/
M.yml
File metadata and controls
55 lines (48 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Merge M3U
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:
jobs:
merge-m3u:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Merge all M3U playlists
run: |
mkdir -p merged_tmp
echo -n > merged_tmp/combined-playlist.m3u
find . -type f -name "*.m3u" ! -path "./merged_tmp/*" ! -name "combined-playlist.m3u" | while read file; do
base=$(basename "$file" .m3u)
awk -v grp="$base" '
NR == 1 && $0 == "#EXTM3U" { next }
/^#EXTINF/ {
if ($0 ~ /group-title="/) {
sub(/group-title="[^"]*"/, "group-title=\"" grp "\"")
} else {
sub(/#EXTINF:/, "#EXTINF:-1 group-title=\"" grp "\",")
}
print
getline
print
next
}
{ print }
' "$file" >> merged_tmp/combined-playlist.m3u
done
sed -i '1i #EXTM3U' merged_tmp/combined-playlist.m3u
mv merged_tmp/combined-playlist.m3u combined-playlist.m3u
rm -rf merged_tmp
- name: Commit and push merged playlist
run: |
git config user.name "${{ secrets.GIT_U }}"
git config user.email "${{ secrets.GIT_E }}"
git add combined-playlist.m3u
if ! git diff --cached --quiet; then
git commit -m "Auto-merged m3u playlists $(date -u +"%Y-%m-%d %H:%M UTC")"
git pull --rebase --strategy-option=theirs origin main
git push origin main
else
echo "No changes to commit"
fi