summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nijitrack.py3
-rw-r--r--sql_table_config.json4
-rw-r--r--webapi/holodex.py18
3 files changed, 11 insertions, 14 deletions
diff --git a/nijitrack.py b/nijitrack.py
index 615db04..47ff8c7 100644
--- a/nijitrack.py
+++ b/nijitrack.py
@@ -78,6 +78,7 @@ def record_subscriber_data(data: list, force_refresh: bool = False):
channel_name = channel["english_name"]
sub_org = channel["group"]
video_count = channel["video_count"]
+ view_count = channel["view_count"]
if channel_name is None:
channel_name = channel["name"]
if sub_org is None:
@@ -86,7 +87,7 @@ def record_subscriber_data(data: list, force_refresh: bool = False):
utc_now = datetime.now(pytz.timezone('UTC'))
pst_now = utc_now.astimezone(pytz.timezone('US/Pacific'))
formatted_time = pst_now.strftime('%Y-%m-%d %H:%M:%S')
- data_tuple = (channel_id, pfp, channel_name, sub_count, sub_org, video_count, formatted_time)
+ data_tuple = (channel_id, pfp, channel_name, sub_count, sub_org, video_count, view_count, formatted_time)
historical_data_tuple = (channel_id, pfp, channel_name, sub_count, formatted_time)
server.insert_row(table_name = DATA_SETTING["TABLE_LIVE"], column = DATA_SETTING["LIVE_HEADER"], data=data_tuple)
record_diff_data(historical_data_tuple, refresh_daily)
diff --git a/sql_table_config.json b/sql_table_config.json
index a1abb14..a4be574 100644
--- a/sql_table_config.json
+++ b/sql_table_config.json
@@ -2,8 +2,8 @@
"TABLE_LIVE": "subscriber_data",
"TABLE_HISTORICAL": "subscriber_data_historical",
"TABLE_DAILY": "24h_historical",
- "LIVE_COLUMNS": "id SERIAL PRIMARY KEY, channel_id VARCHAR(255), profile_pic VARCHAR(255), name VARCHAR(255), subscriber_count INT, suborg VARCHAR(255), video_count INT, timestamp TIMESTAMP",
- "LIVE_HEADER": "channel_id, profile_pic, name, subscriber_count, suborg, video_count, timestamp",
+ "LIVE_COLUMNS": "id SERIAL PRIMARY KEY, channel_id VARCHAR(255), profile_pic VARCHAR(255), name VARCHAR(255), subscriber_count INT, suborg VARCHAR(255), video_count INT, view_count INT, timestamp TIMESTAMP",
+ "LIVE_HEADER": "channel_id, profile_pic, name, subscriber_count, suborg, video_count, view_count, timestamp",
"DAILY_COLUMNS": "id SERIAL PRIMARY KEY, channel_id VARCHAR(255), sub_diff INT",
"DAILY_HEADER": "channel_id, sub_diff",
"HISTORICAL_COLUMNS": "id SERIAL PRIMARY KEY, channel_id VARCHAR(255), profile_pic VARCHAR(255), name VARCHAR(255), subscriber_count INT, timestamp TIMESTAMP",
diff --git a/webapi/holodex.py b/webapi/holodex.py
index 5f81892..2b92305 100644
--- a/webapi/holodex.py
+++ b/webapi/holodex.py
@@ -31,7 +31,9 @@ class HolodexAPI(WebAPI):
for channel in data:
print("DEBUG: ", channel["id"])
try:
- channel["description"] = self.get_channel_description(channel["id"])
+ additional_data = self.get_additional_data(channel["id"])
+ channel["view_count"] = additional_data[0]
+ channel["description"] = additional_data[1]
if channel["inactive"]:
self._inactive_channels.append(channel["id"])
continue
@@ -42,19 +44,13 @@ class HolodexAPI(WebAPI):
self._channel_data = active_channels
return active_channels
- def get_view_count(self, channel_id: str) -> int:
- """
- Gets the view count for a particular channel
- """
- data = self._download_url(f"channels/{channel_id}")
- return data["view_count"]
-
- def get_channel_description(self, channel_id: str) -> str:
+
+ def get_additional_data(self, channel_id: str) -> tuple:
"""
- Gets the description for a particular channel
+ Gets additional data for a particular channel
"""
data = self._download_url(f"channels/{channel_id}")
- return data["description"]
+ return data["view_count"], data["description"]
def set_organization(self, organization: str):
"""
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage