Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_62973052
python_gui
提交
f3c1ea4b
P
python_gui
项目概览
m0_62973052
/
python_gui
与 Fork 源项目一致
Fork自
小小明-代码实体 / python_gui
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
python_gui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f3c1ea4b
编写于
1月 26, 2022
作者:
小小明-代码实体
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新douyin/抖音短视频合集批量下载器v0.2.exe, douyin/douyin_download_ui.py, douyin/douyin.py, douyin/tools.py
上级
f946b950
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
11 deletion
+21
-11
douyin/douyin.py
douyin/douyin.py
+16
-7
douyin/douyin_download_ui.py
douyin/douyin_download_ui.py
+4
-2
douyin/tools.py
douyin/tools.py
+1
-2
douyin/抖音短视频合集批量下载器v0.2.exe
douyin/抖音短视频合集批量下载器v0.2.exe
+0
-0
未找到文件。
douyin/douyin.py
浏览文件 @
f3c1ea4b
...
...
@@ -20,11 +20,12 @@ def get_video_url(url, cookies):
r
'<script id="RENDER_DATA" type="application/json">([^<>]+)</script>'
,
res
.
text
)
data
=
json
.
loads
(
unquote
(
RENDER_DATA
))
key
=
'8'
if
url
.
find
(
"collection"
)
!=
-
1
else
'34'
if
key
not
in
data
:
print
(
"视频无效..."
)
try
:
detail
=
data
[
key
][
'aweme'
][
'detail'
]
title
=
detail
[
'desc'
]
except
Exception
as
e
:
print
(
f
"
{
url
}
无效,报错的key:"
,
e
)
return
detail
=
data
[
key
][
'aweme'
][
'detail'
]
title
=
detail
[
'desc'
]
if
not
title
:
title
,
=
re
.
findall
(
"<title[^>]+>\s*([^>]+)\s*</title>"
,
res
.
text
)
video_url
=
urljoin
(
url
,
detail
[
'video'
][
'playApi'
])
...
...
@@ -64,7 +65,7 @@ def download_video(video_url, title, folder):
yield
done_size
,
cost_time
,
total
# print(f"进度:{done_size / total:.2%},{done_size / cost_time / 1024 / 1024:.2f}MB/s")
cost_time
=
time
.
time
()
-
start_time
print
(
f
'文件:
{
basename
}
下载完成!耗时:
{
cost_time
:
0.2
f
}
秒'
)
print
(
f
'文件:
{
basename
}
下载完成!
\n
耗时:
{
cost_time
:
0.2
f
}
秒'
)
# def download_douyin_collection(collection_urls, collection_title, save_dir="."):
...
...
@@ -99,7 +100,11 @@ def download_douyin(url, download_collection=False, save_dir="."):
if
not
cookies
:
print
(
"从谷歌游览器提取的douyin cookie为空,请确认本地80以上版本的谷歌游览器有访问过抖音主页"
)
return
video_url
,
title
,
collection_urls
,
collection_title
=
get_video_url
(
url
,
cookies
)
tmp
=
get_video_url
(
url
,
cookies
)
if
tmp
is
None
:
print
(
"下载结束!!!"
)
return
video_url
,
title
,
collection_urls
,
collection_title
=
tmp
if
download_collection
and
collection_urls
:
n
=
len
(
collection_urls
)
print
(
f
"该合集共解析出
{
n
}
个视频,合集名称:
{
collection_title
}
"
)
...
...
@@ -107,7 +112,11 @@ def download_douyin(url, download_collection=False, save_dir="."):
os
.
makedirs
(
save_dir
,
exist_ok
=
True
)
for
i
,
collection_url
in
enumerate
(
collection_urls
,
1
):
num
=
int
(
collection_url
[
collection_url
.
rfind
(
"/"
)
+
1
:])
video_url
,
title
,
_
,
_
=
get_video_url
(
collection_url
,
cookies
)
tmp
=
get_video_url
(
collection_url
,
cookies
)
if
tmp
is
None
:
print
(
"无效视频:"
,
collection_url
,
"已跳过..."
)
continue
video_url
,
title
,
_
,
_
=
tmp
for
done_size
,
cost_time
,
total
in
download_video
(
video_url
,
f
"
{
num
:
>
3
d
}
.
{
title
}
"
,
save_dir
):
yield
i
,
n
,
done_size
,
cost_time
,
total
else
:
...
...
douyin/douyin_download_ui.py
浏览文件 @
f3c1ea4b
...
...
@@ -64,7 +64,7 @@ while True:
url
=
values
[
"url"
]
if
url
.
startswith
(
"https://v.douyin.com/"
):
url
=
parse_vdouyin_url
(
url
)
if
not
url
.
startswith
(
"https://www.douyin.com/video/"
):
if
not
url
.
startswith
(
"https://www.douyin.com/video/"
)
and
not
url
.
startswith
(
"https://www.douyin.com/collection/"
)
:
print
(
"视频地址无效!!!仅支持https://www.douyin.com/video/开头的抖音地址"
)
continue
window
[
"url"
].
Update
(
url
)
...
...
@@ -74,8 +74,10 @@ while True:
else
:
save_dir
=
os
.
path
.
abspath
(
"."
)
window
[
"save_dir"
].
Update
(
save_dir
)
flag
=
False
for
i
,
n
,
done_size
,
cost_time
,
total
in
download_douyin
(
url
,
values
[
"download_collection"
],
save_dir
):
flag
=
True
window
[
"video_bar"
].
Update
(
i
*
1000
//
n
)
if
done_size
==
total
:
total_cost_time
+=
cost_time
...
...
@@ -89,7 +91,7 @@ while True:
window
[
"progressbar"
].
Update
(
done_size
*
1000
//
total
)
message
=
f
"
{
done_size
/
1024
/
1024
:.
2
f
}
MB/
{
total
/
1024
/
1024
:.
2
f
}
MB
\n
{
done_size
/
cost_time
/
1024
/
1024
:.
2
f
}
MB/s"
window
[
"message"
].
Update
(
message
)
if
values
[
"open_folder"
]:
if
flag
and
values
[
"open_folder"
]:
sub
.
Popen
(
f
"explorer
{
save_dir
}
"
,
shell
=
False
)
elif
event
==
"清空输出"
:
window
[
"out"
].
Update
(
""
)
...
...
douyin/tools.py
浏览文件 @
f3c1ea4b
...
...
@@ -9,7 +9,6 @@ import base64
import
json
import
os
import
sqlite3
import
subprocess
import
winreg
import
win32crypt
...
...
@@ -64,5 +63,5 @@ def get_chrome_path():
if
__name__
==
'__main__'
:
#
print(fetch_host_cookie("douyin.com"))
print
(
fetch_host_cookie
(
"douyin.com"
))
print
(
get_chrome_path
())
douyin/抖音短视频合集批量下载器v0.2.exe
浏览文件 @
f3c1ea4b
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录