diff --git a/examples/upload_video_to_xhs.py b/examples/upload_video_to_xhs.py index 1ddb01f..b0803f0 100644 --- a/examples/upload_video_to_xhs.py +++ b/examples/upload_video_to_xhs.py @@ -34,7 +34,11 @@ if __name__ == '__main__': for index, file in enumerate(files): title, tags = get_title_and_hashtags(str(file)) + # 加入到标题 补充标题(xhs 可以填1000字不写白不写) tags_str = ' '.join(['#' + tag for tag in tags]) + hash_tags_str = '' + hash_tags = [] + # 打印视频文件名、标题和 hashtag print(f"视频文件名:{file}") print(f"标题:{title}") @@ -45,9 +49,16 @@ if __name__ == '__main__': for i in tags[:3]: topic_official = xhs_client.get_suggest_topic(i) if topic_official: - topics.append(topic_official[0]) + topic_official[0]['type'] = 'topic' + topic_one = topic_official[0] + hash_tag_name = topic_one['name'] + hash_tags.append(hash_tag_name) + topics.append(topic_one) - note = xhs_client.create_video_note(title=title[:20], video_path=str(file), desc=title + tags_str, + hash_tags_str = ' ' + ' '.join(['#' + tag + '[话题]#' for tag in hash_tags]) + + note = xhs_client.create_video_note(title=title[:20], video_path=str(file), + desc=title + tags_str + hash_tags_str, topics=topics, is_private=False, post_time=publish_datetimes[index].strftime("%Y-%m-%d %H:%M:%S")) diff --git a/requirements.txt b/requirements.txt index 9828930..ebaac68 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,6 @@ playwright eventlet schedule cf_clearance -biliup \ No newline at end of file +biliup +xhs +qrcode \ No newline at end of file diff --git a/xhs_uploader/xhs_login_qrcode.py b/xhs_uploader/xhs_login_qrcode.py index 11362b0..796602f 100644 --- a/xhs_uploader/xhs_login_qrcode.py +++ b/xhs_uploader/xhs_login_qrcode.py @@ -5,11 +5,11 @@ from time import sleep from xhs import XhsClient -from xhs_uploader.main import sign +from xhs_uploader.main import sign_local, sign # pip install qrcode if __name__ == '__main__': - xhs_client = XhsClient(sign=sign) + xhs_client = XhsClient(sign=sign, timeout=60) print(datetime.datetime.now()) qr_res = xhs_client.get_qrcode() qr_id = qr_res["qr_id"] @@ -20,8 +20,7 @@ if __name__ == '__main__': border=1) qr.add_data(qr_res["url"]) qr.make() - img = qr.make_image(fill_color="black", back_color="white") - img.save('qrcode.png') + qr.print_ascii() while True: check_qrcode = xhs_client.check_qrcode(qr_id, qr_code)