视频去水印

import os
import time
import emoji
import base64
import threading
import requests
from lxml import etree
from icon import img1
from tkinter import *
from tkinter.filedialog import askdirectory
from tkinter import ttk, messagebox, scrolledtext

# 版本检测更新
def version():
    # 下载最新版本
    def download():
        # 获取文件大小                        headers内没有 content-length 的情况下
        var.set("正在启动下载,请稍后...")
        response_size = requests.get("http://pan.shuaiguoer.com/software/watermarking")
        html_size = etree.HTML(response_size.content.decode())
        version_name_size = html_size.xpath('//div[@class="mdui-col-sm-2 mdui-text-right"]/text()')
        length = float(version_name_size[-1].split("MB")[0]) * 1024 * 1024
        # 获取下载进度
        url = "http://pan.shuaiguoer.com/software/watermarking/%E6%8A%96%E9%9F%B3%E5%8E%BB%E6%B0%B4%E5%8D%B0%20" \
              + str(now_number) + ".exe"
        headers = {'Proxy-Connection': 'keep-alive'}
        r = requests.get(url, stream=True, headers=headers)
        # length = float(r.headers['content-length'])           # 适用于headers内带有 content-length 的情况下
        user_name = os.environ['USERNAME']
        with open(r"C:/Users/" + user_name + "/Desktop/" + version_name[-1], 'wb') as fd:
            count = 0
            count_tmp = 0
            time1 = time.time()
            for chunk in r.iter_content(chunk_size=512):
                if chunk:
                    fd.write(chunk)
                    count += len(chunk)
                    if time.time() - time1 > 2:
                        p = count / length
                        speed = (count - count_tmp) / 1024 / 2
                        count_tmp = count
                        time1 = time.time()
                        var.set("下载进度:{:.2%}    下载速度:{:.2f}KB/s".format(p, speed))
        sign_up.destroy()
        messagebox.showinfo(title="Successful", message="更新完成,请重新打开新版本!")

    # 写入图片数据
    with open("img1.ico", 'wb+') as f:
        f.write(base64.b64decode(img1))
    # 检测当前是否为最新版本
    version_number = 2.7        # 当前软件版本
    response = requests.get("http://pan.shuaiguoer.com/software/watermarking")
    html = etree.HTML(response.content.decode())
    version_name = html.xpath('//div[@class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate"]/span/text()')
    now_number = version_name[-1].split(" ")[1].split(".exe")[0]
    # 公告检测
    up_window = ""
    response = requests.get("http://shuaiguoer.com/douyin/")
    html = etree.HTML(response.content.decode())
    version_info = html.xpath('//*[@id="article"]/p/text()')
    try:
        up_window = str(version_info[0]).split(":")[1]
    except IndexError:
        messagebox.showinfo(title="error", message="服务器状态异常")
    # 弹窗提示
    if not up_window == "":
        messagebox.showinfo(title="tips", message=up_window)
    # 版本检测
    if version_number < float(now_number):
        Tk().withdraw()
        if messagebox.askokcancel(title="更新!", message="检测到新版本!\n是否查看更新?"):
            sign_up = Toplevel(root)
            sign_up.title("下载更新")
            sign_up.geometry('390x225+300+150')
            sign_up.iconbitmap("img1.ico")
            os.remove("img1.ico")
            # 标签
            label = Label(sign_up, text="更新公告", font=('GB2312', 16), fg='red')
            label.grid(row=0, column=0, pady=10)
            # 滚动文本
            scr = scrolledtext.ScrolledText(sign_up, width=50, height=10)
            scr.grid(row=1, column=0, padx=10)
            # 公告更新
            for i in version_info[1:]:
                scr.insert('end', i + "\n\n")
                scr.see(END)      # 设置消息框,默认显示最新内容
            # 标签
            var = StringVar()
            label_up = Label(sign_up, textvariable=var, font=("楷体", 10))
            label_up.grid(row=2, column=0, padx=10, pady=10, sticky=W)
            # 按钮
            button_down = Button(sign_up, text="下载最新版本", command=lambda: thread_it(download))
            button_down.grid(row=2, column=0, padx=10, pady=10, sticky=E)

# 获取路径
def select_path():
    global find_path
    find_path = askdirectory()
    path.set(find_path)

# 解析抖音视频
def watermark():
    url = "https://api.douyin.qlike.cn/parse.php?app=douyin"
    data = {
        'url': entry1.get()
    }
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
                      "AppleWebKit/537.36 (KHTML, like Gecko) "
                      "Chrome/72.0.3626.96 Safari/537.36"
    }
    response = requests.post(url=url, data=data, headers=headers).text
    li = []
    # 获取视频信息
    if entry1.get() == "":
        messagebox.showwarning(title="warning", message="请输入要解析的抖音视频链接")
    if entry2.get() == "":
        messagebox.showwarning(title="warning", message="请选择视频要保存的位置")
    else:
        try:
            response_text = "".join(response)
            for i in range(len(response_text.split('\n'))):
                li.append(response_text.split('\n')[i])
            user_id = str(li[2]).split('<span class="label label-primary">')[1].split('</span>')[0]
            work_info = str(li[3]).split('<span class="label label-primary">')[1].split('</span>')[0]
            # 删除标题里面所有的emoji表情
            b, c, work_index = [], [], []
            for i in emoji.emoji_lis(work_info):
                work_index.append(i.get('location'))
            for i in work_info:
                b.append(i)
                c.append(i)
            for i in work_index:
                num = b[i]
                c.pop(c.index(num))
            work_text = "".join(c)
            # 获取视频信息
            comment = str(li[4]).split('<span class="label label-primary">')[1].split('</span>')[0]
            like = str(li[5]).split('<span class="label label-primary">')[1].split('</span>')[0]
            share = str(li[6]).split('<span class="label label-primary">')[1].split('</span>')[0]
            text1.delete(0.0, END)
            print(user_id, work_info, comment, like, share)
            text1.insert('end', "\n作者ID:{}\n\n作品描述:{}\n\n评论量:{}\n\n点赞量:{}\n\n分享量:{}"
                         .format(user_id, work_text, comment, like, share))
            # 获取视频、音频、封面图链接
            vedio = requests.get(response.split()[12].split("href=")[1].split('"')[1]).content
            music = requests.get(response.split()[20].split("href=")[1].split('"')[1]).content
            image = requests.get(response.split()[1].split("src=")[1].split('"')[1]).content

            # 拼接文件名
            folder_name = find_path + "/" + "douyin_vedio" + "/" + user_id + "_" + work_info
            vedio_name = folder_name + "/" + user_id + "_" + work_info + ".mp4"
            music_name = folder_name + "/" + user_id + "_" + work_info + ".mp3"
            image_name = folder_name + "/" + user_id + "_" + work_info + ".jpeg"

            if not os.path.exists(folder_name):
                os.makedirs(folder_name)
            ii = [vedio_name, music_name, image_name]
            jj = [vedio, music, image]
            for i, j in zip(ii, jj):
                with open(i, 'wb') as ff:
                    ff.write(j)
            messagebox.showinfo(title="Successfully", message="保存完毕")
        except IndexError:
            messagebox.showwarning(title="warning", message="请输入一个正确的抖音视频链接")
        except requests.exceptions.MissingSchema:
            messagebox.showwarning(title="warning", message="无效的URL地址\n请检查链接是否填写正确")

def thread_it(func, *args):
    """将函数打包进线程"""
    # 创建
    t = threading.Thread(target=func, args=args)
    # 守护 !!!
    t.setDaemon(True)
    # 启动
    t.start()

# 写入图片数据
with open("img1.ico", 'wb+') as f:
    f.write(base64.b64decode(img1))

# 主界面基本设置
root = Tk()
root.title("抖音去水印 2.7")
root.iconbitmap("img1.ico")
root.geometry('570x239+560+250')
path = StringVar()

# 标签
label1 = Label(root, text="视频链接:", font=('GB2312', 16))
label1.grid(row=0, column=0, pady=10, padx=5)
label2 = Label(root, text="存放路径:", font=('GB2312', 16))
label2.grid(row=1, column=0, pady=10)

# 文本框
entry1 = Entry(root, width=39, font=('GB2312', 16))
entry1.grid(row=0, column=1, columnspan=2, pady=10, sticky=W)
entry2 = Entry(root, width=28, font=('GB2312', 16), textvariable=path)
entry2.grid(row=1, column=1, pady=10, sticky=W)

# 设置消息框
text1 = Text(root, width=57, height=10, padx=10)
text1.grid(row=2, column=0, padx=10, sticky=W, columnspan=2)

# 按钮
button1 = ttk.Button(root, text="选择路径", command=lambda: thread_it(select_path))
button1.grid(row=1, column=2, sticky=E)
button2 = ttk.Button(root, text="启动视频解析", command=lambda: thread_it(watermark))
button2.grid(row=2, column=1, sticky=E, columnspan=2)
version()           # 调用更新检测
os.remove("img1.ico")
root.mainloop()     # 显示

 

更新记录

1.0.0:支持抖音去水印

1.0.1:支持快手等一些其他的平台的视频。。。去水印

1.0.0:抖音去水印,完善界面

1.0.1:支持快手等一些其他的平台的视频。。。去水印

1.0.2:添加消息框,显示视频信息

1.0.3:支持解析视频、音频、封面图

2.0.1:支持多线程

2.0.2:自动检测更新

2.0.3:后台可控制公告更新、软件弹窗

2.0.4:优化文本框,默认显示为最新内容

2.0.5:更改为滚动文本框,添加滚动条

2.4:优化存放目录

2.5:捕获现已知所有异常

2.6:优化爬取过程,修复有些视频解析出错的BUG。修复无法解析视频描述带emoji表情的BUG。

2.7:增加下载进度、下载速度的动态显示(脑阔疼)

下载

然后甩个下载链接:抖音去水印

 

Last modification:July 6th, 2020 at 06:32 pm
如果觉得我的文章对你有用,请随意赞赏