Skip to content

Commit 2ca898f

Browse files
committed
更新多个模块,下载器更新
1 parent 9783e6e commit 2ca898f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3018
-5719
lines changed

001-Downloader/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# 资源下载器
2-
本项目主要通过网络上开源的项目聚合成了一个跨平台的下载工具,可批量下载抖音、快手和YouTube视音频资源。下载地址:
2+
本项目主要通过网络上开源的项目聚合成了一个跨平台的下载工具,可批量下载抖音、快手视音频资源。下载地址:
33

4-
MacOS:[Downloader1.0.1-mac](https://github.com/xhunmon/PythonIsTools/releases/download/v1.0.1/downloader1.0.1-mac)
4+
MacOS:[Downloader1.0.3-mac](https://github.com/xhunmon/PythonIsTools/releases/download/v1.0.3/Downloader1.0.3.app)
55

6-
Window:[downloader1.0.1-window.exe](https://github.com/xhunmon/PythonIsTools/releases/download/v1.0.1/downloader1.0.1-window.exe)
6+
Window:[downloader1.0.1-window.exe](https://github.com/xhunmon/PythonIsTools/releases/download/v1.0.1/downloader1.0.1-window.exe) (已停用,待更新)
77

88
效果如图:
99

@@ -25,6 +25,8 @@ pyinstaller -F -i res/logo.ico main.py -w
2525
#③:再次进行打包,参考installer-mac.sh
2626
pyinstaller -F -i res/logo.ico main.spec -w
2727
```
28+
打包脚本与配置已放在 `doc` 目录下,需要拷贝出根目录进行打包。
29+
2830
注意:
2931
pyinstaller打包工具的版本与python版本、python所需第三方库以及操作系统会存在各种问题,所以需要看日志查找问题。例如:打包后运用,发现导入pyppeteer报错,通过降低版本后能正常使用:pip install pyppeteer==0.2.2
3032

001-Downloader/config.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# 常用配置模块
22
[common]
33
#软件使用截止日期
4-
expired_time=2022/12/15 23:59:59
4+
expired_time=2025/12/15 23:59:59
55

66
#app的版本名称
7-
version_name=1.0.2
7+
version_name=1.0.3
88

99
#app的版本号
10-
version_code=102
10+
version_code=103

001-Downloader/doc/installer-window.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

001-Downloader/main.spec renamed to 001-Downloader/doc/mac-sh/main.spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ exe = EXE(pyz,
3838
target_arch=None,
3939
codesign_identity=None,
4040
entitlements_file=None , icon='res/logo.ico')
41+
app = BUNDLE(exe,
42+
name='Downloader.app',
43+
icon='res/logo.ico',
44+
bundle_identifier=None)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
pyinstaller -F -i res/logo.ico main.spec main.py -w \
4+
-p type_enum.py \
5+
-p ui.py \
6+
-p utils.py \
7+
-p downloader.py \
8+
-p douyin/dy_download.py \
9+
-p kuaishou/ks_download.py

001-Downloader/doc/main-window.spec renamed to 001-Downloader/doc/win-sh/main.spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ exe = EXE(pyz,
3838
target_arch=None,
3939
codesign_identity=None,
4040
entitlements_file=None , icon='res\\logo.ico')
41+
app = BUNDLE(exe,
42+
name='Downloader.exe',
43+
icon='res\\logo.ico',
44+
bundle_identifier=None)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
pyinstaller -F -i res\\logo.ico -w main.spec main.py
4+
-p type_enum.py
5+
-p ui.py
6+
-p utils.py
7+
-p downloader.py
8+
-p douyin\\dy_download.py
9+
-p kuaishou\\ks_download.py

001-Downloader/douyin/dy_download.py

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
import os
1212
import re
1313
import time
14-
from urllib import parse
1514

1615
import requests
17-
import requests_html
1816

1917
from downloader import Downloader
2018

@@ -132,6 +130,7 @@ def get_data(self, api_post_url, max_cursor):
132130
Downloader.print_ui('[ 用户 ]:' + str(self.nickname) + '\r')
133131
max_cursor = html['max_cursor']
134132
result = html['aweme_list']
133+
self.count = len(result)
135134
Downloader.print_ui('----抓获数据成功----\r')
136135

137136
# 处理第一页视频信息
@@ -150,7 +149,8 @@ def next_data(self, max_cursor):
150149
return
151150
user_url = self.user
152151
# 获取用户sec_uid
153-
key = re.findall('/user/(.*?)\?', str(user_url))[0]
152+
# key = re.findall('/user/(.*?)\?', str(user_url))[0]
153+
key = re.findall('/user/(.*?)$', str(user_url))[0]
154154
if not key:
155155
key = user_url[28:83]
156156

@@ -165,20 +165,22 @@ def next_data(self, max_cursor):
165165
self.end = True
166166
return
167167
index += 1
168-
Downloader.print_ui('----正在对' + max_cursor + '页进行第 %d 次尝试----\r' % index)
168+
# Downloader.print_ui('----正在对' + max_cursor + '页进行第 %d 次尝试----\r' % index)
169+
Downloader.print_ui('----正在对{}页进行第 {} 次尝试----\r'.format(max_cursor, index))
169170
time.sleep(0.3)
170171
response = requests.get(url=api_naxt_post_url, headers=self.headers)
171172
html = json.loads(response.content.decode())
172173
if self.end == False:
173174
# 下一页值
174175
max_cursor = html['max_cursor']
175176
result = html['aweme_list']
176-
Downloader.print_ui('----' + max_cursor + '页抓获数据成功----\r')
177+
self.count = len(result)
178+
Downloader.print_ui('----{}页抓获数据成功----\r'.format(max_cursor))
177179
# 处理下一页视频信息
178180
self.video_info(result, max_cursor)
179181
else:
180-
self.end == True
181-
Downloader.print_ui('----' + max_cursor + '页抓获数据失败----\r')
182+
self.end = True
183+
Downloader.print_ui('----{}页抓获数据失败----\r'.format(max_cursor))
182184
# sys.exit()
183185

184186
# 处理视频信息
@@ -224,40 +226,47 @@ def videos_download(self, count, author_list, video_list, aweme_id, nickname, ma
224226
except:
225227
pass
226228
Downloader.add_downloading_count()
227-
try:
228-
jx_url = f'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids={aweme_id[i]}' # 官方接口
229-
js = json.loads(requests.get(url=jx_url, headers=self.headers).text)
230-
music_url = str(js['item_list'][0]['music']['play_url']['url_list'][0])
231-
music_title = str(js['item_list'][0]['music']['author'])
232-
if self.musicarg == "yes": # 保留音频
233-
music = requests.get(music_url) # 保存音频
234-
start = time.time() # 下载开始时间
235-
size = 0 # 初始化已下载大小
236-
chunk_size = 1024 # 每次下载的数据大小
237-
content_size = int(music.headers['content-length']) # 下载文件总大小
238-
if music.status_code == 200: # 判断是否响应成功
239-
Downloader.print_ui('[ 音频 ]:' + author_list[i] + '[文件 大小]:{size:.2f} MB'.format(
240-
size=content_size / chunk_size / 1024)) # 开始下载,显示下载文件大小
241-
# m_url = pre_save + music_title + '-[' + author_list[i] + '].mp3'
242-
m_url = os.path.join(pre_save,
243-
nickname[i] + "-" + music_title + '-[' + author_list[i] + '].mp3')
244-
Downloader.print_ui("路径:" + m_url)
245-
with open(m_url, 'wb') as file: # 显示进度条
246-
for data in music.iter_content(chunk_size=chunk_size):
247-
file.write(data)
248-
size += len(data)
249-
Downloader.print_ui('\r' + music_title + '\n[下载进度]:%s%.2f%%' % (
250-
'>' * int(size * 50 / content_size), float(size / content_size * 100)))
251-
end = time.time() # 下载结束时间
252-
Downloader.print_ui('\n' + music_title + '\n[下载完成]:耗时: %.2f秒\n' % (end - start)) # 输出下载用时时间
253-
Downloader.add_success_count()
254-
except Exception as error:
255-
# Downloader.print_ui2(error)
256-
Downloader.print_ui('该页音频没有' + str(self.count) + '个,已为您跳过\r')
257-
Downloader.add_failed_count()
258-
break
229+
# try:
230+
# jx_url = f'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids={aweme_id[i]}' # 官方接口
231+
# js = json.loads(requests.get(url=jx_url, headers=self.headers).text)
232+
# music_url = str(js['item_list'][0]['music']['play_url']['url_list'][0])
233+
# music_title = str(js['item_list'][0]['music']['author'])
234+
# if self.musicarg == "yes": # 保留音频
235+
# music = requests.get(music_url) # 保存音频
236+
# start = time.time() # 下载开始时间
237+
# size = 0 # 初始化已下载大小
238+
# chunk_size = 1024 # 每次下载的数据大小
239+
# content_size = int(music.headers['content-length']) # 下载文件总大小
240+
# if music.status_code == 200: # 判断是否响应成功
241+
# Downloader.print_ui('[ 音频 ]:' + author_list[i] + '[文件 大小]:{size:.2f} MB'.format(
242+
# size=content_size / chunk_size / 1024)) # 开始下载,显示下载文件大小
243+
# # m_url = pre_save + music_title + '-[' + author_list[i] + '].mp3'
244+
# m_url = os.path.join(pre_save,
245+
# nickname[i] + "-" + music_title + '-[' + author_list[i] + '].mp3')
246+
# Downloader.print_ui("路径:" + m_url)
247+
# with open(m_url, 'wb') as file: # 显示进度条
248+
# for data in music.iter_content(chunk_size=chunk_size):
249+
# file.write(data)
250+
# size += len(data)
251+
# Downloader.print_ui('\r' + music_title + '\n[下载进度]:%s%.2f%%' % (
252+
# '>' * int(size * 50 / content_size), float(size / content_size * 100)))
253+
# end = time.time() # 下载结束时间
254+
# Downloader.print_ui('\n' + music_title + '\n[下载完成]:耗时: %.2f秒\n' % (end - start)) # 输出下载用时时间
255+
# Downloader.add_success_count()
256+
# except Exception as error:
257+
# # Downloader.print_ui2(error)
258+
# Downloader.print_ui('该页音频没有' + str(self.count) + '个\r')
259+
# # Downloader.add_failed_count()
260+
# # break
259261

260262
try:
263+
v_url = os.path.join(pre_save, nickname[i] + "-" + '[' + author_list[i] + '].mp4')
264+
# 如果本地已经有了就跳过
265+
if os.path.exists(v_url):
266+
Downloader.print_ui('{}-已存在!'.format(v_url))
267+
Downloader.add_success_count()
268+
continue
269+
261270
video = requests.get(video_list[i], headers=self.headers) # 保存视频
262271
start = time.time() # 下载开始时间
263272
size = 0 # 初始化已下载大小
@@ -267,7 +276,7 @@ def videos_download(self, count, author_list, video_list, aweme_id, nickname, ma
267276
Downloader.print_ui(
268277
'[ 视频 ]:' + nickname[i] + '-' + author_list[i] + '[文件 大小]:{size:.2f} MB'.format(
269278
size=content_size / 1024 / 1024)) # 开始下载,显示下载文件大小
270-
v_url = os.path.join(pre_save, nickname[i] + "-" + '[' + author_list[i] + '].mp4')
279+
# v_url = os.path.join(pre_save, nickname[i] + "-" + '[' + author_list[i] + '].mp4')
271280
# v_url = pre_save + '[' + author_list[i] + '].mp4'
272281
Downloader.print_ui("路径:" + v_url)
273282
with open(v_url, 'wb') as file: # 显示进度条

001-Downloader/downloader.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ def print_hint():
4040
Downloader.print_ui(
4141
"""
4242
使用说明:
43-
1、youtube下载需要先让电脑连接外网,地址如:https://www.youtube.com/watch?v=jKhP750VdXw
44-
2、快手下载用户批量视频如:https://www.kuaishou.com/profile/xxx
45-
3、快手下载单条视频如:https://www.kuaishou.com/short-video/xxx
46-
4、抖音下载用户批量视频如:https://www.douyin.com/user/xxx
47-
5、抖音下载单条视频如:https://www.douyin.com/video/xxx
43+
1、快手下载用户批量视频如:https://www.kuaishou.com/profile/xxx
44+
2、快手下载单条视频如:https://www.kuaishou.com/short-video/xxx
45+
3、抖音下载用户批量视频如:https://www.douyin.com/user/xxx
46+
4、抖音下载单条视频如:https://www.douyin.com/video/xxx
4847
"""
4948
)
5049

001-Downloader/installer-mac.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

001-Downloader/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# 主模块执行
1515
if __name__ == "__main__":
1616
path = os.path.dirname(os.path.realpath(sys.argv[0]))
17+
# path = os.path.dirname('/Users/Qincji/Documents/zmt/')
1718
app = Ui()
1819
app.set_dir(path)
1920
# to do

001-Downloader/pytube/__init__.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)