Skip to content

Commit 3c8e824

Browse files
committed
download user favorite videos
1 parent 70277b9 commit 3c8e824

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

douyin/douyin_appsign.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def load_json(self):
5858
data = json.load(f)
5959
return data
6060

61-
def get_video_urls(self, user_id):
61+
def get_video_urls(self, user_id, type_flag='f'):
6262
"""
6363
获得视频播放地址
6464
Parameters:
@@ -143,8 +143,9 @@ def get_video_urls(self, user_id):
143143
sys.exit()
144144
sign = process.communicate()[0].decode().strip('\n').strip('\r')
145145
print('解析视频链接中')
146+
user_url_prefix = 'https://www.amemv.com/aweme/v1/aweme/favorite' if type_flag == 'f' else 'https://www.amemv.com/aweme/v1/aweme/post'
146147
while has_more != 0:
147-
user_url = 'https://www.amemv.com/aweme/v1/aweme/post/?user_id=%s&max_cursor=%s&count=21&aid=1128&_signature=%s&dytk=%s' % (uid, max_cursor, sign, dytk)
148+
user_url = user_url_prefix + '/?user_id=%s&max_cursor=%s&count=21&aid=1128&_signature=%s&dytk=%s' % (uid, max_cursor, sign, dytk)
148149
req = requests.get(user_url, headers=self.headers)
149150
while req.status_code != 200:
150151
req = requests.get(user_url, headers=self.headers)
@@ -220,9 +221,10 @@ def run(self):
220221
None
221222
"""
222223
self.hello()
223-
user_id = input('请输入ID(例如792279162或Empty_1996):')
224-
watermark_flag = int(input('是否下载带水印的视频(0-否,1-是):'))
225-
video_names, video_urls, share_urls, nickname = self.get_video_urls(user_id)
224+
user_id = input('请输入ID(例如792279162或Empty_1996或95006183):')
225+
watermark_flag = bool(int(input('是否下载带水印的视频(0-否,1-是):')))
226+
type_flag = input('p-上传的, f-喜欢的:')
227+
video_names, video_urls, share_urls, nickname = self.get_video_urls(user_id, type_flag)
226228
if nickname not in os.listdir():
227229
os.mkdir(nickname)
228230
print('视频下载中:共有%d个作品!\n' % len(video_urls))

0 commit comments

Comments
 (0)