#author("2022-04-12T01:16:21+09:00","default:nobuoki","nobuoki")
#author("2022-04-12T01:26:11+09:00","default:nobuoki","nobuoki")
* 手抜き版 [#k928f8e9]

** ワンライナー [#gd0605e4]

[[fmstream>http://fmstream.org/]] で afn を検索した結果を編集します
AFNP(AFN Pacific)のほか、AFNE(AFN Europe)、AFN(Pacific/Europe Eagle以外)も取得出来ます

#prism(bash){{{
$ curl -sSL 'http://fmstream.org/index.php?s=afn' | grep -oE "[^']+AFN[^']+\.(mp3|aac)" | sed 's/\\//g; s#^#http://#'
}}}

** 出力例 [#e0b75706]
#pre{{{
http://20723.live.streamtheworld.com/AFNE_VIC.mp3
http://20723.live.streamtheworld.com:3690/AFNE_VIC.mp3
http://23603.live.streamtheworld.com/AFNE_VIC.mp3
http://23603.live.streamtheworld.com:3690/AFNE_VIC.mp3
http://25533.live.streamtheworld.com/AFNE_VIC.mp3
http://25533.live.streamtheworld.com:3690/AFNE_VIC.mp3
http://25583.live.streamtheworld.com:3690/AFNE_VICAAC.aac
http://20853.live.streamtheworld.com/AFNE_VICAAC.aac
http://20853.live.streamtheworld.com:3690/AFNE_VICAAC.aac
http://20423.live.streamtheworld.com/AFNE_VICAAC.aac
...
}}}

* 地道に取得する版 [#s4e5b1cb]

以前のバージョン [[sh/ネタ/AFN配信URL_v1]] をベースに、最近のURL変更に対応させたものです
3690/tcp や .aac は除外しています

** ワンライナー [#la313db9]

$ curl -sSL http://nakkara.cocolog-nifty.com/nakkara/2021/04/post-1d1379.html | grep -oE '[A-Z][a-zA-Z ]+=AFN.?_[A-Z]+' | sed 's/ /_/g;s/=/ /' | while read -r station id; do echo "curl -sSL 'https://playerservices.streamtheworld.com/api/livestream?station=$id&version=1.8' | xmlstarlet sel -N x=http://provisioning.streamtheworld.com/player/livestream-1.8 -t -m '//x:port[text()=80]' -v @type -o :// -v ../../x:ip -o '/$id.mp3' -n"; done | parallel

** 出力例 [#s734908f]
#pre{{{
http://25583.live.streamtheworld.com/AFNP_SBO.mp3
http://20853.live.streamtheworld.com/AFNP_SBO.mp3
...
http://18723.live.streamtheworld.com/AFNP_SBO.mp3
http://19803.live.streamtheworld.com/AFNP_CSY.mp3
http://18393.live.streamtheworld.com/AFNP_CSY.mp3
...
}}}

* 解説 [#v296f9c4]

** [[AFN 360の配信URL一覧の取得: ∵なっから∴今日のラヂヲ>http://nakkara.cocolog-nifty.com/nakkara/2021/04/post-1d1379.html]] からステーションIDを取得 [#sebdc8f0]

以前の [[AFN 360 Internet Radio>https://www.afnpacific.net/afn-360/]] はURL変更により使えなくなりました。。。

#prism(bash){{{
curl -sSL http://nakkara.cocolog-nifty.com/nakkara/2021/04/post-1d1379.html |
grep -oE '[A-Z][a-zA-Z ]+=AFN.?_[A-Z]+' |
sed 's/ /_/g;s/=/ /' |
}}}

最後の sed で後続の read の準備をしています
  使用前 station(空白含む)=id
  使用後 station(アンダースコアつなぎ)[半角空白]id

** ステーションID毎に配信サーバ情報を取得するコマンドを生成し、parallel で並列処理 [#ycdee338]

#prism(bash){{{
while read -r station id; do
  echo "配信サーバ情報のxmlを取得し、パースするコマンド";
done | parallel
}}}

** 前述「配信サーバ情報のxmlを取得し、パースするコマンド」 [#kbb398ad]

#prism(bash){{{
curl -sSL 'https://playerservices.streamtheworld.com/api/livestream?station=$id&version=1.8' |
xmlstarlet sel \
  -N x=http://provisioning.streamtheworld.com/player/livestream-1.8 \
  -t \
  -m '//x:port[text()=80]' \
  -v @type -o :// -v ../../x:ip -o '/$id.mp3' -n
}}}

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS