抖音無水印視訊解析思路

s發表於2020-09-08

本文前半部分是分析過程,只看思路的為節省時間建議直接拉到末尾。
本文寫於2020年9月8日,不保證此方法在以後的有效性。

分析過程

首先從抖音客戶端找一個視訊,點選分享-複製連結,貼上一下發到電腦上,準備進行下一步,這裡已經準備好了一個從客戶端得到的分享文字。

聽說集齊碎片可以召喚神龍!#家鄉變成二次元 #充能計劃 #畫畫 #夏日打卡挑戰 https://v.douyin.com/Jj8eXXu/ 複製此連結,開啟【抖音短視訊】,直接觀看視訊!

把其中的連結貼上到瀏覽器中訪問一下,得到了這樣的介面:

同時,位址列中的連結變成了:

https://www.iesdouyin.com/share/video/6855476646057643272/?region=CN&mid=6855476868364192519&u_code=1l1346c029b7&titleType=title&utm_source=copy_link&utm_campaign=client_share&utm_medium=android&app=aweme

可見其發生了重定向。

F12審查一下播放區域:

發現這個時候播放區域只有一張背景圖片和一個播放按鈕,點選一下播放試試:

多了一個video標籤,其中的src屬性的值就是視訊的url,所以大膽猜測一下,這個播放地址可能是通過ajax請求得到的。

切換到Network皮膚,點選xhr,再重新整理一下頁面,果然有一個ajax請求,這個ajax請求帶有一個item_ids的引數,其值應該為視訊的id,可以在頁面重定向後的url中找到這個id:

響應結果是一個json字串,複製到編輯器中格式化後如下:

{
    "extra": {
        "now": 1599467301000,
        "logid": "202009071628210101980651031208C5C1"
    },
    "status_code": 0,
    "item_list": [
        {
            "video_labels": null,
            "label_top_text": null,
            "long_video": null,
            "category": 103,
            "aweme_id": "6855476646057643272",
            "desc": "聽說集齊碎片可以召喚神龍!#家鄉變成二次元 #充能計劃 #畫畫 #夏日打卡挑戰",
            "video_text": null,
            "forward_id": "0",
            "mix_info": {
                "statis": {
                    "collect_vv": 0,
                    "current_episode": 35,
                    "updated_to_episode": 35,
                    "play_vv": 0
                },
                "desc": "原創不易,不喜勿噴~",
                "extra": "{\"first_reviewed\":1,\"is_quality_mix\":0,\"next_info\":{\"cover\":\"tos-cn-i-0813/57a48d47c61142748748802d08a75570\",\"desc\":\"原創不易,不喜勿噴~\",\"name\":\"家鄉變成二次元\"}}",
                "create_time": 1596724793,
                "mix_id": "6857880767423318030",
                "cover_url": {
                    "uri": "tos-cn-i-0813/57a48d47c61142748748802d08a75570",
                    "url_list": [
                        "https://p6-dy-ipv6.byteimg.com/obj/tos-cn-i-0813/57a48d47c61142748748802d08a75570?from=2563711402",
                        "https://p1-dy-ipv6.byteimg.com/obj/tos-cn-i-0813/57a48d47c61142748748802d08a75570?from=2563711402",
                        "https://p26-dy.byteimg.com/obj/tos-cn-i-0813/57a48d47c61142748748802d08a75570?from=2563711402"
                    ]
                },
                "status": {
                    "status": 2,
                    "is_collected": 0
                },
                "next_info": {
                    "mix_name": "家鄉變成二次元",
                    "desc": "原創不易,不喜勿噴~",
                    "cover_url": {
                        "uri": "tos-cn-i-0813/57a48d47c61142748748802d08a75570",
                        "url_list": [
                            "https://p1-dy.bytecdn.cn/obj/tos-cn-i-0813/57a48d47c61142748748802d08a75570",
                            "https://p3-dy.bytecdn.cn/obj/tos-cn-i-0813/57a48d47c61142748748802d08a75570",
                            "https://p9-dy.bytecdn.cn/obj/tos-cn-i-0813/57a48d47c61142748748802d08a75570"
                        ]
                    }
                },
                "mix_name": "家鄉變成二次元"
            },
            "music": {
                "status": 1,
                "id": 6855476868364193000,
                "mid": "6855476868364192519",
                "cover_hd": {
                    "url_list": [
                        "https://p26-dy.byteimg.com/aweme/1080x1080/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p6-dy-ipv6.byteimg.com/aweme/1080x1080/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p3-dy-ipv6.byteimg.com/aweme/1080x1080/317ca0000ef155aeac0be.jpeg?from=4010531038"
                    ],
                    "uri": "317ca0000ef155aeac0be"
                },
                "cover_large": {
                    "url_list": [
                        "https://p26-dy.byteimg.com/aweme/1080x1080/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p6-dy-ipv6.byteimg.com/aweme/1080x1080/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p3-dy-ipv6.byteimg.com/aweme/1080x1080/317ca0000ef155aeac0be.jpeg?from=4010531038"
                    ],
                    "uri": "317ca0000ef155aeac0be"
                },
                "play_url": {
                    "uri": "http://p9-dy.byteimg.com/obj/ies-music/6855476835380480781.mp3",
                    "url_list": [
                        "http://p9-dy.byteimg.com/obj/ies-music/6855476835380480781.mp3",
                        "http://p1-dy.byteimg.com/obj/ies-music/6855476835380480781.mp3"
                    ]
                },
                "duration": 135,
                "position": null,
                "title": "@不自由畫師團糰子創作的原聲",
                "author": "不自由畫師團糰子",
                "cover_medium": {
                    "uri": "317ca0000ef155aeac0be",
                    "url_list": [
                        "https://p29-dy.byteimg.com/aweme/720x720/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p1-dy-ipv6.byteimg.com/aweme/720x720/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p9-dy.byteimg.com/aweme/720x720/317ca0000ef155aeac0be.jpeg?from=4010531038"
                    ]
                },
                "cover_thumb": {
                    "uri": "317ca0000ef155aeac0be",
                    "url_list": [
                        "https://p3-dy-ipv6.byteimg.com/aweme/100x100/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p9-dy.byteimg.com/aweme/100x100/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p29-dy.byteimg.com/aweme/100x100/317ca0000ef155aeac0be.jpeg?from=4010531038"
                    ]
                }
            },
            "author_user_id": 71884871098,
            "share_info": {
                "share_weibo_desc": "#在抖音,記錄美好生活#聽說集齊碎片可以召喚神龍!#家鄉變成二次元 #充能計劃 #畫畫 #夏日打卡挑戰",
                "share_desc": "在抖音,記錄美好生活",
                "share_title": "聽說集齊碎片可以召喚神龍!#家鄉變成二次元 #充能計劃 #畫畫 #夏日打卡挑戰"
            },
            "promotions": null,
            "is_preview": 0,
            "group_id": 6855476646057643000,
            "video": {
                "origin_cover": {
                    "uri": "tos-cn-p-0015/ac5c4e77f7c441359a656c68c86926e4_1596165086",
                    "url_list": [
                        "https://p3-dy-ipv6.byteimg.com/tos-cn-p-0015/ac5c4e77f7c441359a656c68c86926e4_1596165086~tplv-dy-360p.jpeg?from=2563711402",
                        "https://p6-dy-ipv6.byteimg.com/tos-cn-p-0015/ac5c4e77f7c441359a656c68c86926e4_1596165086~tplv-dy-360p.jpeg?from=2563711402",
                        "https://p26-dy.byteimg.com/tos-cn-p-0015/ac5c4e77f7c441359a656c68c86926e4_1596165086~tplv-dy-360p.jpeg?from=2563711402"
                    ]
                },
                "ratio": "540p",
                "has_watermark": true,
                "bit_rate": null,
                "duration": 135302,
                "is_long_video": 1,
                "width": 720,
                "cover": {
                    "uri": "tos-cn-p-0015/b98b9cb496be4379bcb8e283f38f1c9e",
                    "url_list": [
                        "https://p6-dy-ipv6.byteimg.com/img/tos-cn-p-0015/b98b9cb496be4379bcb8e283f38f1c9e~c5_300x400.jpeg?from=2563711402_large",
                        "https://p3-dy-ipv6.byteimg.com/img/tos-cn-p-0015/b98b9cb496be4379bcb8e283f38f1c9e~c5_300x400.jpeg?from=2563711402_large",
                        "https://p9-dy.byteimg.com/img/tos-cn-p-0015/b98b9cb496be4379bcb8e283f38f1c9e~c5_300x400.jpeg?from=2563711402_large"
                    ]
                },
                "height": 1280,
                "dynamic_cover": {
                    "url_list": [
                        "https://p3-dy-ipv6.byteimg.com/obj/tos-cn-p-0015/11e5f3dcb62749a6848a14c01c556f66_1596165086?from=2563711402_large",
                        "https://p29-dy.byteimg.com/obj/tos-cn-p-0015/11e5f3dcb62749a6848a14c01c556f66_1596165086?from=2563711402_large",
                        "https://p9-dy.byteimg.com/obj/tos-cn-p-0015/11e5f3dcb62749a6848a14c01c556f66_1596165086?from=2563711402_large"
                    ],
                    "uri": "tos-cn-p-0015/11e5f3dcb62749a6848a14c01c556f66_1596165086"
                },
                "vid": "v0200fda0000bshokcp94bbr1103bot0",
                "play_addr": {
                    "uri": "v0200fda0000bshokcp94bbr1103bot0",
                    "url_list": [
                        "https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200fda0000bshokcp94bbr1103bot0&ratio=720p&line=0"
                    ]
                }
            },
            "share_url": "https://www.iesdouyin.com/share/video/6855476646057643272/?region=&mid=6855476868364192519&u_code=48&titleType=title",
            "aweme_type": 4,
            "image_infos": null,
            "geofencing": null,
            "is_live_replay": false,
            "create_time": 1596165084,
            "duration": 135302,
            "comment_list": null,
            "cha_list": [
                {
                    "is_commerce": false,
                    "cid": "1670532508858382",
                    "desc": "",
                    "connect_music": null,
                    "view_count": 0,
                    "hash_tag_profile": "",
                    "cha_name": "家鄉變成二次元",
                    "user_count": 0,
                    "type": 1
                }
            ],
            "risk_infos": {
                "warn": false,
                "type": 0,
                "content": ""
            },
            "text_extra": [
                {
                    "hashtag_id": 1670532508858382,
                    "start": 13,
                    "end": 21,
                    "type": 1,
                    "hashtag_name": "家鄉變成二次元"
                },
                {
                    "start": 22,
                    "end": 27,
                    "type": 1,
                    "hashtag_name": "充能計劃",
                    "hashtag_id": 1655868948754440
                },
                {
                    "start": 28,
                    "end": 31,
                    "type": 1,
                    "hashtag_name": "畫畫",
                    "hashtag_id": 1553508302124033
                },
                {
                    "start": 32,
                    "end": 39,
                    "type": 1,
                    "hashtag_name": "夏日打卡挑戰",
                    "hashtag_id": 1673117213997070
                }
            ],
            "author": {
                "policy_version": null,
                "uid": "71884871098",
                "short_id": "612124342",
                "signature": "沉迷二次元無法自拔的小姐姐(老阿姨)\n面對骨感的現實,依然滿懷希望的走在實現夢想的路上\n————漸行漸遠……(畫風越來越不對了…)",
                "avatar_thumb": {
                    "uri": "317ca0000ef155aeac0be",
                    "url_list": [
                        "https://p3-dy-ipv6.byteimg.com/aweme/100x100/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p9-dy.byteimg.com/aweme/100x100/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p29-dy.byteimg.com/aweme/100x100/317ca0000ef155aeac0be.jpeg?from=4010531038"
                    ]
                },
                "unique_id": "",
                "platform_sync_info": null,
                "nickname": "不自由畫師團糰子",
                "avatar_larger": {
                    "uri": "317ca0000ef155aeac0be",
                    "url_list": [
                        "https://p1-dy-ipv6.byteimg.com/aweme/1080x1080/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p9-dy.byteimg.com/aweme/1080x1080/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p6-dy-ipv6.byteimg.com/aweme/1080x1080/317ca0000ef155aeac0be.jpeg?from=4010531038"
                    ]
                },
                "avatar_medium": {
                    "uri": "317ca0000ef155aeac0be",
                    "url_list": [
                        "https://p6-dy-ipv6.byteimg.com/aweme/720x720/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p29-dy.byteimg.com/aweme/720x720/317ca0000ef155aeac0be.jpeg?from=4010531038",
                        "https://p3-dy-ipv6.byteimg.com/aweme/720x720/317ca0000ef155aeac0be.jpeg?from=4010531038"
                    ]
                },
                "followers_detail": null,
                "geofencing": null,
                "type_label": null
            },
            "statistics": {
                "aweme_id": "6855476646057643272",
                "comment_count": 6598,
                "digg_count": 74803,
                "play_count": 0
            }
        }
    ],
    "ab_type": 1
}

資訊還是蠻豐富的,作者資訊、視訊資訊、音樂資訊、封面資訊等一應俱全,視訊的地址是在item_list下video.play_addr.url_list中,複製下這個地址用瀏覽器訪問一下果然得到了視訊:

不過這個視訊還是帶水印的,如何獲得沒有水印的視訊呢,來看看從json字串中得到的視訊地址:

https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200fda0000bshokcp94bbr1103bot0&ratio=720p&line=0

覺不覺得這個playwm中的wm是water mask的簡寫呢,把wm刪掉再訪問一下試試。即:

https://aweme.snssdk.com/aweme/v1/play/?video_id=v0200fda0000bshokcp94bbr1103bot0&ratio=720p&line=0

結果一片空白,是不是這樣行不通呢,不應該啊,不然直接寫play多好,何必又搞個playwm呢,一定是訪問姿勢有問題,點選左上角的裝置切換按鈕切換到移動端訪問一下,哇,amazing,竟然真的訪問到了!

同時可以看到原本左上角的抖音水印消失了。成功!

思路總結

  1. 訪問客戶端分享文字中的連結,從重定向後的url中提取視訊id,https://www.iesdouyin.com/share/video/後的數字就是視訊id。
  2. 訪問https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=視訊id獲取有關該視訊的json字串。
  3. 從得到的json字串中提取視訊播放地址,在item_list下video.play_addr.url_list中。
  4. 將視訊地址中的playwm替換為play。
  5. 使用移動端的user-agent訪問替換後的視訊地址即可得到無抖音水印的視訊。

個人已使用node.js寫了一個抖音無水印視訊的解析庫,併發布在了npm和github上,詳情請訪問:

npm:https://www.npmjs.com/package/douyin_video

github:https://github.com/xyz-studio/Douyin_Video

相關文章