The repository contains a collection of tools for downloading archived programs of subscribed channels on Fresh!.
Fresh! is a Japanese live streaming platform which delivers programs in HTTP Live Streaming. It protects paid contents by HLS encryption with keys (EXT-X-KEY
) that are further encrypted with user tokens in a custom algorithm.
- first retrieve_encryption_key_uri.rb to get the encrypted key of a paid program,
- and decrypt_key_with_appjs.js to decrypt the key,
- finally make a ffmpeg-friendly m3u8 by customize_playlist.rb.
It also comes with a simple run.sh for downloading a program, and could possibly explain the usage contexts for the above tools. (The script could be outdated if the site get updated in the future.)
- shell commands (sh, sed, grep)
- ruby
- node
- ffmpeg (if need downloading)
tested on macOS High Sierra.
Checkout the codes first,
git clone https://github.com/Adios/freshlive_tv_helper
And then setup the modules for node,
npm install
Finally the gems with Bundler,
bundle --standalone
Before starting, you should obtain two URLs from the program page,
- Log into Fresh!
- Browse to an archieved paid program you want to download, e.g.: https://freshlive.tv/uchidamaaya/191012. (Note that you must be a subscriber for that channel in order to get the required information.)
- Open developer tool, find the link to the archive.m3u8 with a token included, it looks like this:
https://movie.freshlive.tv/manifest/191012/archive.m3u8?token=NNNNNNtNNNNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&version=2&beta4k=
- app.js, at which the site stores the custom secret, e.g.:
https://freshlive.tv/assets/1524096831/app.js
Let us first get the encrypted encryption key of that program from the archive.m3u8 ,
bin/retrieve_encryption_key_uri.rb \
'https://movie.freshlive.tv/manifest/191012/archive.m3u8?token=NNNNNNtNNNNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&version=2&beta4k='
You would see the result string like this,
abemafresh://abemafresh/NNNNNNtNNNNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/0de7c2f47df5b6a559fbdeff5341363a
Acutually it's the URI value of the m3u8's EXT-X-KEY
field. However ffmpeg is unable to recognize the meaning since it is further encrypted with Fresh!'s algorithm. That's why you can't ffmpeg -i m3u8 -c copy
without pain.
Now let us decrypt the string with the secret stored at app.js
bin/decrypt_key_with_appjs.js \
'abemafresh://abemafresh/NNNNNNtNNNNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/0de7c2f47df5b6a559fbdeff5341363a' \
'https://freshlive.tv/assets/1524096831/app.js' > program.key
Congratulations! You obtain the real encryption key program.key which should be a 16-bytes binary file. And we then make a new playlist from archive.m3u8 with the real encryption key:
bin/customize_playlist.rb \
'https://movie.freshlive.tv/manifest/191012/archive.m3u8?token=NNNNNNtNNNNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&version=2&beta4k=' \
program.key > program.m3u8
And finally download it with ffmpeg:
ffmpeg -allowed_extensions ALL \
-protocol_whitelist 'crypto+https,file,crypto,https,tls,tcp' \
-i program.m3u8 -codec copy program.ts
Could also see https://adios.github.io/freshlive_tv_helper/how-to-download-programs.
- Log in, browser to program page, e.g.: https://freshlive.tv/uchidamaaya/191012.
- Open developer tool, look for
?token=NNNNNNtNNNNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
to get your token. - run.sh it.
./run.sh 'NNNNNNtNNNNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' 'https://freshlive.tv/uchidamaaya/191012'
- Adios - Initial work - Adios