看到有大神分享了一个去水印下载的代码,源代码是PHP的。我简单读了一下,测试后其实很简单,这里简单记录一下,之后可以做一些东西。

获取视频ID

其实这一步很简单,如果是电脑上的浏览器访问的,地址栏最后就会包含这个ID。例如

https://www.douyin.com/video/7324602766213598501

最后面的一串数字就是这个视频的ID。

获取uri

通过API获取这个视频play_addruri地址。

https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?reflow_source=reflow_page&item_ids=7324602766213598501&a_bogus=64745b2b5bdc4e75b720a9a85b19867a

只需要替换上面链接中的item_ids=7324602766213598501这一项的数字就是视频ID。然后在返回的页面中可以看到很长一段json数据。格式化一下,更容易查看:

{
	"item_list": [{
		"aweme_id": "7324602766213598501",
		"desc": "#江西文旅 #庐山雪景  我来给我家乡江西上分啦!欢迎大家来九江庐山看雪呀~ 超级美!",
		"create_time": 1705391987,
		"author": {
			"short_id": "11491514",
			"nickname": "饭思思",
			"signature": "爱唱歌爱cos~\n来围脖找我玩呀:饭思思的微博\n合作邮箱:sisi2442@163.com\n唯一小号@万年婴儿肥",
			"avatar_thumb": {
				"uri": "100x100/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2",
				"url_list": ["https://p3.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172", "https://p11.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172", "https://p26.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172"]
			},
			"avatar_medium": {
				"uri": "100x100/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2",
				"url_list": ["https://p3.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172", "https://p11.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172", "https://p26.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172"]
			},
			"follow_status": 0,
			"following_count": 0,
			"favoriting_count": 0,
			"unique_id": "sisi2442",
			"mplatform_followers_count": 0,
			"followers_detail": null,
			"platform_sync_info": null,
			"geofencing": null,
			"policy_version": null,
			"sec_uid": "MS4wLjABAAAAOEQzC2nJjIS5Zq5QFgfRxxLKGODQj0Vvlz8gciLF8Tg",
			"type_label": null,
			"card_entries": null,
			"mix_info": null
		},
		"music": {
			"mid": "7324602840553409291",
			"title": "@饭思思创作的原声一饭思思(原声中的歌曲:此生不换-Qing Niao Fei Yu)",
			"author": "饭思思",
			"cover_hd": {
				"uri": "1080x1080/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2",
				"url_list": ["https://p11.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172", "https://p3.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172", "https://p6.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172"]
			},
			"cover_large": {
				"uri": "1080x1080/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2",
				"url_list": ["https://p11.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172", "https://p3.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172", "https://p6.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172"]
			},
			"cover_medium": {
				"uri": "720x720/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2",
				"url_list": ["https://p11.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172", "https://p3.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172", "https://p26.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2.jpeg?from=116350172"]
			},
			"cover_thumb": {
				"uri": "168x168/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2",
				"url_list": ["https://p11.douyinpic.com/img/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2~c5_168x168.jpeg?from=116350172", "https://p3.douyinpic.com/img/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2~c5_168x168.jpeg?from=116350172", "https://p26.douyinpic.com/img/aweme-avatar/tos-cn-avt-0015_31b2187fc176a131cb13a70cd0a840f2~c5_168x168.jpeg?from=116350172"]
			},
			"duration": 30,
			"position": null,
			"status": 1
		},
		"cha_list": null,
		"video": {
			"play_addr": {
				"uri": "v0200fg10000cmj3edbc77u6r20l0bg0",
				"url_list": ["https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200fg10000cmj3edbc77u6r20l0bg0\u0026ratio=720p\u0026line=0"]
			},
			"cover": {
				"uri": "tos-cn-i-0813/oQAAMUHgQBALifT2L35EYfK2sc7qKBAfPEG7At",
				"url_list": ["https://p3-sign.douyinpic.com/tos-cn-i-0813/oQAAMUHgQBALifT2L35EYfK2sc7qKBAfPEG7At~c5_300x400.webp?x-expires=1706662800\u0026x-signature=KDss1boVmMbpV9s1B7wXy6s0984%3D\u0026from=3213915784_large\u0026s=PackSourceEnum_DOUYIN_REFLOW\u0026se=false\u0026sc=cover\u0026biz_tag=aweme_video\u0026l=20240117093850F434F462C106845AC2B1", "https://p9-sign.douyinpic.com/tos-cn-i-0813/oQAAMUHgQBALifT2L35EYfK2sc7qKBAfPEG7At~c5_300x400.webp?x-expires=1706662800\u0026x-signature=Gm32fNnhaB%2BuHg%2FdYYtGDzaOTh8%3D\u0026from=3213915784_large\u0026s=PackSourceEnum_DOUYIN_REFLOW\u0026se=false\u0026sc=cover\u0026biz_tag=aweme_video\u0026l=20240117093850F434F462C106845AC2B1", "https://p26-sign.douyinpic.com/tos-cn-i-0813/oQAAMUHgQBALifT2L35EYfK2sc7qKBAfPEG7At~c5_300x400.webp?x-expires=1706662800\u0026x-signature=pRe9L5y22stsKjkV5kho%2BOHklXE%3D\u0026from=3213915784_large\u0026s=PackSourceEnum_DOUYIN_REFLOW\u0026se=false\u0026sc=cover\u0026biz_tag=aweme_video\u0026l=20240117093850F434F462C106845AC2B1", "https://p3-sign.douyinpic.com/tos-cn-i-0813/oQAAMUHgQBALifT2L35EYfK2sc7qKBAfPEG7At~c5_300x400.jpeg?x-expires=1706662800\u0026x-signature=cX7dhmiOZft%2BHL8bY0%2Btx%2BvziPg%3D\u0026from=3213915784_large\u0026s=PackSourceEnum_DOUYIN_REFLOW\u0026se=false\u0026sc=cover\u0026biz_tag=aweme_video\u0026l=20240117093850F434F462C106845AC2B1"]
			},
			"height": 1080,
			"width": 1920,
			"bit_rate": null
		},
		"statistics": {
			"aweme_id": "7324602766213598501",
			"comment_count": 4719,
			"digg_count": 70996,
			"play_count": 0,
			"share_count": 4648,
			"collect_count": 2021
		},
		"text_extra": [{
			"start": 0,
			"end": 5,
			"type": 1,
			"hashtag_name": "江西文旅",
			"hashtag_id": 1641348211717134
		}, {
			"start": 6,
			"end": 11,
			"type": 1,
			"hashtag_name": "庐山雪景",
			"hashtag_id": 1587012021222414
		}],
		"video_labels": null,
		"image_infos": null,
		"risk_infos": {
			"warn": false,
			"type": 0,
			"content": "",
			"reflow_unplayable": 0
		},
		"comment_list": null,
		"geofencing": null,
		"video_text": null,
		"label_top_text": null,
		"promotions": null,
		"long_video": null,
		"images": null,
		"group_id_str": "7317867723025960233",
		"chapter_list": null,
		"interaction_stickers": null,
		"img_bitrate": null
	}],
	"filter_list": [],
	"extra": {
		"now": 1705455530245,
		"logid": "20240117093850F434F462C106845AC2B1"
	},
	"status_code": 0
}

可以找到video里面play_addruri地址为v0200fg10000cmj3edbc77u6r20l0bg0

得到无水印视频链接

用上一步得到的uri地址,替换下面的${data.video.play_addr.uri}就可以了

https://www.iesdouyin.com/aweme/v1/play/?video_id=${data.video.play_addr.uri}&ratio=1080p&line=0

所以这个例子里面得到无水印视频下载地址为:

https://www.iesdouyin.com/aweme/v1/play/?video_id=v0200fg10000cmj3edbc77u6r20l0bg0&ratio=1080p&line=0

需要注意的是,这个uri地址是会变的,所以需要实时获取才有效。

参考链接

https://github.com/x-dr/douyin

❤️ 转载文章请注明出处,谢谢!❤️