Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Обложки для видео #510

Open
deathnoragami opened this issue Jul 30, 2024 · 0 comments
Open

Обложки для видео #510

deathnoragami opened this issue Jul 30, 2024 · 0 comments

Comments

@deathnoragami
Copy link
Contributor

deathnoragami commented Jul 30, 2024

РАБОЧИЙ код для загрузки и применении обложек

url = 'https://api.vk.com/method/video.getThumbUploadUrl'
TOKEN = "vk1.a...."
ID_GROUP = -213 # айди группы ОТРИЦАТЕЛЬНОЕ ЧИСЛО, пользователь - ПОЛОЖИТЕЛЬНОЕ
ID_VIDEO = 123123 # Айди видоса
data = {
    'access_token': TOKEN ,
    'v': '5.199',
    'owner_id' : ID_GROUP
}

response = requests.post(url, data=data) # Получение URL для загрузки
response_json = response.json()
upload_url = response_json['response']['upload_url']
file_path = 'D:/test image/02.jpg' # Выбор картинки

file = {'file': open(file_path, 'rb')}

upload_response = requests.post(upload_url, files=file) # Загрузка картинки
upload_response_json = upload_response.json()
json_string = json.dumps(upload_response_json) # Делаем дамп

save_thumb_url = 'https://api.vk.com/method/video.saveUploadedThumb'
save_data = {
    'access_token': TOKEN,
    'owner_id': ID_GROUP, 
    'thumb_json': json_string,
    'thumb_size': '1', # ХЗ зачем
    'v': '5.241', 
    'video_id': ID_VIDEO, 
    'set_thumb': 1 # Недавно добавленный пункт, он и начал сохранять обложки на видосе
}
save_response = requests.post(save_thumb_url, data=save_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant