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

Try to fix the API request errors in CI #180

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion sources/bin/extract_gtn_tutorials.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

import argparse
import time
from datetime import date
from typing import (
Dict,
Expand All @@ -12,6 +13,8 @@
import yt_dlp
from owlready2 import get_ontology

PLAUSIBLE_REQUEST_NB = 0


def add_supported_servers(tuto: dict) -> None:
"""
Expand Down Expand Up @@ -80,8 +83,13 @@ def get_visit_results(url: str, tuto: dict, plausible_api: str) -> None:
"""
Extract visit results from Plausible URL
"""
global PLAUSIBLE_REQUEST_NB
headers = {"Authorization": f"Bearer {plausible_api}"}
if PLAUSIBLE_REQUEST_NB > 400:
time.sleep(3600)
PLAUSIBLE_REQUEST_NB = 0
results = shared.get_request_json(url, headers)
PLAUSIBLE_REQUEST_NB += 1
if "results" in results:
for metric in ["visitors", "pageviews", "visit_duration"]:
tuto[metric] += results["results"][metric]["value"]
Expand Down Expand Up @@ -109,7 +117,11 @@ def get_youtube_stats(tuto: dict) -> None:
"""
tuto["video_versions"] = 0
tuto["video_view"] = 0
ydl_opts = {"ignoreerrors": True, "quiet": True}
ydl_opts = {
"ignoreerrors": True,
"quiet": True,
"skip_download": True,
}
recordings = []
if "recordings" in tuto and tuto["recordings"]:
recordings = tuto["recordings"]
Expand Down