Note on Extracting Audio from Moji Weather

I’ve been wanting to add scheduled weather forecast to my music alarm clock, but I’m lazy. Having a daily scheduled weather report would be great. I came across the voice forecast feature on Moji Weather and thought it would be interesting to extract the audio through an API. Surprisingly, it turned out to be much simpler than I imagined.(English version Translated by GPT-3.5, 返回中文)

Before We Begin

This article simply documents the process I went through. There’s no guarantee that the API will be maintained for a long time, nor that this method will remain effective. So, please be aware of the publishing date before proceeding.

Capturing Packets with Charles

Without further ado, I used Charles to capture the packets. After setting it up on my iPad, I opened Moji Weather and clicked on the voice broadcast. Charles displayed the following information:

charles-total-detail

After removing unnecessary requests, it looked like this:

charles-detail

Wow, this was too easy. The necessary information was clear at a glance…and it turns out it was an HTTP API…

Listening to the Audio

Here are the contents of these MP3 files:

file content
good_afternoon_zh_1.mp3 Good afternoon
bg_rainy_heavy.mp3 Background music with thunder
day2night_zh_1.mp3 From today daytime to nighttime
23_zh_1.mp3 Twenty-three
temperature_zh_1.mp3 Temperature
today_zh_1.mp3 Today

The complete voice should be:

1
下午好, 墨迹天气为您播报, 杭州, 今天白天到夜间, 大雨转小雨, 温度 20-23摄氏度, 东风3-4级, 今天不限行

It turns out that Moji Weather uses segmented audio, with many audio files being played back together. “bg_rainy” serves as the background music. Since the API is minimal, we can directly look at the most valuable http://v1.weather.moji.com/weather/pb/detail.

Obtaining the Audio

The content of detail is shown in the image below, and we can see the important content.

charles-detail-content

But what is the black garbled text? I still couldn’t figure it out… However, the MP3 files in between are quite noticeable, and we can see that almost everything we need is there. Upon listening, these contents are:

fileName content
bg_rainy_heavy.mp3 Music with rain sound
bg_end.mp3 Ending part of the music
blank_new.mp3 2 seconds of blank audio
{bless}_zh_1.mp3 Good afternoon, the “bless” is replaced by “good_morning”, “afternoon”, “evening”
now_is_zh_1.mp3 Now is
{time}# Unknown
hello_moji_zh_1.mp3 Moji Weather presents
city_143_zh_2.mp3 Hangzhou
day2night_zh_1.mp3 From today daytime to nighttime
heavy_rain_zh_1.mp3 Heavy rain
transfer_zh_1.mp3 to
light_rain_zh_1.mp3 Light rain
temperature_zh_1.mp3 Temperature
20_zh_1.mp3 Twenty
to_zh_1.mp3 to
23_zh_1.mp3 Twenty-three
centigrade_zh_1.mp3 degrees Celsius
e_zh_1.mp3 east wind
3_zh_1.mp3 three
to_zh_1.mp3 to
4_zh_1.mp3 four
level_zh_1.mp3 level
today_zh_1.mp3 Today
no_limit_zh_1.mp3 No traffic restrictions

Perfect! The next step is to handle this detail. Let me give you the conclusion…to be honest…the token and identifier inside it are useless… you can simply remove them to make the request…

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
最后请求结果: 

POST: http://v1.weather.moji.com/weather/pb/detail
{
"common": {
"mcc": "xxx",
"app_version": "app版本",
"width": 0,
"net": "wifi",
"mnc": "XXX",
"platform": "iPad",
"language": "CN",
"height": 0,
"os_version": "系统版本",
"pid": "9000",
"device": "iPad型号"
},
"params": {
"city": [
{
"id": 143,
"ts": "此刻时间",
"avatarId": "2",
"cr": 1
}
],
"lang": "CN",
"tu": "c",
"wu": "beau",
"sst": 0
}
}

My idea is to match or extract the files to download, save them locally, then use the “ffmpeg -i “concat:xxxx”” command to merge them into a single file, add background music, and finally output the final file.

Here’s the final result:

Conclusion

To be honest, I didn’t expect it to be so quick and easy. I hope this API can last for a while. I’m going to include it in my daily weather report, playing it once in the morning before going to work.

Backup of All Downloaded Audio Files

The files starting with “city” are a bunch of place names and basically include almost all the audio. Even creating a personalized voice broadcast is not difficult. However, this is likely copyrighted material, so please use it for your own research and learning purposes, but not for commercial use.

mojiAudio_2020.zip - RuterFu My Storage