Accesses to radiko API, gets media playlist URL and built header for HTTP request to its URL.
This is light weight library for interacting with radiko API to get informations to access to media playlist. We can find various useages by integrating with other libraries.
Following example requires additional installations:
import time
import ffmpeg
from radikoplaylist import MasterPlaylistClient, LiveMasterPlaylistRequest
master_playlist_request = LiveMasterPlaylistRequest("FMT")
master_playlist = MasterPlaylistClient.get(master_playlist_request, area_id="JP13")
stream = ffmpeg.input(
master_playlist.media_playlist_url,
headers=master_playlist.headers,
copytb='1'
)
stream = ffmpeg.output(stream, "./record.m4a", f='mp4', c='copy')
# @see https://github.com/kkroening/ffmpeg-python/issues/162#issuecomment-571820244
popen = stream.run_async(pipe_stdin=True)
recording_minute = 30
time.sleep(recording_minute * 60)
popen.communicate(str.encode("q"))
time.sleep(3)
popen.terminate()
import ffmpeg
from radikoplaylist import MasterPlaylistClient, TimeFreeMasterPlaylistRequest
master_playlist_request = TimeFreeMasterPlaylistRequest(
"NACK5", 20200529210000, 20200529230000
)
master_playlist = MasterPlaylistClient.get(master_playlist_request, area_id="JP13")
stream = ffmpeg.input(
master_playlist.media_playlist_url,
headers=master_playlist.headers,
copytb='1'
)
stream = ffmpeg.output(stream, "./record.m4a", f='mp4', c='copy')
ffmpeg.run(stream)