抖音短链去水印下载工具 附python源代码

打开后,按照提示输入抖音视频短链接的网址。
格式为:https://v.douyin.com/XXXXXXX/。

如何去水印?这款软件可以帮您一键去除抖音视频水印,在抖音应用端有一个分享链接,这个分享链接就是抖音短链接。

按回车键下载到当前目录。文件名以抖音视频的名称为准。

Python源代码

import requests
import re
import json
import os
 
 
class douyin_video():
    def __init__(self):
        self.headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
                        'Accept-Encoding': 'gzip, deflate, sdch, br',
                        'Accept-Language': 'zh-CN,zh;q=0.8',
                        'Connection': 'keep-alive',
                        'Upgrade-Insecure-Requests': '1',
                        'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Mobile Safari/537.36'
                        }
        self.url = ''
 
    def get_video_info(self):
        video_id = re.search('video/.*?/', get_local_url(headers=self.headers, url=self.url)).group().replace('video/', '').replace('/', '')
        url = 'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=' + video_id
        res = requests.get(url=url)
        data = json.loads(res.content)['item_list'][0]
        return {
            'file_name': validateTitle(data['desc']),
            'vid': data['video']['vid']
        }
 
    def down_video(self, name_vidObj):
        url = 'https://aweme.snssdk.com/aweme/v1/play/?video_id=%s&ratio=720p&line=0' % name_vidObj['vid']
        video_url = get_local_url(url=url, headers=self.headers)
        res = requests.get(url=video_url)
        with open(name_vidObj['file_name'] + '.mp4', 'wb') as  f:
            f.write(res.content)
        print('%s 下载完成!' % name_vidObj['file_name'])
 
 
def get_local_url(url, headers):
    html = requests.get(url, headers=headers, allow_redirects=False)
    return html.headers['Location']
 
 
def validateTitle(title):
    rstr = r"[\/\\\:\*\?\"\<\>\|]"  # '/ \ : * ? " < > |'
    new_title = re.sub(rstr, "_", title)  # 替换为下划线
    return new_title
 
 
if __name__ == '__main__':
    getVideo = douyin_video()
    while True:
        while True:
            url = input('输入抖音url短链: ')
            if url != '':
                break
 
        getVideo.url = url
        try:
            getVideo.down_video(getVideo.get_video_info())
            print('\n')
        except:
            print('错误的分享链接,或该接口失效\n')
            input('按任意键重试\n')
            os.system('cls')
资源下载
© 版权声明
THE END
喜欢就支持以下吧
点赞32
分享
评论 抢沙发