#!/usr/bin/python
# -*- coding: utf-8 -*-
#author: vk
#date:2020-10-31
#公众号:vk的pyhon不安全
#qq:2563105014
from tkinter import *
from PIL import ImageTk,Image
import re
import requests
from tkinter import messagebox
import pyperclip
import webbrowser
import time
app = Tk()
app.title("抖音去水印---VK")
app.iconbitmap('vk.ico')
top=Toplevel(padx=10,pady=10,borderwidth=3)
top.title('vk抖音去水印')
top.attributes('-topmost',True)
top.attributes('-toolwindow',True)
photo=PhotoImage(file='3.gif')
Label1=Label(top,height=500,width=500,compound=TOP,image=photo).pack(padx=200,pady=20)
image1 =Image.open('1.gif')
image2 =Image.open('2.gif')
background_image2= ImageTk.PhotoImage(image2)
background_image1= ImageTk.PhotoImage(image1)
w = background_image2.width()
h = background_image2.height()
app.geometry('%dx%d+500+300' % (w+300,h+100))
lb=Label(app)
lb.place(relx=0.6,rely=0.5,anchor=W)
Label(app,image=background_image2).pack(anchor=W,pady=6)
Label(app,image=background_image1).pack(anchor=S,pady=6)
e1=Entry(app,width=19,font='方正悠黑',bg='lightyellow',)
if len(pyperclip.paste())>5:
url=pyperclip.paste()
e1.insert(0,url)
else:
e1.insert(0,'请输入抖音分享链接')
e1.place(x=196,y=180)
headers = {
'User-Agent': 'User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16D57 Version/12.0 Safari/604.1',
}
def prase():
try:
string=e1.get() #
pattern = re.compile(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+') # 匹配模式
url= re.findall(pattern,string)
print(url[0])
response = requests.get(url[0], headers=headers)
now_url = response.url
pat_item_ids = '/video/(.*?)/'
item_ids = re.compile(pat_item_ids, re.S).findall(now_url)
pat_dytk = 'dytk: "(.*?)"'
dytk = re.compile(pat_dytk, re.S).findall(response.text)
url = 'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/'
params = {
'item_ids': item_ids,
'dytk': dytk
}
response = requests.get(url, headers=headers, params=params).json()
true_url = response['item_list'][0]['video']['play_addr']['url_list'][0]
true_url = true_url.replace('playwm','play')
response = requests.get(true_url, headers=headers)
true_url = response.url
data=requests.get(true_url)
with open('已去水印.mp4','wb') as f:
f.write(data.content)
messagebox.showinfo('Happy Halloween', '已在与本程序相同目录下保存成功' )
webbrowser.open('https://mp.weixin.qq.com/s/rd90vsrYHEam2skgio--1w')
except Exception as e:
print(e)
messagebox.askretrycancel('vk提示您!','链接错误,请检查复制内容')
btn=Button(app,text='去水印',overrelief='ridge',bg='#FFE4E1',command=prase,highlightthickness=6,fg='#76EE00',font='方正悠黑')
btn.place(x=400,y=166)
app.mainloop()