From 325e5aa459b11a640d7b6513d59732202d252e17 Mon Sep 17 00:00:00 2001 From: MeerBiene <60227302+MeerBiene@users.noreply.github.com> Date: Sat, 15 Jan 2022 11:24:40 +0100 Subject: [PATCH 1/2] implements #220 --- README.md | 2 ++ main.py | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 17debd6d..70ca8ee7 100644 --- a/README.md +++ b/README.md @@ -239,6 +239,8 @@ CSS 2 repos █░░░░░░░░░░░░░░░░ `IGNORED_REPOS` flag can be set to `"waka-readme-stats, my-first-repo"` (just an example) to ignore some repos you don’t want to be counted +`WAKATIME_API_URL` flag can be set if you are hosting your own wakatime compliant backend like [wakapi](https://github.com/muety/wakapi). You only have to supply your base url like so `https://wakapi.dev` + **Timeline** ![Chart not found](https://raw.githubusercontent.com/anmol098/anmol098/master/charts/bar_graph.png) diff --git a/main.py b/main.py index 7e24e5ef..a1b7f452 100644 --- a/main.py +++ b/main.py @@ -29,6 +29,7 @@ listReg = f"{START_COMMENT}[\\s\\S]+{END_COMMENT}" waka_key = os.getenv('INPUT_WAKATIME_API_KEY') +waka_url = os.getenv('INPUT_WAKATIME_URL', "https://wakatime.com") ghtoken = os.getenv('INPUT_GH_TOKEN') showTimeZone = os.getenv('INPUT_SHOW_TIMEZONE') showProjects = os.getenv('INPUT_SHOW_PROJECTS') @@ -98,7 +99,7 @@ get_profile_traffic = Template("""/repos/$owner/$repo/traffic/popular/referrers""") truthy = ['true', '1', 't', 'y', 'yes'] - +exit() def run_v3_api(query): request = requests.get('https://api.github.com' + query, headers=headers) if request.status_code == 200: @@ -309,7 +310,7 @@ def generate_commit_list(tz): def get_waka_time_stats(): stats = '' request = requests.get( - f"https://wakatime.com/api/v1/users/current/stats/last_7_days?api_key={waka_key}") + f"https://{waka_url}/api/v1/users/current/stats/last_7_days?api_key={waka_key}") no_activity = translate["No Activity Tracked This Week"] if request.status_code == 401: @@ -468,8 +469,9 @@ def get_stats(github): yearly_data = get_yearly_data() if show_total_code_time.lower() in truthy: + actual_base_url = f"{waka_url}/api/" if "wakatime.com" in waka_url else f"{waka_url}/api/compat/wakatime/" request = requests.get( - f"https://wakatime.com/api/v1/users/current/all_time_since_today?api_key={waka_key}") + f"https://{actual_base_url}/v1/users/current/all_time_since_today?api_key={waka_key}") if request.status_code == 401: print("Error With WAKA time API returned " + str(request.status_code) + " Response " + str(request.json())) elif "text" not in request.json()["data"]: From d566089dd1ff55ce23aa1abb52fc3cc93d09f414 Mon Sep 17 00:00:00 2001 From: MeerBiene <60227302+MeerBiene@users.noreply.github.com> Date: Sun, 16 Jan 2022 09:14:05 +0100 Subject: [PATCH 2/2] remove wrong exit statement --- main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/main.py b/main.py index a1b7f452..da7181d6 100644 --- a/main.py +++ b/main.py @@ -99,7 +99,6 @@ get_profile_traffic = Template("""/repos/$owner/$repo/traffic/popular/referrers""") truthy = ['true', '1', 't', 'y', 'yes'] -exit() def run_v3_api(query): request = requests.get('https://api.github.com' + query, headers=headers) if request.status_code == 200: