Created
January 19, 2023 09:41
-
-
Save darkaico/b06f1ea5e9012d961af0d08f87c4500d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from urllib.request import urlretrieve | |
from datetime import datetime | |
TOKEN = "<api_token_here" | |
FORM_URLS = "https://api.videoask.com/forms" | |
headers = {"Authorization": f"Bearer {TOKEN}"} | |
# I knew that my total videoasks were 84 so I'm going from 20 to 20 | |
offset = 64 | |
while offset > 0: | |
params = {"order_by": "-updated_at", "limit": "0", "offset": offset} | |
response = requests.get(FORM_URLS, headers=headers, params=params) | |
forms = response.json().get("results") | |
for form in forms: | |
created = datetime.strptime(form["created_at"], "%Y-%m-%dT%H:%M:%S.%fZ") | |
file_name = created.strftime("%Y_%m_%d_%H_%M") | |
print(file_name) | |
thumbnail_url = form.get("first_question", {}).get("thumbnail") | |
# Only save those that were thumbanils from videos | |
if thumbnail_url and thumbnail_url.startswith("https://media.videoask.com"): | |
urlretrieve(thumbnail_url, f"{file_name}.jpg") | |
offset -= 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment