mirror of
https://github.com/harry0703/MoneyPrinterTurbo.git
synced 2026-02-21 16:37:21 +08:00
wip
This commit is contained in:
parent
dba994f22d
commit
f480b21e58
@ -28,65 +28,69 @@ song_file_path = "./music.mp3"
|
||||
bgm_file_path = "../resource/songs/music.mp3"
|
||||
bgm_volume = 0.2
|
||||
|
||||
upload_music_url = f"{api_base_url}/musics"
|
||||
files = {'file': open(song_file_path, 'rb')}
|
||||
response = requests.post(upload_music_url, files=files)
|
||||
bgm_file = response.json()['data']['file']
|
||||
def function(request):
|
||||
|
||||
generate_script_url = f"{api_base_url}/scripts"
|
||||
script_payload = {
|
||||
"video_subject": video_subject,
|
||||
"video_language": video_language,
|
||||
"paragraph_number": 1
|
||||
}
|
||||
response = requests.post(generate_script_url, headers=headers, data=json.dumps(script_payload))
|
||||
video_script = response.json()['data']['video_script']
|
||||
upload_music_url = f"{api_base_url}/musics"
|
||||
files = {'file': open(song_file_path, 'rb')}
|
||||
response = requests.post(upload_music_url, files=files)
|
||||
bgm_file = response.json()['data']['file']
|
||||
|
||||
generate_keywords_url = f"{api_base_url}/terms"
|
||||
keywords_payload = {
|
||||
"video_subject": video_subject,
|
||||
"video_script": video_script,
|
||||
"amount": 5
|
||||
}
|
||||
response = requests.post(generate_keywords_url, headers=headers, data=json.dumps(keywords_payload))
|
||||
video_terms = response.json()['data']['video_terms']
|
||||
generate_script_url = f"{api_base_url}/scripts"
|
||||
script_payload = {
|
||||
"video_subject": video_subject,
|
||||
"video_language": video_language,
|
||||
"paragraph_number": 1
|
||||
}
|
||||
response = requests.post(generate_script_url, headers=headers, data=json.dumps(script_payload))
|
||||
video_script = response.json()['data']['video_script']
|
||||
|
||||
generate_video_url = f"{api_base_url}/videos"
|
||||
video_payload = {
|
||||
"video_subject": video_subject,
|
||||
"video_script": video_script,
|
||||
"video_terms": video_terms,
|
||||
"video_aspect": video_aspect_ratio,
|
||||
"video_concat_mode": video_concat_mode,
|
||||
"video_transition_mode": video_transition_mode,
|
||||
"video_clip_duration": video_clip_duration,
|
||||
"video_count": video_count,
|
||||
"video_source": video_source,
|
||||
"video_language": video_language,
|
||||
"voice_name": speech_voice,
|
||||
"voice_volume": speech_volume,
|
||||
"voice_rate": speech_rate,
|
||||
"bgm_type": "custom",
|
||||
"bgm_file": bgm_file,
|
||||
"bgm_volume": bgm_volume,
|
||||
"subtitle_enabled": False,
|
||||
}
|
||||
generate_keywords_url = f"{api_base_url}/terms"
|
||||
keywords_payload = {
|
||||
"video_subject": video_subject,
|
||||
"video_script": video_script,
|
||||
"amount": 5
|
||||
}
|
||||
response = requests.post(generate_keywords_url, headers=headers, data=json.dumps(keywords_payload))
|
||||
video_terms = response.json()['data']['video_terms']
|
||||
|
||||
response = requests.post(generate_video_url, headers=headers, data=json.dumps(video_payload))
|
||||
print(response.json())
|
||||
generate_video_url = f"{api_base_url}/videos"
|
||||
video_payload = {
|
||||
"video_subject": video_subject,
|
||||
"video_script": video_script,
|
||||
"video_terms": video_terms,
|
||||
"video_aspect": video_aspect_ratio,
|
||||
"video_concat_mode": video_concat_mode,
|
||||
"video_transition_mode": video_transition_mode,
|
||||
"video_clip_duration": video_clip_duration,
|
||||
"video_count": video_count,
|
||||
"video_source": video_source,
|
||||
"video_language": video_language,
|
||||
"voice_name": speech_voice,
|
||||
"voice_volume": speech_volume,
|
||||
"voice_rate": speech_rate,
|
||||
"bgm_type": "custom",
|
||||
"bgm_file": bgm_file,
|
||||
"bgm_volume": bgm_volume,
|
||||
"subtitle_enabled": False,
|
||||
}
|
||||
|
||||
task_id = response.json()['data']['task_id']
|
||||
response = requests.post(generate_video_url, headers=headers, data=json.dumps(video_payload))
|
||||
print(response.json())
|
||||
|
||||
time.sleep(float(os.getenv("TIME_BEFORE_DOWNLOAD")))
|
||||
task_id = response.json()['data']['task_id']
|
||||
|
||||
download_url = f"{api_base_url}/download/{task_id}/final-1.mp4"
|
||||
response = requests.get(download_url, headers=headers)
|
||||
with open('output_video.mp4', 'wb') as f:
|
||||
f.write(response.content)
|
||||
time.sleep(float(os.getenv("TIME_BEFORE_DOWNLOAD")))
|
||||
|
||||
video_path = "output_video.mp4"
|
||||
description = os.getenv("VIDEO_DESCRIPTION")
|
||||
account_name = os.getenv("ACCOUNT_NAME")
|
||||
hashtags = ['fyp']
|
||||
download_url = f"{api_base_url}/download/{task_id}/final-1.mp4"
|
||||
response = requests.get(download_url, headers=headers)
|
||||
with open('output_video.mp4', 'wb') as f:
|
||||
f.write(response.content)
|
||||
|
||||
upload_tiktok(video=video_path, description=description, accountname=account_name)
|
||||
video_path = "output_video.mp4"
|
||||
description = os.getenv("VIDEO_DESCRIPTION")
|
||||
account_name = os.getenv("ACCOUNT_NAME")
|
||||
hashtags = ['fyp']
|
||||
|
||||
upload_tiktok(video=video_path, description=description, accountname=account_name)
|
||||
|
||||
return "Function executed successfully"
|
||||
Loading…
Reference in New Issue
Block a user