我有一个非常简单的脚本,可以在包含我所有音乐的plex播放列表中查找歌曲,并根据现有的m3u文件创建plex播放列表:
#!/bin/bash
file=$(echo $1)
echo Doing "$file"
echo "-----"
echo "#EXTM3U" >> Plex/"$file"8
echo "#Written by WebTools for Plex" >> Plex/"$file"8
echo '#{"playlistType": "audio", "title": "Music", "leafCount": "13474", "content": null, "ServerID": "8854525f8d9eb2bac12228bb9ab2a6142eb933aa", "smart": "0"}' >> Plex/"$file"8
echo "#" >> Plex/"$file"8
echo "#" >> Plex/"$file"8
while read p ; do
if grep -q "$p" ~/Downloads/Music.m3u8; then
grep -B 2 "$p" ~/Downloads/Music.m3u8 >> Plex/"$file"8
else
echo "$p" not found.
echo "$p" >> "$file".notfound
fi
done < "$file"
echo "-----"
到目前为止,这已经可以处理约15个播放列表和约1500首歌曲,但是在新批次上运行时我得到了一些奇怪的输出。
有效的播放列表具有以下结构:
/home/shared/plex/Music/Video Game - PC/Cave Story/On To Grasstown.mp3
/home/shared/plex/Music/Video Game - PC/Cave Story/Eyes Of Flame (Boss Theme #2).mp3
/home/shared/plex/Music/Video Game - PC/Cave Story/Cave Story (Plantation Main Theme).mp3
结构不完全相同的新播放列表:
/home/shared/plex/Music/Liz Callaway/Anastasia/Once Upon A December.mp3
/home/shared/plex/Music/Liz Callaway/Anastasia/Journey To The Past.mp3
/home/shared/plex/Music/Phil Collins, 'N Sync/Tarzan/Trashin' The Camp.mp3
旧的播放列表没有任何未找到的条目,但是找不到新的每个条目,但它看起来像这样:
not found.d/plex/Music/Elton John/The Road To El Dorado/Queen Of Cities.mp3
not found.d/plex/Music/Mandy Moore & Zachary Levi/Tangled/I See The Light.mp3
not found.d/plex/Music/Randy Newman/Toy Story/You've Got A Friend In Me.mp3
我知道它以某种方式未达到grep,但输出不应将“ not found”放在“ shared”的中间
我能够成功将文件中的每一行grep到〜/ Downloads / Music.m3u8。肯定有事了。有什么想法吗?