抖音视频去水印接口分析 | 附API接口源码(2022-12-24更新)

抖音视频去水印接口分析 | 附API接口源码(2022-12-24更新)

在线体验

视频去水印流程

前端:通过Vue提取文案中的URL链接

首先在前端过滤抖音口令,只保留URL链接部分

譬如我们复制链接,拿到的口令如下

6.64 odn:/ 复制打开抖音,看看【KvKv的作品】昨天是黑暗风今天是糖果风~# 人像写真 # 美出高... https://v.douyin.com/hG1p4Gr/

我们只需要URL链接

https://v.douyin.com/hG1p4Gr/

在我们vue的代码中,输入框按钮

<el-input placeholder="请粘贴分享链接" v-model="input" id="url" lass="input-with-select">

然后核心的JS部分,通过正则判断只保留输入的URL链接即可

const url = /http[s]?:\/\/[\w.]+[\w/]*[\w.]*\??[\w=&:\-+%]*[/]*/.exec(this.input)

后端:做好解析接口

已经从前端拿到了URL,由于这些链接是进行过缩短的,故我们需要先对链接进行访问

https://v.douyin.com/hG1p4Gr/

访问后发现链接变成了

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

我们可以通过video后面的数字来获取视频ID

7180278615983049996

然后我们需要对抖音的接口进行分析,之前的版本使用的是V2接口,我们将视频ID传入即可

https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=

但现在我们发现V2接口貌似对权限做了限制,故已经拿不到数据了,所以我们寻找一些之前的旧版接口,我们发现之前的V1接口居然还可以使用!

https://www.iesdouyin.com/aweme/v1/web/aweme/detail/?aweme_id=

然后我们对接口进行测试,输入我们刚才找的视频ID

https://www.iesdouyin.com/aweme/v1/web/aweme/detail/?aweme_id=7180278615983049996

发现可以拿到JSON内容

{
    "aweme_detail": {
        "anchors": null,
        "author": {
            "avatar_thumb": {
                "height": 720,
                "uri": "100x100/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22",
                "url_list": [
                    "https://p6.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p11.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p3.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172"
                ],
                "width": 720
            },
            "cf_list": null,
            "close_friend_type": 0,
            "contacts_status": 1,
            "contrail_list": null,
            "cover_url": [
                {
                    "height": 720,
                    "uri": "c8510002be9a3a61aad2",
                    "url_list": [
                        "https://p26-sign.douyinpic.com/obj/c8510002be9a3a61aad2?x-expires=1673082000\u0026x-signature=26dM5yh81WUkBtzytncs1Zj8PW8%3D\u0026from=116350172",
                        "https://p96-sign.douyinpic.com/obj/c8510002be9a3a61aad2?x-expires=1673082000\u0026x-signature=5jZu8%2BnF9IlCJZmZFI9Q9eJ12e8%3D\u0026from=116350172",
                        "https://p3-sign.douyinpic.com/obj/c8510002be9a3a61aad2?x-expires=1673082000\u0026x-signature=jrHdLIzP9zGrWb8KbMulxFoFCY0%3D\u0026from=116350172"
                    ],
                    "width": 720
                }
            ],
            "create_time": 0,
            "custom_verify": "",
            "data_label_list": null,
            "endorsement_info_list": null,
            "enterprise_verify_reason": "",
            "favoriting_count": 357,
            "follow_status": 0,
            "follower_count": 0,
            "follower_list_secondary_information_struct": null,
            "follower_status": 0,
            "following_count": 0,
            "im_role_ids": null,
            "is_ad_fake": false,
            "is_blocked_v2": false,
            "is_blocking_v2": false,
            "is_cf": 0,
            "max_follower_count": 0,
            "nickname": "三三七七",
            "not_seen_item_id_list": null,
            "not_seen_item_id_list_v2": null,
            "offline_info_list": null,
            "personal_tag_list": null,
            "prevent_download": false,
            "risk_notice_text": "",
            "sec_uid": "MS4wLjABAAAAGoRj-ReKWaJE3QFZqI4ykAwKBE80DdZkRAoLUGMZ6rC_8rMWwNquB4B1FbKc8Ful",
            "secret": 0,
            "share_info": {
                "share_desc": "",
                "share_desc_info": "",
                "share_qrcode_url": {
                    "height": 720,
                    "uri": "31b2100072df1acc3499f",
                    "url_list": [
                        "https://p96-sign.douyinpic.com/obj/31b2100072df1acc3499f?x-expires=1671894000\u0026x-signature=LP43QzOQ1GvdI%2FT4HU2oAvzXC4U%3D\u0026from=116350172",
                        "https://p3-sign.douyinpic.com/obj/31b2100072df1acc3499f?x-expires=1671894000\u0026x-signature=5jwaAkZ6BtrE8zsRXwsZdlU0zJg%3D\u0026from=116350172",
                        "https://p9-sign.douyinpic.com/obj/31b2100072df1acc3499f?x-expires=1671894000\u0026x-signature=Owx5o5P2fW84Aj6dZMcDySDuRHk%3D\u0026from=116350172"
                    ],
                    "width": 720
                },
                "share_title": "",
                "share_title_myself": "",
                "share_title_other": "",
                "share_url": "",
                "share_weibo_desc": ""
            },
            "short_id": "3834542499",
            "signature": "自用好物放橱窗了\n未经允许🈲️搬运\n三月:(哥哥)曼基康 不爱喵 粘人\n小七:(妹妹)高地 碎嘴子 \n宝宝:(女儿)抱抱 超级黏人",
            "signature_extra": null,
            "special_people_labels": null,
            "status": 1,
            "text_extra": null,
            "total_favorited": 2770121,
            "uid": "2515291808738012",
            "unique_id": "ssisme3377",
            "user_age": -1,
            "user_canceled": false,
            "user_permissions": null,
            "verification_type": 1
        },
        "author_mask_tag": 0,
        "author_user_id": 2515291808738012,
        "aweme_control": {
            "can_comment": true,
            "can_forward": true,
            "can_share": true,
            "can_show_comment": true
        },
        "aweme_id": "7175398411020029218",
        "aweme_type": 0,
        "challenge_position": null,
        "chapter_list": null,
        "collect_stat": 0,
        "comment_gid": 7175398411020029218,
        "comment_list": null,
        "comment_permission_info": {
            "can_comment": true,
            "comment_permission_status": 0,
            "item_detail_entry": false,
            "press_entry": false,
            "toast_guide": false
        },
        "commerce_config_data": null,
        "common_bar_info": "[]",
        "component_info_v2": "{\"desc_lines_limit\":0,\"hide_marquee\":false}",
        "cover_labels": null,
        "create_time": 1670652638,
        "desc": "小小年纪就不听妈妈管了 #小奶猫的成长日记",
        "digg_lottie": {
            "can_bomb": 0,
            "lottie_id": ""
        },
        "disable_relation_bar": 0,
        "dislike_dimension_list": null,
        "duet_aggregate_in_music_tab": false,
        "duration": 49967,
        "geofencing": [],
        "geofencing_regions": null,
        "group_id": "7175398411020029218",
        "hybrid_label": null,
        "image_album_music_info": {
            "begin_time": -1,
            "end_time": -1,
            "volume": -1
        },
        "image_infos": null,
        "image_list": null,
        "images": null,
        "img_bitrate": null,
        "impression_data": {
            "group_id_list_a": [
                7175398411020029218
            ],
            "group_id_list_b": [
                7175398411020029218
            ],
            "similar_id_list_a": null,
            "similar_id_list_b": null
        },
        "interaction_stickers": null,
        "is_ads": false,
        "is_collects_selected": 0,
        "is_duet_sing": false,
        "is_image_beat": false,
        "is_life_item": false,
        "is_story": 0,
        "is_top": 0,
        "item_warn_notification": {
            "content": "",
            "show": false,
            "type": 0
        },
        "label_top_text": null,
        "long_video": null,
        "music": {
            "album": "",
            "artist_user_infos": null,
            "artists": [],
            "audition_duration": 49,
            "author": "三三七七",
            "author_deleted": false,
            "author_position": null,
            "author_status": 1,
            "avatar_large": {
                "height": 720,
                "uri": "1080x1080/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22",
                "url_list": [
                    "https://p11.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p3.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p26.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172"
                ],
                "width": 720
            },
            "avatar_medium": {
                "height": 720,
                "uri": "720x720/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22",
                "url_list": [
                    "https://p6.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p26.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p3.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172"
                ],
                "width": 720
            },
            "avatar_thumb": {
                "height": 720,
                "uri": "100x100/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22",
                "url_list": [
                    "https://p6.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p26.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p11.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172"
                ],
                "width": 720
            },
            "binded_challenge_id": 0,
            "can_background_play": true,
            "collect_stat": 0,
            "cover_hd": {
                "height": 720,
                "uri": "1080x1080/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22",
                "url_list": [
                    "https://p11.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p3.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p26.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172"
                ],
                "width": 720
            },
            "cover_large": {
                "height": 720,
                "uri": "1080x1080/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22",
                "url_list": [
                    "https://p11.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p3.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p26.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172"
                ],
                "width": 720
            },
            "cover_medium": {
                "height": 720,
                "uri": "720x720/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22",
                "url_list": [
                    "https://p6.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p26.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p3.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172"
                ],
                "width": 720
            },
            "cover_thumb": {
                "height": 720,
                "uri": "100x100/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22",
                "url_list": [
                    "https://p6.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p26.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172",
                    "https://p11.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_d92ca6a5c25fa015ea34bbb9491d9e22.jpeg?from=116350172"
                ],
                "width": 720
            },
            "dmv_auto_show": false,
            "dsp_status": 10,
            "duration": 49,
            "end_time": 0,
            "external_song_info": [],
            "extra": "{\"hotsoon_review_time\":-1,\"music_tagging\":{\"Languages\":[\"non_vocal\"],\"Moods\":[\"Happy\"],\"Genres\":[\"Childhood\"],\"Themes\":null,\"AEDs\":[\"non_vocal\"],\"SingingVersions\":null,\"Instruments\":null},\"is_red\":0,\"is_subsidy_exp\":false,\"extract_item_id\":7175398411020029218,\"has_edited\":0,\"douyin_beats_info\":{},\"review_unshelve_reason\":0,\"beats\":{},\"cover_colors\":null,\"music_label_id\":null,\"is_aed_music\":1,\"with_aed_model\":1,\"dsp_switch\":0,\"reviewed\":0,\"schedule_search_time\":0,\"aggregate_exempt_conf\":[]}",
            "id": 7175398444192893756,
            "id_str": "7175398444192893756",
            "is_audio_url_with_cookie": false,
            "is_commerce_music": false,
            "is_del_video": false,
            "is_matched_metadata": false,
            "is_original": false,
            "is_original_sound": true,
            "is_pgc": false,
            "is_restricted": false,
            "is_video_self_see": false,
            "luna_info": {
                "is_luna_user": false
            },
            "lyric_short_position": null,
            "mid": "7175398444192893756",
            "music_chart_ranks": null,
            "music_status": 1,
            "musician_user_infos": null,
            "mute_share": false,
            "offline_desc": "",
            "owner_handle": "ssisme3377",
            "owner_id": "2515291808738012",
            "owner_nickname": "三三七七",
            "pgc_music_type": 2,
            "play_url": {
                "height": 720,
                "uri": "https://sf3-cdn-tos.douyinstatic.com/obj/ies-music/7175398442968140602.mp3",
                "url_key": "7175398444192893756",
                "url_list": [
                    "https://sf3-cdn-tos.douyinstatic.com/obj/ies-music/7175398442968140602.mp3",
                    "https://sf6-cdn-tos.douyinstatic.com/obj/ies-music/7175398442968140602.mp3"
                ],
                "width": 720
            },
            "position": null,
            "prevent_download": false,
            "prevent_item_download_status": 0,
            "preview_end_time": 0,
            "preview_start_time": 0,
            "reason_type": 0,
            "redirect": false,
            "schema_url": "",
            "search_impr": {
                "entity_id": "7175398444192893756"
            },
            "sec_uid": "MS4wLjABAAAAGoRj-ReKWaJE3QFZqI4ykAwKBE80DdZkRAoLUGMZ6rC_8rMWwNquB4B1FbKc8Ful",
            "shoot_duration": 49,
            "source_platform": 23,
            "start_time": 0,
            "status": 1,
            "tag_list": null,
            "title": "@三三七七创作的原声",
            "unshelve_countries": null,
            "user_count": 0,
            "video_duration": 49
        },
        "nickname_position": null,
        "origin_comment_ids": null,
        "origin_text_extra": [],
        "original_images": null,
        "packed_clips": null,
        "photo_search_entrance": {
            "ecom_type": 0
        },
        "position": null,
        "preview_title": "小小年纪就不听妈妈管了 #小奶猫的成长日记",
        "preview_video_status": 1,
        "promotions": [],
        "rate": 12,
        "region": "CN",
        "relation_labels": null,
        "search_impr": {
            "entity_id": "7175398411020029218",
            "entity_type": "GENERAL"
        },
        "series_paid_info": {
            "item_price": 0,
            "series_paid_status": 0
        },
        "share_info": {
            "share_desc": "在抖音,记录美好生活",
            "share_desc_info": "#在抖音,记录美好生活#小小年纪就不听妈妈管了 #小奶猫的成长日记",
            "share_link_desc": "6.69 lcA:/ 小小年纪就不听妈妈管了 # 小奶猫的成长日记  %s 复制此链接,打开Dou音搜索,直接观看视频!",
            "share_url": "https://www.iesdouyin.com/share/video/7175398411020029218/?region=CN\u0026mid=7175398444192893756\u0026u_code=-1\u0026titleType=title\u0026from_ssr=1"
        },
        "share_url": "https://www.iesdouyin.com/share/video/7175398411020029218/?region=CN\u0026mid=7175398444192893756\u0026u_code=-1\u0026titleType=title\u0026from_ssr=1",
        "should_open_ad_report": false,
        "show_follow_button": {},
        "social_tag_list": null,
        "standard_bar_info_list": null,
        "statistics": {
            "admire_count": 0,
            "aweme_id": "7175398411020029218",
            "collect_count": 1224,
            "comment_count": 1398,
            "digg_count": 21334,
            "play_count": 0,
            "share_count": 5952
        },
        "status": {
            "allow_share": true,
            "aweme_id": "7175398411020029218",
            "in_reviewing": false,
            "is_delete": false,
            "is_prohibited": false,
            "listen_video_status": 0,
            "part_see": 0,
            "private_status": 0,
            "review_result": {
                "review_status": 0
            }
        },
        "text_extra": [
            {
                "end": 21,
                "hashtag_id": "1610528685419587",
                "hashtag_name": "小奶猫的成长日记",
                "is_commerce": false,
                "start": 12,
                "type": 1
            }
        ],
        "uniqid_position": null,
        "user_digged": 0,
        "video": {
            "big_thumbs": [
                {
                    "duration": 49.938333,
                    "fext": "jpg",
                    "img_num": 50,
                    "img_url": "http://p3-sign.douyinpic.com/tos-cn-p-0015/a1fa7d62b4c44577af603e102bd7c120_1670652905~tplv-noop.image?x-expires=1671876275\u0026x-signature=5Gq5kUThRyFkL2fZTaUyZQ7vAEQ%3D",
                    "img_x_len": 10,
                    "img_x_size": 240,
                    "img_y_len": 5,
                    "img_y_size": 136,
                    "interval": 1,
                    "uri": "tos-cn-p-0015/a1fa7d62b4c44577af603e102bd7c120_1670652905"
                }
            ],
            "bit_rate": [
                {
                    "FPS": 30,
                    "HDR_bit": "",
                    "HDR_type": "",
                    "bit_rate": 1295000,
                    "gear_name": "adapt_540_0",
                    "is_bytevc1": 0,
                    "is_h265": 0,
                    "play_addr": {
                        "data_size": 8088575,
                        "file_cs": "c:0-55447-fab9",
                        "file_hash": "f77c605df1a75e84463fc94deadfd118",
                        "height": 576,
                        "uri": "v0d00fg10000cea259rc77u7stdoiv4g",
                        "url_key": "v0d00fg10000cea259rc77u7stdoiv4g_h264_540p_1295000",
                        "url_list": [
                            "http://v26-default.365yg.com/93663bb958aaecd9ef58311964e3b465/63a6ceb3/video/tos/cn/tos-cn-ve-15/o4nSIJe5trNnYfIUAQnAUKlP9zjgRBqAHCDcbs/?a=0\u0026ch=26\u0026cr=0\u0026dr=0\u0026lr=all\u0026cd=0%7C0%7C0%7C0\u0026cv=1\u0026br=1264\u0026bt=1264\u0026cs=0\u0026ds=6\u0026ft=4zenzjjM9-px8Zq8ZmCM5y7EkcADPce.NLrkbJ4LZmoagl\u0026mime_type=video_mp4\u0026qs=11\u0026rc=M2g7Z2Q7NTM2aGZmZ2ZmZ0Bpanlydzo6Zjw1aDMzNGkzM0BfNS00Xi5gNS4xNjZjNS1iYSMxZmFwcjRvMl5gLS1kLWFzcw%3D%3D\u0026l=2022122417034654FC0D15D92ACC62E253\u0026btag=20000",
                            "http://v9-default.365yg.com/e9b420f57a3b579a7740a0868d052a96/63a6ceb3/video/tos/cn/tos-cn-ve-15/o4nSIJe5trNnYfIUAQnAUKlP9zjgRBqAHCDcbs/?a=0\u0026ch=26\u0026cr=0\u0026dr=0\u0026lr=all\u0026cd=0%7C0%7C0%7C0\u0026cv=1\u0026br=1264\u0026bt=1264\u0026cs=0\u0026ds=6\u0026ft=4zenzjjM9-px8Zq8ZmCM5y7EkcADPce.NLrkbJ4LZmoagl\u0026mime_type=video_mp4\u0026qs=11\u0026rc=M2g7Z2Q7NTM2aGZmZ2ZmZ0Bpanlydzo6Zjw1aDMzNGkzM0BfNS00Xi5gNS4xNjZjNS1iYSMxZmFwcjRvMl5gLS1kLWFzcw%3D%3D\u0026l=2022122417034654FC0D15D92ACC62E253\u0026btag=20000",
                            "https://api.amemv.com/aweme/v1/play/?video_id=v0d00fg10000cea259rc77u7stdoiv4g\u0026line=0\u0026file_id=ed0c8cfd9c9c4e1380c218aa7d088eb0\u0026sign=f77c605df1a75e84463fc94deadfd118\u0026is_play_url=1\u0026source=PackSourceEnum_AWEME_DETAIL",
                            "https://api5-normal-dsa.amemv.com/aweme/v1/play/?video_id=v0d00fg10000cea259rc77u7stdoiv4g\u0026line=1\u0026file_id=ed0c8cfd9c9c4e1380c218aa7d088eb0\u0026sign=f77c605df1a75e84463fc94deadfd118\u0026is_play_url=1\u0026source=PackSourceEnum_AWEME_DETAIL"
                        ],
                        "width": 1024
                    },
                    "quality_type": 28
                },
                {
                    "FPS": 30,
                    "HDR_bit": "",
                    "HDR_type": "",
                    "bit_rate": 1190000,
                    "gear_name": "normal_540_0",
                    "is_bytevc1": 0,
                    "is_h265": 0,
                    "play_addr": {
                        "data_size": 7432596,
                        "file_cs": "c:0-55506-1ae5",
                        "file_hash": "2419cd6de5e33edd8ea56b1fc769b59c",
                        "height": 576,
                        "uri": "v0d00fg10000cea259rc77u7stdoiv4g",
                        "url_key": "v0d00fg10000cea259rc77u7stdoiv4g_h264_540p_1190000",
                        "url_list": [
                            "http://v26-default.365yg.com/552d0f4992c36f5d16f7b5fddb1e3aef/63a6ceb3/video/tos/cn/tos-cn-ve-15/owfU9CJwjINHAFAPIBleZqKDUcnQzrASngbX7r/?a=0\u0026ch=26\u0026cr=0\u0026dr=0\u0026lr=all\u0026cd=0%7C0%7C0%7C0\u0026cv=1\u0026br=1162\u0026bt=1162\u0026cs=0\u0026ds=6\u0026ft=4zenzjjM9-px8Zq8ZmCM5y7EkcADPce.NLrkbJ4LZmoagl\u0026mime_type=video_mp4\u0026qs=0\u0026rc=OzhnNWdmMzY1ODY3ODdlZUBpanlydzo6Zjw1aDMzNGkzM0AzYTUvYmNfNWAxXjQ2NC8uYSMxZmFwcjRvMl5gLS1kLWFzcw%3D%3D\u0026l=2022122417034654FC0D15D92ACC62E253\u0026btag=20000",
                            "http://v9-default.365yg.com/bc3f7d1fd219e2429d46c75df858e961/63a6ceb3/video/tos/cn/tos-cn-ve-15/owfU9CJwjINHAFAPIBleZqKDUcnQzrASngbX7r/?a=0\u0026ch=26\u0026cr=0\u0026dr=0\u0026lr=all\u0026cd=0%7C0%7C0%7C0\u0026cv=1\u0026br=1162\u0026bt=1162\u0026cs=0\u0026ds=6\u0026ft=4zenzjjM9-px8Zq8ZmCM5y7EkcADPce.NLrkbJ4LZmoagl\u0026mime_type=video_mp4\u0026qs=0\u0026rc=OzhnNWdmMzY1ODY3ODdlZUBpanlydzo6Zjw1aDMzNGkzM0AzYTUvYmNfNWAxXjQ2NC8uYSMxZmFwcjRvMl5gLS1kLWFzcw%3D%3D\u0026l=2022122417034654FC0D15D92ACC62E253\u0026btag=20000",
                            "https://api.amemv.com/aweme/v1/play/?video_id=v0d00fg10000cea259rc77u7stdoiv4g\u0026line=0\u0026file_id=1b2b749574a345c283b0fced228dd568\u0026sign=2419cd6de5e33edd8ea56b1fc769b59c\u0026is_play_url=1\u0026source=PackSourceEnum_AWEME_DETAIL",
                            "https://api5-normal-dsa.amemv.com/aweme/v1/play/?video_id=v0d00fg10000cea259rc77u7stdoiv4g\u0026line=1\u0026file_id=1b2b749574a345c283b0fced228dd568\u0026sign=2419cd6de5e33edd8ea56b1fc769b59c\u0026is_play_url=1\u0026source=PackSourceEnum_AWEME_DETAIL"
                        ],
                        "width": 1024
                    },
                    "quality_type": 20
                },
                {
                    "FPS": 30,
                    "HDR_bit": "",
                    "HDR_type": "",
                    "bit_rate": 1065969,
                    "gear_name": "adapt_lower_540_0",
                    "is_bytevc1": 0,
                    "is_h265": 0,
                    "play_addr": {
                        "data_size": 6658046,
                        "file_cs": "c:0-55446-bce0",
                        "file_hash": "95836f5688938d1c54d2bfa6f9bd0b33",
                        "height": 576,
                        "uri": "v0d00fg10000cea259rc77u7stdoiv4g",
                        "url_key": "v0d00fg10000cea259rc77u7stdoiv4g_h264_540p_1065969",
                        "url_list": [
                            "http://v26-default.365yg.com/7037c856db6ade6a737503e7e2d9e325/63a6ceb3/video/tos/cn/tos-cn-ve-15/oUAcpnIgNCAeJDCRWP9fPlbrWKnNABGUSQojzU/?a=0\u0026ch=26\u0026cr=0\u0026dr=0\u0026lr=all\u0026cd=0%7C0%7C0%7C0\u0026cv=1\u0026br=1040\u0026bt=1040\u0026cs=0\u0026ds=6\u0026ft=4zenzjjM9-px8Zq8ZmCM5y7EkcADPce.NLrkbJ4LZmoagl\u0026mime_type=video_mp4\u0026qs=14\u0026rc=ZDw4ZGllOGk2NjY0ZGZnNEBpanlydzo6Zjw1aDMzNGkzM0A2M2FeNC5hXi4xM2A2NjJeYSMxZmFwcjRvMl5gLS1kLWFzcw%3D%3D\u0026l=2022122417034654FC0D15D92ACC62E253\u0026btag=20000",
                            "http://v9-default.365yg.com/ace89873cbb43dd8c95c923074219c8c/63a6ceb3/video/tos/cn/tos-cn-ve-15/oUAcpnIgNCAeJDCRWP9fPlbrWKnNABGUSQojzU/?a=0\u0026ch=26\u0026cr=0\u0026dr=0\u0026lr=all\u0026cd=0%7C0%7C0%7C0\u0026cv=1\u0026br=1040\u0026bt=1040\u0026cs=0\u0026ds=6\u0026ft=4zenzjjM9-px8Zq8ZmCM5y7EkcADPce.NLrkbJ4LZmoagl\u0026mime_type=video_mp4\u0026qs=14\u0026rc=ZDw4ZGllOGk2NjY0ZGZnNEBpanlydzo6Zjw1aDMzNGkzM0A2M2FeNC5hXi4xM2A2NjJeYSMxZmFwcjRvMl5gLS1kLWFzcw%3D%3D\u0026l=2022122417034654FC0D15D92ACC62E253\u0026btag=20000",
                            "https://api.amemv.com/aweme/v1/play/?video_id=v0d00fg10000cea259rc77u7stdoiv4g\u0026line=0\u0026file_id=a15d9c9ac1634313afd51b7faad5699a\u0026sign=95836f5688938d1c54d2bfa6f9bd0b33\u0026is_play_url=1\u0026source=PackSourceEnum_AWEME_DETAIL",
                            "https://api5-normal-dsa.amemv.com/aweme/v1/play/?video_id=v0d00fg10000cea259rc77u7stdoiv4g\u0026line=1\u0026file_id=a15d9c9ac1634313afd51b7faad5699a\u0026sign=95836f5688938d1c54d2bfa6f9bd0b33\u0026is_play_url=1\u0026source=PackSourceEnum_AWEME_DETAIL"
                        ],
                        "width": 1024
                    },
                    "quality_type": 21
                },
                {
                    "FPS": 30,
                    "HDR_bit": "",
                    "HDR_type": "",
                    "bit_rate": 777904,
                    "gear_name": "lower_540_0",
                    "is_bytevc1": 0,
                    "is_h265": 0,
                    "play_addr": {
                        "data_size": 4858692,
                        "file_cs": "c:0-42328-abc1",
                        "file_hash": "0de10d03579a5d0d5e4f7742d4940b0c",
                        "height": 576,
                        "uri": "v0d00fg10000cea259rc77u7stdoiv4g",
                        "url_key": "v0d00fg10000cea259rc77u7stdoiv4g_h264_540p_777904",
                        "url_list": [
                            "http://v26-default.365yg.com/a2b14d6c7ccf75645804434a588a06df/63a6ceb3/video/tos/cn/tos-cn-ve-15/owUSfEPA9UzA9NybPiIQrcnjomJeDAnCBg0KIl/?a=0\u0026ch=26\u0026cr=0\u0026dr=0\u0026lr=all\u0026cd=0%7C0%7C0%7C0\u0026cv=1\u0026br=759\u0026bt=759\u0026cs=0\u0026ds=6\u0026ft=4zenzjjM9-px8Zq8ZmCM5y7EkcADPce.NLrkbJ4LZmoagl\u0026mime_type=video_mp4\u0026qs=4\u0026rc=ZGY4ZTdkODllaTc4ODw0NkBpanlydzo6Zjw1aDMzNGkzM0A2YmJhYl9hNTAxXjNgM2AwYSMxZmFwcjRvMl5gLS1kLWFzcw%3D%3D\u0026l=2022122417034654FC0D15D92ACC62E253\u0026btag=20000",
                            "http://v9-default.365yg.com/bc70f65f6ac9762cd223e102d474e931/63a6ceb3/video/tos/cn/tos-cn-ve-15/owUSfEPA9UzA9NybPiIQrcnjomJeDAnCBg0KIl/?a=0\u0026ch=26\u0026cr=0\u0026dr=0\u0026lr=all\u0026cd=0%7C0%7C0%7C0\u0026cv=1\u0026br=759\u0026bt=759\u0026cs=0\u0026ds=6\u0026ft=4zenzjjM9-px8Zq8ZmCM5y7EkcADPce.NLrkbJ4LZmoagl\u0026mime_type=video_mp4\u0026qs=4\u0026rc=ZGY4ZTdkODllaTc4ODw0NkBpanlydzo6Zjw1aDMzNGkzM0A2YmJhYl9hNTAxXjNgM2AwYSMxZmFwcjRvMl5gLS1kLWFzcw%3D%3D\u0026l=2022122417034654FC0D15D92ACC62E253\u0026btag=20000",
                            "https://api.amemv.com/aweme/v1/play/?video_id=v0d00fg10000cea259rc77u7stdoiv4g\u0026line=0\u0026file_id=33c169c565a44f3b86d5bae4dbe5ec9a\u0026sign=0de10d03579a5d0d5e4f7742d4940b0c\u0026is_play_url=1\u0026source=PackSourceEnum_AWEME_DETAIL",
                            "https://api5-normal-dsa.amemv.com/aweme/v1/play/?video_id=v0d00fg10000cea259rc77u7stdoiv4g\u0026line=1\u0026file_id=33c169c565a44f3b86d5bae4dbe5ec9a\u0026sign=0de10d03579a5d0d5e4f7742d4940b0c\u0026is_play_url=1\u0026source=PackSourceEnum_AWEME_DETAIL"
                        ],
                        "width": 1024
                    },
                    "quality_type": 24
                }
            ],
            "cover": {
                "height": 720,
                "uri": "tos-cn-p-0015/0c5ec4686de24325b9947207a38e5d91_1670652899",
                "url_list": [
                    "https://p9-sign.douyinpic.com/tos-cn-p-0015/0c5ec4686de24325b9947207a38e5d91_1670652899~tplv-dmt-logomcc:tos-cn-i-0813/08b2e29ebdf547c8b307e90291de184f:300:400.jpeg?x-expires=1673082000\u0026x-signature=LDF7Ux5k7vXlfvDTmqLayhKJzvQ%3D\u0026from=3213915784_large\u0026s=PackSourceEnum_AWEME_DETAIL\u0026se=false\u0026sc=cover\u0026l=2022122417034654FC0D15D92ACC62E253",
                    "https://p3-sign.douyinpic.com/tos-cn-p-0015/0c5ec4686de24325b9947207a38e5d91_1670652899~tplv-dmt-logomcc:tos-cn-i-0813/08b2e29ebdf547c8b307e90291de184f:300:400.jpeg?x-expires=1673082000\u0026x-signature=HoJJphXHc%2BxDKfhxX5Ff%2F%2FHoIq0%3D\u0026from=3213915784_large\u0026s=PackSourceEnum_AWEME_DETAIL\u0026se=false\u0026sc=cover\u0026l=2022122417034654FC0D15D92ACC62E253",
                    "https://p6-sign.douyinpic.com/tos-cn-p-0015/0c5ec4686de24325b9947207a38e5d91_1670652899~tplv-dmt-logomcc:tos-cn-i-0813/08b2e29ebdf547c8b307e90291de184f:300:400.jpeg?x-expires=1673082000\u0026x-signature=OF1tFfBLMRca32h3TxSRhFrGjlc%3D\u0026from=3213915784_large\u0026s=PackSourceEnum_AWEME_DETAIL\u0026se=false\u0026sc=cover\u0026l=2022122417034654FC0D15D92ACC62E253"
                ],
                "width": 720
            },
            "cover_original_scale": {
                "height": 720,
                "uri": "tos-cn-p-0015/0c5ec4686de24325b9947207a38e5d91_1670652899",
                "url_list": [
                    "https://p9-sign.douyinpic.com/tos-cn-p-0015/0c5ec4686de24325b9947207a38e5d91_1670652899~tplv-dy-360p.jpeg?x-expires=1673082000\u0026x-signature=LLCf4jvsKRSVVL8b6yP5j9FBWkQ%3D\u0026from=3213915784\u0026se=false\u0026biz_tag=feed_cover\u0026l=2022122417034654FC0D15D92ACC62E253",
                    "https://p3-sign.douyinpic.com/tos-cn-p-0015/0c5ec4686de24325b9947207a38e5d91_1670652899~tplv-dy-360p.jpeg?x-expires=1673082000\u0026x-signature=GRVUznAMJFnvHXSOh7QDnjpzNOY%3D\u0026from=3213915784\u0026se=false\u0026biz_tag=feed_cover\u0026l=2022122417034654FC0D15D92ACC62E253",
                    "https://p6-sign.douyinpic.com/tos-cn-p-0015/0c5ec4686de24325b9947207a38e5d91_1670652899~tplv-dy-360p.jpeg?x-expires=1673082000\u0026x-signature=76rWzP1%2FPJgZOmzc2VIQZD22Ngg%3D\u0026from=3213915784\u0026se=false\u0026biz_tag=feed_cover\u0026l=2022122417034654FC0D15D92ACC62E253"
                ],
                "width": 720
            },
            "duration": 49967,
            "dynamic_cover": {
                "height": 720,
                "uri": "tos-cn-p-0015/e201d11cd89745dc80f0e68bfcfa8729_1670652901",
                "url_list": [
                    "https://p6-sign.douyinpic.com/tos-cn-p-0015/e201d11cd89745dc80f0e68bfcfa8729_1670652901~tplv-dmt-logom:tos-cn-i-0813/08b2e29ebdf547c8b307e90291de184f.image?x-expires=1673082000\u0026x-signature=WumPthxD0Ev%2B9UaSqkKi9tqXqD4%3D\u0026from=3213915784_large",
                    "https://p3-sign.douyinpic.com/tos-cn-p-0015/e201d11cd89745dc80f0e68bfcfa8729_1670652901~tplv-dmt-logom:tos-cn-i-0813/08b2e29ebdf547c8b307e90291de184f.image?x-expires=1673082000\u0026x-signature=w15XFsu%2Fyrc2yITjCtBV%2Bx12jL8%3D\u0026from=3213915784_large",
                    "https://p9-sign.douyinpic.com/tos-cn-p-0015/e201d11cd89745dc80f0e68bfcfa8729_1670652901~tplv-dmt-logom:tos-cn-i-0813/08b2e29ebdf547c8b307e90291de184f.image?x-expires=1673082000\u0026x-signature=fC%2FdIoxJ7%2BrbhBG5m1xPXvo8zCU%3D\u0026from=3213915784_large"
                ],
                "width": 720
            },
            "height": 1080,
            "is_h265": 0,
            "is_source_HDR": 0,
            "meta": "{\"bright_ratio_mean\":\"0.0333\",\"brightness_mean\":\"146.672\",\"diff_overexposure_ratio\":\"0.0349\",\"fullscreen_max_crop\":\"{\\\"maxcrop_left\\\": -1.0, \\\"maxcrop_right\\\": -1.0, \\\"maxcrop_top\\\": -1.0, \\\"version\\\": \\\"v1.0\\\"}\",\"loudness\":\"-17.6\",\"overexposure_ratio_mean\":\"0.0535\",\"peak\":\"1\",\"qprf\":\"1.000\",\"sr_score\":\"0.000\",\"std_brightness\":\"11.91\",\"title_info\":\"{\\\"ratio_br_l\\\": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], \\\"ratio_edge_l\\\": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], \\\"progress_bar\\\": [0.0, 0.0, 0.0], \\\"version\\\": \\\"v1.0\\\"}\"}",
            "origin_cover": {
                "height": 720,
                "uri": "tos-cn-p-0015/d41cd35e4f6c4b19ab8f38a50de9c1d7_1670652643",
                "url_list": [
                    "https://p3-sign.douyinpic.com/tos-cn-p-0015/d41cd35e4f6c4b19ab8f38a50de9c1d7_1670652643~tplv-dy-360p.jpeg?x-expires=1673082000\u0026x-signature=osP%2FV6BJS14BwM02n%2BVXTXOCat8%3D\u0026from=3213915784\u0026se=false\u0026biz_tag=feed_cover\u0026l=2022122417034654FC0D15D92ACC62E253",
                    "https://p6-sign.douyinpic.com/tos-cn-p-0015/d41cd35e4f6c4b19ab8f38a50de9c1d7_1670652643~tplv-dy-360p.jpeg?x-expires=1673082000\u0026x-signature=bRYXdVrXNEzHmjksxqqedOmIQso%3D\u0026from=3213915784\u0026se=false\u0026biz_tag=feed_cover\u0026l=2022122417034654FC0D15D92ACC62E253",
                    "https://p26-sign.douyinpic.com/tos-cn-p-0015/d41cd35e4f6c4b19ab8f38a50de9c1d7_1670652643~tplv-dy-360p.jpeg?x-expires=1673082000\u0026x-signature=9zK0H4ciZ4e5bUgcW5GizjKfhNs%3D\u0026from=3213915784\u0026se=false\u0026biz_tag=feed_cover\u0026l=2022122417034654FC0D15D92ACC62E253"
                ],
                "width": 720
            },
            "play_addr": {
                "data_size": 7432596,
                "file_cs": "c:0-55506-1ae5",
                "file_hash": "2419cd6de5e33edd8ea56b1fc769b59c",
                "height": 576,
                "uri": "v0d00fg10000cea259rc77u7stdoiv4g",
                "url_key": "v0d00fg10000cea259rc77u7stdoiv4g_h264_540p_1190000",
                "url_list": [
                    "http://v26-default.365yg.com/552d0f4992c36f5d16f7b5fddb1e3aef/63a6ceb3/video/tos/cn/tos-cn-ve-15/owfU9CJwjINHAFAPIBleZqKDUcnQzrASngbX7r/?a=0\u0026ch=26\u0026cr=0\u0026dr=0\u0026lr=all\u0026cd=0%7C0%7C0%7C0\u0026cv=1\u0026br=1162\u0026bt=1162\u0026cs=0\u0026ds=6\u0026ft=4zenzjjM9-px8Zq8ZmCM5y7EkcADPce.NLrkbJ4LZmoagl\u0026mime_type=video_mp4\u0026qs=0\u0026rc=OzhnNWdmMzY1ODY3ODdlZUBpanlydzo6Zjw1aDMzNGkzM0AzYTUvYmNfNWAxXjQ2NC8uYSMxZmFwcjRvMl5gLS1kLWFzcw%3D%3D\u0026l=2022122417034654FC0D15D92ACC62E253\u0026btag=20000",
                    "http://v9-default.365yg.com/bc3f7d1fd219e2429d46c75df858e961/63a6ceb3/video/tos/cn/tos-cn-ve-15/owfU9CJwjINHAFAPIBleZqKDUcnQzrASngbX7r/?a=0\u0026ch=26\u0026cr=0\u0026dr=0\u0026lr=all\u0026cd=0%7C0%7C0%7C0\u0026cv=1\u0026br=1162\u0026bt=1162\u0026cs=0\u0026ds=6\u0026ft=4zenzjjM9-px8Zq8ZmCM5y7EkcADPce.NLrkbJ4LZmoagl\u0026mime_type=video_mp4\u0026qs=0\u0026rc=OzhnNWdmMzY1ODY3ODdlZUBpanlydzo6Zjw1aDMzNGkzM0AzYTUvYmNfNWAxXjQ2NC8uYSMxZmFwcjRvMl5gLS1kLWFzcw%3D%3D\u0026l=2022122417034654FC0D15D92ACC62E253\u0026btag=20000",
                    "https://api.amemv.com/aweme/v1/play/?video_id=v0d00fg10000cea259rc77u7stdoiv4g\u0026line=0\u0026file_id=1b2b749574a345c283b0fced228dd568\u0026sign=2419cd6de5e33edd8ea56b1fc769b59c\u0026is_play_url=1\u0026source=PackSourceEnum_AWEME_DETAIL",
                    "https://api5-normal-dsa.amemv.com/aweme/v1/play/?video_id=v0d00fg10000cea259rc77u7stdoiv4g\u0026line=1\u0026file_id=1b2b749574a345c283b0fced228dd568\u0026sign=2419cd6de5e33edd8ea56b1fc769b59c\u0026is_play_url=1\u0026source=PackSourceEnum_AWEME_DETAIL"
                ],
                "width": 1024
            },
            "ratio": "540p",
            "width": 1920
        },
        "video_labels": null,
        "video_tag": [
            {
                "level": 1,
                "tag_id": 2027,
                "tag_name": "萌宠"
            },
            {
                "level": 2,
                "tag_id": 2027001,
                "tag_name": "宠物猫"
            },
            {
                "level": 3,
                "tag_id": 2027001003,
                "tag_name": "猫vlog日常"
            }
        ],
        "video_text": []
    },
    "log_pb": {
        "impr_id": "2022122417034654FC0D15D92ACC62E253"
    },
    "status_code": 0
}

之后,就是将其中的昵称、头像、封面图、视频地址进行提取就OK了!然后写接口的时候我们可以通过下面的返回值status_code进行判断,代表我们已经拿到数据了

"status_code": 0

最终核心的PHP代码如下

    public function douyin($url) {
        $loc = get_headers($url, true) ['Location'];
        preg_match('/video\/(.*)\?/', $loc, $id);
        $num = preg_replace('/[^0-9]/', '', $id[1]);
        $arr = json_decode($this->curl('https://www.iesdouyin.com/aweme/v1/web/aweme/detail/?aweme_id=' .$num), true);
        if ($arr['status_code']==0) {
            $arr = ['code' => 200, 
            'msg' => '解析成功', 
                'author' => $arr['aweme_detail']['author']['nickname'], 
                'uid' => $arr['aweme_detail']['author']['unique_id'], 
                'avatar' => $arr['aweme_detail']['music']['avatar_large']['url_list'][0],
                'like' => $arr['aweme_detail']['statistics']['digg_count'], 
                'time' => $arr['aweme_detail']["create_time"], 
                'title' => $arr['aweme_detail']['desc'], 
                'cover' => $arr['aweme_detail']['video']['origin_cover']['url_list'][0], 
                'url' => $arr['aweme_detail']['video']['play_addr']['url_list'][0],
                'musicurl' => $arr['aweme_detail']['music']['play_url']['url_list'][0], 
                'music' => [
                    'author' => $arr['aweme_detail']['music']['author'], 
                    'avatar' => $arr['aweme_detail']['music']['cover_large']['url_list'][0], 
                    'url' => $arr['aweme_detail']['music']['play_url']['url_list'][0], 
                ]
            ];
            return $arr;
        }
    }

完整代码我们会放到文章的最后,可以供大家下载使用,如果你比较懒也可以直接调用我们的接口

https://api.iculture.cc/api/video/?url=

依旧是刚才的视频链接

https://api.iculture.cc/api/video/?url=https://v.douyin.com/hG1p4Gr/

我们举例看下返回的内容

{
    "code": 200,
    "msg": "解析成功",
    "author": "KvKv",
    "uid": "g7m800",
    "avatar": "https://p3.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-i-0813_3733d4f3f0ef44c99edf7801729a47db.jpeg?from=116350172",
    "like": 4794,
    "time": 1671788906,
    "title": "昨天是黑暗风今天是糖果风~#人像写真 #美出高级感 #随拍 #谁穿谁好看 #这谁顶得住啊 ",
    "cover": "https://p6-sign.douyinpic.com/tos-cn-p-0015/6fb8aa1d80264ca59159ca2fe0fcfa00_1671788910~tplv-dy-360p.jpeg?x-expires=1673085600&x-signature=cWF2BcUk5it02NNV0NW55xDFsbg%3D&from=3213915784&se=false&biz_tag=feed_cover&l=202212241832568E548B9E41CD1A64BCDF",
    "url": "http://v9-default.365yg.com/e3fb8c4ca74cce6139767b5785c094e3/63a6e36e/video/tos/cn/tos-cn-ve-15/oUB89Znep9XbksTzKrVeDJwDc2n8QAj3AogAXx/?a=0&ch=26&cr=0&dr=0&lr=all&cd=0%7C0%7C0%7C0&cv=1&br=1146&bt=1146&cs=0&ds=3&ft=KabkaPPT2_5jH6WH6BRfu~NiAjM5Srhn7BN7TGbR&mime_type=video_mp4&qs=0&rc=N2c1aDk3Nzs1M2Y2NTs0M0BpanI6aTw6ZmZxaDMzNGkzM0BiNDEzX2I1NWIxNTZfXl40YSNxa29xcjQwZmZgLS1kLTBzcw%3D%3D&l=202212241832568E548B9E41CD1A64BCDF&btag=8000",
    "musicurl": "https://sf6-cdn-tos.douyinstatic.com/obj/ies-music/7180278647274179387.mp3",
    "music": {
        "author": "KvKv",
        "avatar": "https://p3.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-i-0813_3733d4f3f0ef44c99edf7801729a47db.jpeg?from=116350172",
        "url": "https://sf6-cdn-tos.douyinstatic.com/obj/ies-music/7180278647274179387.mp3"
    }
}

我们在结果里提供了作者用户名、UID、头像地址、该视频的点赞数、发布视频的时间戳、视频标题、视频封面、视频链接以及背景音乐,还是比较全面的了。

后端API完整代码

目录结构

  • src文件夹
    • video_spider.php
  • index.php
图片[1]-抖音视频去水印接口分析 | 附API接口源码(2022-12-24更新)-FancyPig's blog

video_spider.php

<?php
namespace Video_spider;

class Video {
    public function pipixia($url) {
        $loc = get_headers($url, true) ['Location'];
        preg_match('/item\/(.*)\?/', $loc, $id);
        $arr = json_decode($this->curl('https://is.snssdk.com/bds/cell/detail/?cell_type=1&aid=1319&app_name=super&cell_id=' . $id[1]), true);
        $video_url = $arr['data']['data']['item']['origin_video_download']['url_list'][0]['url'];
        if ($video_url) {
            $arr = [
                'code' => 200, 
                    'author' => $arr['data']['data']['item']['author']['name'], 
                    'avatar' => $arr['data']['data']['item']['author']['avatar']['download_list'][0]['url'], 
                    'time' => $arr['data']['data']['display_time'], 
                    'title' => $arr['data']['data']['item']['content'], 
                    'cover' => $arr['data']['data']['item']['cover']['url_list'][0]['url'], 
                    'url' => $video_url
                ];
            return $arr;
        }
    }
    
    public function douyin($url) {
        $loc = get_headers($url, true) ['Location'];
        preg_match('/video\/(.*)\?/', $loc, $id);
        $num = preg_replace('/[^0-9]/', '', $id[1]);
        $arr = json_decode($this->curl('https://www.iesdouyin.com/aweme/v1/web/aweme/detail/?aweme_id=' .$num), true);
        // preg_match('/href="(.*?)">Found/', $this->curl(str_replace('playwm', 'play', $arr['item_list'][0]["video"]["play_addr"]["url_list"][0])), $matches);
        // $video_url = str_replace('&', '&', $matches[1]);
        if ($arr['status_code']==0) {
            $arr = ['code' => 200, 
            'msg' => '解析成功', 
                'author' => $arr['aweme_detail']['author']['nickname'], 
                'uid' => $arr['aweme_detail']['author']['unique_id'], 
                'avatar' => $arr['aweme_detail']['music']['avatar_large']['url_list'][0],
                'like' => $arr['aweme_detail']['statistics']['digg_count'], 
                'time' => $arr['aweme_detail']["create_time"], 
                'title' => $arr['aweme_detail']['desc'], 
                'cover' => $arr['aweme_detail']['video']['origin_cover']['url_list'][0], 
                'url' => $arr['aweme_detail']['video']['play_addr']['url_list'][0],
                'musicurl' => $arr['aweme_detail']['music']['play_url']['url_list'][0], 
                'music' => [
                    'author' => $arr['aweme_detail']['music']['author'], 
                    'avatar' => $arr['aweme_detail']['music']['cover_large']['url_list'][0], 
                    'url' => $arr['aweme_detail']['music']['play_url']['url_list'][0], 
                ]
            ];
            return $arr;
        }
    }

    public function huoshan($url) {
        $loc = get_headers($url, true) ['location'];
        preg_match('/item_id=(.*)&tag/', $loc, $id);
        $arr = json_decode($this->curl('https://share.huoshan.com/api/item/info?item_id=' . $id[1]), true);
        $url = $arr['data']['item_info']['url'];
        preg_match('/video_id=(.*)&line/', $url, $id);
        if ($id) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                'cover' => $arr["data"]["item_info"]["cover"], 
                'url' => 'https://api-hl.huoshan.com/hotsoon/item/video/_playback/?video_id=' . $id[1]
            ];
            return $arr;
        }
    }

    public function weishi($url) {
        preg_match('/feed\/(.*)\b/', $url, $id);
        if (strpos($url, 'h5.weishi') != false) {
            $arr = json_decode($this->curl('https://h5.weishi.qq.com/webapp/json/weishi/WSH5GetPlayPage?feedid=' . $id[1]), true);
        } else {
            $arr = json_decode($this->curl('https://h5.weishi.qq.com/webapp/json/weishi/WSH5GetPlayPage?feedid=' . $url), true);
        }
        $video_url = $arr['data']['feeds'][0]['video_url'];
        if ($video_url) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'author' => $arr['data']['feeds'][0]['poster']['nick'], 
                    'avatar' => $arr['data']['feeds'][0]['poster']['avatar'], 
                    'time' => $arr['data']['feeds'][0]['poster']['createtime'], 
                    'title' => $arr['data']['feeds'][0]['feed_desc_withat'], 
                    'cover' => $arr['data']['feeds'][0]['images'][0]['url'], 
                    'url' => $video_url
            ];
            return $arr;
        }
    }

    public function weibo($url) {
        if (strpos($url, 'show?fid=') != false) {
            preg_match('/fid=(.*)/', $url, $id);
            $arr = json_decode($this->weibo_curl($id[1]), true);
        } else {
            preg_match('/\d+\:\d+/', $url, $id);
            $arr = json_decode($this->weibo_curl($id[0]), true);
        }
        if ($arr) {
            $one = key($arr['data']['Component_Play_Playinfo']['urls']);
            $video_url = $arr['data']['Component_Play_Playinfo']['urls'][$one];
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'author' => $arr['data']['Component_Play_Playinfo']['author'], 
                    'avatar' => $arr['data']['Component_Play_Playinfo']['avatar'], 
                    'time' => $arr['data']['Component_Play_Playinfo']['real_date'], 
                    'title' => $arr['data']['Component_Play_Playinfo']['title'], 
                    'cover' => $arr['data']['Component_Play_Playinfo']['cover_image'], 
                    'url' => $video_url
                ];
            return $arr;
        }
    }

    public function lvzhou($url) {
        $text = $this->curl($url);
        preg_match('/<div class=\"status-title\">(.*)<\/div>/', $text, $video_title);
        preg_match('/<div style=\"background-image:url\((.*)\)/', $text, $video_cover);
        preg_match('/<video src=\"([^\"]*)\"/', $text, $video_url);
        preg_match('/<div class=\"nickname\">(.*)<\/div>/', $text, $video_author);
        preg_match('/<a class=\"avatar\"><img src=\"(.*)\?/', $text, $video_author_img);
        preg_match('/已获得(.*)条点赞<\/div>/', $text, $video_like);
        if ($video_url[1]) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'author' => $video_author[1], 
                    'avatar' => str_replace('1080.180', '1080.680', $video_author_img) [1], 
                    'like' => $video_like[1], 
                    'title' => $video_title[1], 
                    'cover' => $video_cover[1], 
                    'url' => $video_url[1], 
                ];
            return $arr;
        }
    }

    public function zuiyou($url) {
        $text = $this->curl($url);
        preg_match('/fullscreen=\"false\" src=\"(.*?)\"/', $text, $video);
        preg_match('/:<\/span><h1>(.*?)<\/h1><\/div><div class=/', $text, $video_title);
        preg_match('/poster=\"(.*?)\">/', $text, $video_cover);
        $video_url = str_replace('\\', '/', str_replace('u002F', '', $video[1]));
        preg_match('/<span class=\"SharePostCard__name\">(.*?)<\/span>/', $text, $video_author);
        if ($video_url) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'author' => $video_author[1], 
                    'title' => $video_title[1], 
                    'cover' => $video_cover[1], 
                    'url' => $video_url, 
                ];
            return $arr;
        }
    }

    public function bbq($url) {
        preg_match('/id=(.*)\b/', $url, $id);
        $arr = json_decode($this->curl('https://bbq.bilibili.com/bbq/app-bbq/sv/detail?svid=' . $id[1]), true);
        $video_url = $arr['data']['play']['file_info'][0]['url'];
        if ($video_url) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'author' => $arr['data']['user_info']['uname'], 
                    'avatar' => $arr['data']['user_info']['face'], 
                    'time' => $arr['data']['pubtime'], 
                    'like' => $arr['data']['like'], 
                    'title' => $arr['data']['title'], 
                    'cover' => $arr['data']['cover_url'], 
                    'url' => $video_url, 
                ];
            return $arr;
        }
    }

    public function kuaishou($url) {
        $locs = get_headers($url, true) ['Location'][1];
        preg_match('/photoId=(.*?)\&/', $locs, $matches);
        $headers = array('Cookie: did=web_9bceee20fa5d4a968535a27e538bf51b; didv=1655992503000;',
        'Referer: ' . $locs, 'Content-Type: application/json');
        $post_data = '{"photoId": "' . str_replace(['video/', '?'], '', $matches[1]) . '","isLongVideo": false}';
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, 'https://v.m.chenzhongtech.com/rest/wd/photo/info');
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_NOBODY, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLINFO_HEADER_OUT, TRUE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
        $data = curl_exec($curl);
        curl_close($curl);
        $json = json_decode($data, true);
        if ($json) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'avatar' => $json['photo']['headUrl'], 
                    'author' => $json['photo']['userName'], 
                    'time' => $json['photo']['timestamp'], 
                    'title' => $json['photo']['caption'], 
                    'cover' => $json['photo']['coverUrls'][key($json['photo']['coverUrls']) ]['url'], 
                    'url' => $json['photo']['mainMvUrls'][key($json['photo']['mainMvUrls']) ]['url'], 
                ];
            return $arr;
        }
    }

    public function quanmin($id) {
        if (strpos($id, 'quanmin.baidu.com/v/')) {
            preg_match('/v\/(.*?)\?/', $id, $vid);
            $id = $vid[1];
        }
        $arr = json_decode($this->curl('https://quanmin.hao222.com/wise/growth/api/sv/immerse?source=share-h5&pd=qm_share_mvideo&vid=' . $id . '&_format=json'), true);
        if ($arr) {
            $arr = ['code' => 200, 
            'msg' => '解析成功', 
                'author' => $arr["data"]["author"]['name'], 
                'avatar' => $arr["data"]["author"]["icon"], 
                'title' => $arr["data"]["meta"]["title"], 
                'cover' => $arr["data"]["meta"]["image"], 
                'url' => $arr["data"]["meta"]["video_info"]["clarityUrl"][0]['url']
            ];
            return $arr;
        }
    }

    public function basai($id) {
        $arr = json_decode($this->curl('http://www.moviebase.cn/uread/api/m/video/' . $id . '?actionkey=300303'), true);
        $video_url = $arr[0]['data']['videoUrl'];
        if ($video_url) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'time' => $arr[0]['data']['createDate'], 
                    'title' => $arr[0]['data']['title'], 
                    'cover' => $arr[0]['data']['coverUrl'], 
                    'url' => $video_url
                ];
            return $arr;
        }
    }

    public function before($url) {
        preg_match('/detail\/(.*)\?/', $url, $id);
        $arr = json_decode($this->curl('https://hlg.xiatou.com/h5/feed/detail?id=' . $id[1]), true);
        $video_url = $arr['data'][0]['mediaInfoList'][0]['videoInfo']['url'];
        if ($video_url) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'author' => $arr['data'][0]['author']['nickName'], 
                    'avatar' => $arr['data'][0]['author']['avatar']['url'], 
                    'like' => $arr['data'][0]['diggCount'], 
                    'time' => $arr['recTimeStamp'], 
                    'title' => $arr['data'][0]['title'], 
                    'cover' => $arr['data'][0]['staticCover'][0]['url'], 
                    'url' => $video_url
                ];
            return $arr;
        }
    }

    public function kaiyan($url) {
        preg_match('/\?vid=(.*)\b/', $url, $id);
        $arr = json_decode($this->curl('https://baobab.kaiyanapp.com/api/v1/video/' . $id[1] . '?f=web'), true);
        $video = 'https://baobab.kaiyanapp.com/api/v1/playUrl?vid=' . $id[1] . '&resourceType=video&editionType=default&source=aliyun&playUrlType=url_oss&ptl=true';
        $video_url = get_headers($video, true) ["Location"];
        if ($video_url) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'title' => $arr['title'], 
                    'cover' => $arr['coverForFeed'], 
                    'url' => $video_url
                ];
            return $arr;
        }
    }

    public function momo($url) {
        preg_match('/new-share-v2\/(.*)\.html/', $url, $id);
        if (count($id) < 1) {
            preg_match('/momentids=(\w+)/', $url, $id);
        }
        $post_data = ["feedids" => $id[1], ];
        $arr = json_decode($this->post_curl('https://m.immomo.com/inc/microvideo/share/profiles', $post_data), true);
        $video_url = $arr['data']['list'][0]['video']['video_url'];
        if ($video_url) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'author' => $arr['data']['list'][0]['user']['name'], 
                    'avatar' => $arr['data']['list'][0]['user']['img'], 
                    'uid' => $arr['data']['list'][0]['user']['momoid'], 
                    'sex' => $arr['data']['list'][0]['user']['sex'], 
                    'age' => $arr['data']['list'][0]['user']['age'], 
                    'city' => $arr['data']['list'][0]['video']['city'], 
                    'like' => $arr['data']['list'][0]['video']['like_cnt'], 
                    'title' => $arr['data']['list'][0]['content'], 
                    'cover' => $arr['data']['list'][0]['video']['cover']['l'], 
                    'url' => $video_url
                ];
            return $arr;
        }
    }

    public function vuevlog($url) {
        $text = $this->curl($url);
        preg_match('/<title>(.*?)<\/title>/', $text, $video_title);
        preg_match('/<meta name=\"twitter:image\" content=\"(.*?)\">/', $text, $video_cover);
        preg_match('/<meta property=\"og:video:url\" content=\"(.*?)\">/', $text, $video_url);
        preg_match('/<div class=\"infoItem name\">(.*?)<\/div>/', $text, $video_author);
        preg_match('/<div class="avatarContainer"><img src="(.*?)\"/', $text, $video_avatar);
        preg_match('/<div class=\"likeTitle\">(.*) friends/', $text, $video_like);
        $video_url = $video_url[1];
        if ($video_url) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'author' => $video_author[1], 
                    'avatar' => $video_avatar[1], 
                    'like' => $video_like[1], 
                    'title' => $video_title[1], 
                    'cover' => $video_cover[1], 
                    'url' => $video_url, 
                ];
            return $arr;
        }
    }

    public function xiaokaxiu($url) {
        preg_match('/id=(.*)\b/', $url, $id);
        $sign = md5('S14OnTD#Qvdv3L=3vm&time=' . time());
        $arr = json_decode($this->curl('https://appapi.xiaokaxiu.com/api/v1/web/share/video/' . $id[1] . '?time=' . time(), ["x-sign : $sign"]), true);
        if ($arr['code'] != - 2002) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'author' => $arr['data']['video']['user']['nickname'], 
                    'avatar' => $arr['data']['video']['user']['avatar'], 
                    'like' => $arr['data']['video']['likedCount'], 
                    'time' => $arr['data']['video']['createdAt'], 
                    'title' => $arr['data']['video']['title'], 
                    'cover' => $arr['data']['video']['cover'], 
                    'url' => $arr['data']['video']['url'][0]
                ];
            return $arr;
        }
    }

    public function pipigaoxiao($url) {
        preg_match('/post\/(.*)/', $url, $id);
        $arr = json_decode($this->pipigaoxiao_curl($id[1]), true);
        $id = $arr["data"]["post"]["imgs"][0]["id"];
        if ($id) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'title' => $arr["data"]["post"]["content"], 
                    'cover' => 'https://file.ippzone.com/img/view/id/' . $arr["data"]["post"]["imgs"][0]["id"], 
                    'url' => $arr["data"]["post"]["videos"]["$id"]["url"]
                ];
            return $arr;
        }
    }

    public function quanminkge($url) {
        preg_match('/\?s=(.*)/', $url, $id);
        $text = $this->curl('https://kg.qq.com/node/play?s=' . $id[1]);
        preg_match('/<title>(.*?)-(.*?)-/', $text, $video_title);
        preg_match('/cover\":\"(.*?)\"/', $text, $video_cover);
        preg_match('/playurl_video\":\"(.*?)\"/', $text, $video_url);
        preg_match('/{\"activity_id\":0\,\"avatar\":\"(.*?)\"/', $text, $video_avatar);
        preg_match('/<p class=\"singer_more__time\">(.*?)<\/p>/', $text, $video_time);
        if ($video_url[1]) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'title' => $video_title[2], 
                    'cover' => $video_cover[1], 
                    'url' => $video_url[1], 
                    'author' => $video_title[1], 
                    'avatar' => $video_avatar[1], 
                    'time' => $video_time[1], 
                ];
            return $arr;
        }
    }

    public function xigua($url) {
        if (strpos($url, 'v.ixigua.com') != false) {
            $loc = get_headers($url, true) ['Location'];
            preg_match('/video\/(.*)\//', $loc, $id);
            $url = 'https://www.ixigua.com/' . $id[1];
        }
        $headers = ["User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36 ", "cookie:MONITOR_WEB_ID=7892c49b-296e-4499-8704-e47c1b150c18; ixigua-a-s=1; ttcid=af99669b6304453480454f150701d5c226; BD_REF=1; __ac_nonce=060d88ff000a75e8d17eb; __ac_signature=_02B4Z6wo00f01kX9ZpgAAIDAKIBBQUIPYT5F2WIAAPG2ad; ttwid=1%7CcIsVF_3vqSIk4XErhPB0H2VaTxT0tdsTMRbMjrJOPN8%7C1624806049%7C08ce7dd6f7d20506a41ba0a331ef96a6505d96731e6ad9f6c8c709f53f227ab1"];
        $text = $this->curl($url, $headers);
        preg_match('/<script id=\"SSR_HYDRATED_DATA\">window._SSR_HYDRATED_DATA=(.*?)<\/script>/', $text, $jsondata);
        $data = json_decode(str_replace('undefined', 'null', $jsondata[1]), 1);
        $result = $data["anyVideo"]["gidInformation"]["packerData"]["video"];
        $video_url = base64_decode($result["videoResource"]["dash"]["dynamic_video"]["dynamic_video_list"][2]["main_url"]);
        $music_url = base64_decode($result["videoResource"]["dash"]["dynamic_video"]["dynamic_audio_list"][0]["main_url"]);
        $video_author = $result['user_info']['name'];
        $video_avatar = str_replace('300x300.image', '300x300.jpg', $result['user_info']['avatar_url']);
        $video_cover = $data["anyVideo"]["gidInformation"]["packerData"]["video"]["poster_url"];
        $video_title = $result["title"];
        if ($video_url) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'author' => $video_author, 
                    'avatar' => $video_avatar, 
                    'like' => $result['video_like_count'], 
                    'time' => $result['video_publish_time'], 
                    'title' => $video_title, 
                    'cover' => $video_cover, 
                    'url' => $video_url, 
                    'music' => [
                        'url' => $music_url
                        ]
                ];
            return $arr;
        }
    }

    public function doupai($url) {
        preg_match("/topic\/(.*?).html/", $url, $d_url);
        $vid = $d_url[1];
        $base_url = "https://v2.doupai.cc/topic/" . $vid . ".json";
        $data = json_decode($this->curl($base_url), true);
        $url = $data["data"]["videoUrl"];
        $title = $data["data"]["name"];
        $cover = $data["data"]["imageUrl"];
        $time = $data['data']['createdAt'];
        $author = $data['data']['userId'];
        if ($url) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'title' => $title, 
                    'cover' => $cover, 
                    'time' => $time, 
                    'author' => $author['name'], 
                    'avatar' => $author['avatar'], 
                    'url' => $url
                ];
            return $arr;
        }
    }

    public function sixroom($url) {
        preg_match("/http[s]?:\/\/(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+/", $url, $deal_url);
        $headers = ['user-agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36', 'x-requested-with' => 'XMLHttpRequest'];
        $rows = $this->curl($deal_url[0], $headers);
        preg_match('/tid: \'(\w+)\',/', $rows, $tid);
        $base_url = 'https://v.6.cn/message/message_home_get_one.php';
        $content = $this->curl($base_url . '?tid=' . $tid[1], $headers);
        $content = json_decode($content, 1);
        if ($content) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'title' => $content["content"]["content"][0]["content"]['title'], 
                    'cover' => $content["content"]["content"][0]["content"]['url'], 
                    'url' => $content["content"]["content"][0]["content"]['playurl'], 
                    'author' => $content["content"]["content"][0]['alias'], 
                    'avatar' => $content["content"]["content"][0]['userpic'], 
                ];
            return $arr;
        }
    }

    public function huya($url) {
        preg_match('/\/(\d+).html/', $url, $vid);
        $api = 'https://liveapi.huya.com/moment/getMomentContent';
        $response = $this->curl($api . '?videoId=' . $vid[1], ['user-agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36', 'referer' => 'https://v.huya.com/', ]);
        $content = json_decode($response, 1);
        if ($content['status'] === 200) {
            $url = $content["data"]["moment"]["videoInfo"]["definitions"][0]["url"];
            $cover = $content["data"]["moment"]["videoInfo"]["videoCover"];
            $title = $content["data"]["moment"]["videoInfo"]["videoTitle"];
            $avatarUrl = $content["data"]["moment"]["videoInfo"]["avatarUrl"];
            $author = $content["data"]["moment"]["videoInfo"]["nickName"];
            $time = $content["data"]["moment"]["cTime"];
            $like = $content["data"]["moment"]["favorCount"];
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'title' => $title, 
                    'cover' => $cover, 
                    'url' => $url, 
                    'time' => $time, 
                    'like' => $like, 
                    'author' => $author, 
                    'avatar' => $avatarUrl
                ];
            return $arr;
        }
    }

    public function pear($url) {
        $html = $this->curl($url);
        preg_match('/<h1 class=\"video-tt\">(.*?)<\/h1>/', $html, $title);
        preg_match('/_(\d+)/', $url, $feed_id);
        $base_url = sprintf("https://www.pearvideo.com/videoStatus.jsp?contId=%s&mrd=%s", $feed_id[1], time());
        $response = $this->pear_curl($base_url, $url);
        $content = json_decode($response, 1);
        if ($content['resultCode'] == 1) {
            $video = $content["videoInfo"]["videos"]["srcUrl"];
            $cover = $content["videoInfo"]["video_image"];
            $timer = $content["systemTime"];
            $video_url = str_replace($timer, "cont-" . $feed_id[1], $video);
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'title' => $title[1], 
                    'cover' => $cover, 
                    'url' => $video_url, 
                    'time' => $timer, 
                ];
            return $arr;
        }
    }

    public function xinpianchang($url) {
        $api_headers = ["User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36", "referer" => $url, "origin" => "https://www.xinpianchang.com", "content-type" => "application/json"];
        $home_headers = ["User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36", "upgrade-insecure-requests" => "1"];
        $html = $this->curl($url, $home_headers);
        preg_match('/var modeServerAppKey = "(.*?)";/', $html, $key);
        preg_match('/var vid = "(.*?)";/', $html, $vid);
        $base_url = sprintf("https://mod-api.xinpianchang.com/mod/api/v2/media/%s?appKey=%s&extend=%s", $vid[1], $key[1], "userInfo,userStatus");
        $response = $this->xinpianchang_curl($base_url, $api_headers, $url);
        $content = json_decode($response, 1);
        if ($content['status'] == 0) {
            $cover = $content['data']["cover"];
            $title = $content['data']["title"];
            $videos = $content['data']["resource"]["progressive"];
            $author = $content['data']['owner']['username'];
            $avatar = $content['data']['owner']['avatar'];
            $video = [];
            foreach ($videos as $v) {
                $video[] = ['profile' => $v['profile'], 'url' => $v['url']];
            }
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'author' => $author, 
                    'avatar' => $avatar, 
                    'cover' => $cover, 
                    'title' => $title, 
                    'url' => $video
                ];
            return $arr;
        }
    }

    public function acfan($url) {
        $headers = ['User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'];
        $html = $this->acfun_curl($url, $headers);
        preg_match('/var videoInfo =\s(.*?);/', $html, $info);
        $videoInfo = json_decode(trim($info[1]), 1);
        preg_match('/var playInfo =\s(.*?);/', $html, $play);
        $playInfo = json_decode(trim($play[1]), 1);
        if ($html) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    'title' => $videoInfo['title'], 
                    'cover' => $videoInfo['cover'], 
                    'url' => $playInfo['streams'][0]['playUrls'][0], 
            ];
            return $arr;
        }
    }

    public function meipai($url) {
        $headers = ["User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36 ", ];
        $html = $this->curl($url, $headers);
        preg_match('/data-video="(.*?)"/', $html, $content);
        preg_match('/<meta name=\"description\" content="(.*?)"/', $html, $title);
        $video_bs64 = $content[1];
        $hex = $this->getHex($video_bs64);
        $dec = $this->getDec($hex['hex_1']);
        $d = $this->sub_str($hex['str_1'], $dec['pre']);
        $p = $this->getPos($d, $dec['tail']);
        $kk = $this->sub_str($d, $p);
        $video = 'https:' . base64_decode($kk);
        if ($video_bs64) {
            $arr = [
                'code' => 200, 
                'msg' => '解析成功', 
                    "title" => $title[1], 
                    "url" => $video
            ];
            return $arr;
        }
    }

    private function acfun_curl($url, $headers = []) {
        $header = ['User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'];
        $con = curl_init((string)$url);
        curl_setopt($con, CURLOPT_HEADER, false);
        curl_setopt($con, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($con, CURLOPT_RETURNTRANSFER, true);
        if (!empty($headers)) {
            curl_setopt($con, CURLOPT_HTTPHEADER, $headers);
        } else {
            curl_setopt($con, CURLOPT_HTTPHEADER, $header);
        }
        curl_setopt($con, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($con, CURLOPT_TIMEOUT, 5000);
        return curl_exec($con);
    }

    private function curl($url, $headers = []) {
        $header = ['User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'];
        $con = curl_init((string)$url);
        curl_setopt($con, CURLOPT_HEADER, false);
        curl_setopt($con, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($con, CURLOPT_RETURNTRANSFER, true);
        if (!empty($headers)) {
            curl_setopt($con, CURLOPT_HTTPHEADER, $headers);
        } else {
            curl_setopt($con, CURLOPT_HTTPHEADER, $header);
        }
        curl_setopt($con, CURLOPT_TIMEOUT, 5000);
        $result = curl_exec($con);
        return $result;
    }

    private function post_curl($url, $post_data) {
        $postdata = http_build_query($post_data);
        $options = ['http' => ['method' => 'POST', 'content' => $postdata, ]];
        $context = stream_context_create($options);
        $result = @file_get_contents($url, false, $context);
        return $result;
    }

    private function pipigaoxiao_curl($id) {
        $post_data = "{\"pid\":" . $id . ",\"type\":\"post\",\"mid\":null}";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "http://share.ippzone.com/ppapi/share/fetch_content");
        curl_setopt($ch, CURLOPT_REFERER, "http://share.ippzone.com/ppapi/share/fetch_content");
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
        $output = curl_exec($ch);
        curl_close($ch);
        return $output;
    }

    private function weibo_curl($id) {
        $cookie = "login_sid_t=6b652c77c1a4bc50cb9d06b24923210d; cross_origin_proto=SSL; WBStorage=2ceabba76d81138d|undefined; _s_tentry=passport.weibo.com; Apache=7330066378690.048.1625663522444; SINAGLOBAL=7330066378690.048.1625663522444; ULV=1625663522450:1:1:1:7330066378690.048.1625663522444:; TC-V-WEIBO-G0=35846f552801987f8c1e8f7cec0e2230; SUB=_2AkMXuScYf8NxqwJRmf8RzmnhaoxwzwDEieKh5dbDJRMxHRl-yT9jqhALtRB6PDkJ9w8OaqJAbsgjdEWtIcilcZxHG7rw; SUBP=0033WrSXqPxfM72-Ws9jqgMF55529P9D9W5Qx3Mf.RCfFAKC3smW0px0; XSRF-TOKEN=JQSK02Ijtm4Fri-YIRu0-vNj";
        $post_data = "data={\"Component_Play_Playinfo\":{\"oid\":\"$id\"}}";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://weibo.com/tv/api/component?page=/tv/show/" . $id);
        curl_setopt($ch, CURLOPT_COOKIE, $cookie);
        curl_setopt($ch, CURLOPT_REFERER, "https://weibo.com/tv/show/" . $id);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
        $output = curl_exec($ch);
        curl_close($ch);
        return $output;
    }

    private function pear_curl($url, $referer) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_REFERER, $referer);
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
        $output = curl_exec($ch);
        curl_close($ch);
        return $output;
    }

    private function xinpianchang_curl($url, $headers, $referer) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_REFERER, $referer);
        if (!empty($headers)) {
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        }
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
        $output = curl_exec($ch);
        curl_close($ch);
        return $output;
    }

    protected function getHex($url) {
        $length = strlen($url);
        $hex_1 = substr($url, 0, 4);
        $str_1 = substr($url, 4, $length);
        return ['hex_1' => strrev($hex_1), 'str_1' => $str_1];
    }

    protected function getDec($hex) {
        $b = hexdec($hex);
        $length = strlen($b);
        $c = str_split(substr($b, 0, 2));
        $d = str_split(substr($b, 2, $length));
        return ['pre' => $c, 'tail' => $d, ];
    }

    protected function sub_str($a, $b) {
        $length = strlen($a);
        $k = $b[0];
        $c = substr($a, 0, $k);
        $d = substr($a, $k, $b[1]);
        $temp = str_replace($d, '', substr($a, $k, $length));
        return $c . $temp;
    }

    protected function getPos($a, $b) {
        $b[0] = strlen($a) - (int)$b[0] - (int)$b[1];
        return $b;
    }
}

index.php

<?php
header('Access-Control-Allow-Origin:*');
header('Content-type: application/json');
ini_set('display_errors','off');
error_reporting(E_ALL || ~E_NOTICE);
require 'src/video_spider.php';
$url = $_REQUEST['url'];
$id = $_GET['id'];
$vid = $_GET['vid'];
$basai_id = $_GET['data'];
use Video_spider\Video;
$api = new Video;
if (strpos($url,'pipix')){
    $arr = $api->pipixia($url);
} elseif (strpos($url, 'douyin')){
    $arr = $api->douyin($url);
} elseif (strpos($url, 'huoshan')){
    $arr = $api->huoshan($url);
} elseif (strpos($url, 'h5.weishi')){
    $arr = $api->weishi($url);
} elseif (strpos($url, 'isee.weishi')){
    $arr = $api->weishi($id);
} elseif (strpos($url, 'weibo.com')){
    $arr = $api->weibo($url);
} elseif (strpos($url, 'oasis.weibo')){
    $arr = $api->lvzhou($url);
} elseif (strpos($url, 'zuiyou')){
    $arr = $api->zuiyou($url);
} elseif (strpos($url, 'xiaochuankeji')){
    $arr = $api->zuiyou($url);
    
} elseif (strpos($url, 'bbq.bilibili')){
    $arr = $api->bbq($url);
} elseif (strpos($url, 'kuaishou')){
    $arr = $api->kuaishou($url);
} elseif (strpos($url, 'quanmin')){
    if(empty($vid)){
        $arr = $api->quanmin($url);
    }else{
        $arr = $api->quanmin($vid);
    }
} elseif (strpos($url, 'moviebase')){
    $arr = $api->basai($basai_id);
} elseif (strpos($url, 'hanyuhl')){
    $arr = $api->before($url);
} elseif (strpos($url, 'eyepetizer')){
    $arr = $api->kaiyan($url);
} elseif (strpos($url, 'immomo')){
    $arr = $api->momo($url);
} elseif (strpos($url, 'vuevideo')){
    $arr = $api->vuevlog($url);
} elseif (strpos($url, 'xiaokaxiu')){
    $arr = $api->xiaokaxiu($url);
} elseif (strpos($url, 'ippzone') || strpos($url,'pipigx') ){
    $arr = $api->pipigaoxiao($url);
} elseif (strpos($url, 'qq.com')){
    $arr = $api->quanminkge($url);
} elseif (strpos($url, 'ixigua.com')){
    $arr = $api->xigua($url);
} elseif (strpos($url, 'doupai')){
    $arr = $api->doupai($url);
} elseif(strpos($url,'6.cn')){
    $arr = $api->sixroom($url);
} elseif(strpos($url,'huya.com/play/')){
    $arr = $api->huya($url);
} elseif(strpos($url,'pearvideo.com')){
    $arr = $api->pear($url);
} elseif(strpos($url,'xinpianchang.com')){
    $arr = $api->xinpianchang($url);
} elseif(strpos($url,'acfun.cn')){
    $arr = $api->acfan($url);
} elseif(strpos($url,'meipai.com')){
    $arr = $api->meipai($url);
} else {
    $arr = array(
        'code'  => 201,
        'msg' => '不支持您输入的链接'
    );
}
if (!empty($arr)){
    echo json_encode($arr, JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
else{
    $arr = array(
        'code' => 201,
        'msg' => '解析失败',
    );
    echo json_encode($arr, JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
?>

您可以配合我们的API源码系统使用,可以在index.php第二行加入以下代码,来兼容API系统的IP黑名单,针对指定IP接口将不会发送任何数据

include '../black.php';
© 版权声明
THE END
喜欢就支持一下吧
点赞16赞赏 分享
评论 共10条

请登录后发表评论