- Май
- 577
- 146
Пользователь
Какой метод для получения видео в вк? Video.get не отдает прямую ссылку, а если где-то что-то и дает, то при переходе пишет просто 0 (намёк) или другие числа, которые я уже не помню
By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!def get_vk_video(owner_id, access_token, count=10):Какой метод для получения видео в вк? Video.get не отдает прямую ссылку, а если где-то что-то и дает, то при переходе пишет просто 0 (намёк) или другие числа, которые я уже не помню
Ошибка обработки: 400 Client Error: Bad Request for url: https://vkvd206.okcdn.ru/?expires=1766073564652&s...def get_vk_video(owner_id, access_token, count=10):
import requests
response = requests.get("https://api.vk.com/method/video.get", params={
"owner_id": owner_id,
"count": count,
"access_token": access_token,
"v": "5.199"
})
return response.json()
Ошибка обработки: 400 Client Error: Bad Request for url: https://vkvd206.okcdn.ru/?expires=1766073564652&s...
Ну и переходе там цифра 2
import requests
def get_vk_videos_for_display(owner_id, access_token, count=10):
try:
response = requests.get(
"https://api.vk.com/method/video.get",
params={
"owner_id": owner_id,
"access_token": access_token,
"v": "5.199",
"count": count,
"extended": 1
}
)
data = response.json()
if "response" in data:
videos = data["response"]["items"]
for video in videos:
video_id = video["id"]
owner_id = video["owner_id"]
embed_url = f"https://vk.com/video{owner_id}_{video_id}"
iframe_code = f'<iframe src="https://vk.com/video_ext.php?oid={owner_id}&id={video_id}" width="640" height="360" frameborder="0"></iframe>'
print(f"Video: {video.get('title')}")
print(f"Embed URL: {embed_url}")
print(f"Player URL: https://vk.com/video_ext.php?oid={owner_id}&id={video_id}")
return data
except Exception as e:
print(f"Error: {e}")
return None