From 78a5af6ff9cbc3a3d0a1d1a9bd573e92f1a98e46 Mon Sep 17 00:00:00 2001
From: Jon Michael Aanes <jonjmaa@gmail.com>
Date: Wed, 26 Feb 2025 00:12:37 +0100
Subject: [PATCH] Misc

---
 personal_data/fetchers/psnprofiles.py | 4 ++--
 personal_data/fetchers/stepmania.py   | 3 ---
 personal_data/main.py                 | 4 ++--
 personal_data/secrets.py              | 3 ++-
 requirements.txt                      | 2 +-
 5 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/personal_data/fetchers/psnprofiles.py b/personal_data/fetchers/psnprofiles.py
index 431beaf..23e2130 100644
--- a/personal_data/fetchers/psnprofiles.py
+++ b/personal_data/fetchers/psnprofiles.py
@@ -73,7 +73,7 @@ class PsnProfiles(Scraper):
     def _scrape_games_overview(self) -> Iterator[dict]:
         for page_num in range(1, 1000):
             logger.info('Getting Overview (page %d)', page_num)
-            url = URL_GAMES_OVERVIEW.format(psn_id=secrets.PLAYSTATION_PSN_ID)
+            url = URL_GAMES_OVERVIEW.format(psn_id=secrets.playstation_psn_id())
             response = self.session.get(url, params={'page': page_num})
             if 'page' not in response.url:
                 msg = "Configuration error? psnprofiles.com made an redirection. This is possibly because your profile name wasn't exactly as expected. Please check it"
@@ -157,7 +157,7 @@ class PsnProfiles(Scraper):
         logger.info('Getting Game Trophies %s', psnprofiles_id)
 
         url = URL_USER_GAME_TROPHIES.format(
-            psn_id=secrets.PLAYSTATION_PSN_ID,
+            psn_id=secrets.playstation_psn_id(),
             game_id=psnprofiles_id,
         )
         response = self.session.get(url, expire_after=cache_duration)
diff --git a/personal_data/fetchers/stepmania.py b/personal_data/fetchers/stepmania.py
index 2719065..159f0e1 100644
--- a/personal_data/fetchers/stepmania.py
+++ b/personal_data/fetchers/stepmania.py
@@ -27,14 +27,11 @@ class Stepmania(Scraper):
             'Europe/Copenhagen',
         )  # TODO: Parameterize in an intelligent manner
 
-        print(STATS_FILE_PATH)
-
         with open(STATS_FILE_PATH) as f:
             soup = bs4.BeautifulSoup(f.read(), 'lxml-xml')
 
         # Derp
         for score in soup.select('SongScores Song HighScoreList HighScore'):
-            print(score.parent.parent)
             song = score.parent.parent.parent
             song_path = Path(song ['Dir'].removesuffix('/'))
 
diff --git a/personal_data/main.py b/personal_data/main.py
index ae607a5..86acbce 100644
--- a/personal_data/main.py
+++ b/personal_data/main.py
@@ -15,12 +15,12 @@ try:
     import cfscrape
 except ImportError:
     cfscrape = None
-    logger.warning('cfscrape not installed: Certain fetchers might not work')
+    logger.exception('cfscrape not installed: Certain fetchers might not work')
 
 try:
     import browsercookie
 except ImportError:
-    logger.warning('browsercookie not installed: Certain fetchers might not work')
+    logger.exception('browsercookie not installed: Certain fetchers might not work')
     browsercookie = None
 
 
diff --git a/personal_data/secrets.py b/personal_data/secrets.py
index 3eb9c13..078a255 100644
--- a/personal_data/secrets.py
+++ b/personal_data/secrets.py
@@ -11,7 +11,8 @@ CRUNCHYROLL_AUTH = secrets.load('CRUNCHYROLL_AUTH')
 FFXIV_CHARACTER_ID = secrets.load('FFXIV_CHARACTER_ID')
 
 # Playstation
-PLAYSTATION_PSN_ID = secrets.load('PLAYSTATION_PSN_ID')
+def playstation_psn_id():
+    return secrets.load_or_fail('PLAYSTATION_PSN_ID')
 
 
 # Partisia Blockchain
diff --git a/requirements.txt b/requirements.txt
index 60e5335..438ba7a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,7 +3,7 @@ lxml
 requests
 requests_cache
 browsercookie
-cfscrape
+cfscrape @ git+https://github.com/landryraccoon/cloudflare-scrape.git
 frozendict
 python-kucoin
 krakenex