How to Retrieve and Download Douyin Dynamic Wallpaper Videos Using mitmproxy and Python
This guide explains how to capture Douyin dynamic wallpaper video URLs with mitmproxy, extract MP4 links from the generated content.data file, deduplicate them, and download the videos using a Python script with requests and tqdm.
The article shows how to obtain the MP4 download links of Douyin (TikTok) dynamic wallpaper videos without writing a custom request simulator. First, install the Windows version of Douyin, start mitmweb , and open the wallpaper page; mitmproxy will display a request starting with https://www.douyin.com/aweme/v1/web/wallpaper/ . Clicking the "Download" button saves a content.data file that contains the video URLs.
Next, a Python script reads content.data , parses the JSON, removes entries with anchor_info , extracts the play_addr URL list, and uses the video_id to deduplicate identical videos. The script builds a dictionary of unique URLs and finally creates a list of download links.
<code>import json
url_list = []
url_dict = {}
with open('content.data', 'r', encoding='utf-8') as f:
x = json.load(f)
for i in x['aweme_list']:
if 'anchor_info' in i:
continue
else:
for i in i['video']['bit_rate']:
url = i['play_addr']['url_list'][2]
a = url.split('video_id=')[1].split('&line=')[0]
url_dict[a] = url
for k, v in url_dict.items():
url_list.append(v)
print(len(url_list))
print(url_list)
</code>After obtaining the list of MP4 URLs, another Python script downloads each video. It uses requests.get with streaming, shows a progress bar via tqdm , and saves the files under a videos directory.
<code>import os
import requests
from tqdm import tqdm
VIDEO_PATH = r'videos'
def download(url, fname):
resp = requests.get(url, stream=True, verify=False)
total = int(resp.headers.get('content-length', 0))
with open(fname, 'wb') as file, tqdm(desc=fname, total=total, unit='iB', unit_scale=True, unit_divisor=1024) as bar:
for data in resp.iter_content(chunk_size=1024):
size = file.write(data)
bar.update(size)
if __name__ == "__main__":
url_list = [
'https://www.douyin.com/aweme/v1/play/?video_id=v0d00fg10000cagm35rc77u3k4nb0430&line=0&file_id=fec3f8eeb45e48a18f30dfd96922f659&sign=4450c5609c69d0a5c1100e6801cf25dd&is_play_url=1&source=PackSourceEnum_AWEME_DETAIL',
# ... more URLs ...
]
for url in url_list:
video_name = url[47:67]
video_full_path = os.path.join(VIDEO_PATH, f"{video_name}.mp4")
download(url, video_full_path)
</code>Running the downloader fetches the dynamic wallpaper videos, which can then be set as desktop wallpapers, providing a visually appealing and constantly changing background.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.