aboutsummaryrefslogtreecommitdiffstats
path: root/webapi/holodex.py
diff options
context:
space:
mode:
authorPinapelz <donaldshan1@outlook.com>2023-05-04 16:01:14 -0700
committerPinapelz <donaldshan1@outlook.com>2023-05-04 16:01:14 -0700
commited1e2cbe77f93307f0f3bff736e14695a6c59163 (patch)
treeadc588b2c9b2842240ce043e027bc27c7ff7b4d6 /webapi/holodex.py
Fresh initial commit to remove large history
Diffstat (limited to 'webapi/holodex.py')
-rw-r--r--webapi/holodex.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/webapi/holodex.py b/webapi/holodex.py
new file mode 100644
index 0000000..9ecad60
--- /dev/null
+++ b/webapi/holodex.py
@@ -0,0 +1,55 @@
+from webapi.web_api import WebAPI
+
+
+class HolodexAPI(WebAPI):
+ """
+ Class for interacting with the Holodex API
+ """
+
+ def __init__(self, api_key: str = None, member_count: int = 300,
+ organization: str = "Nijisanji"):
+ super().__init__(api_key = api_key, base_url = "https://holodex.net/api/v2/")
+ self.member_count = member_count
+ self.organization = organization
+ self._inactive_channels = []
+
+ def get_data_all_channels(self) -> list:
+ """
+ Gets data for all channels in a particular organization
+ """
+ members = self.member_count
+ data = []
+ filtered_data = []
+ offset = 0
+ while members > 0:
+ data += self._download_url(
+ f"channels?type=vtuber&offset={offset}&limit=100&org={self.organization}")
+ members -= 100
+ offset += 100
+ for channel in data:
+ if channel['inactive'] is False:
+ channel['description'] = self.get_channel_description(channel['id'])
+ filtered_data.append(channel)
+ else:
+ self._inactive_channels.append(channel['id'])
+ return filtered_data
+
+ def get_exclude_channels(self) -> list:
+ """
+ Gets the list of excluded channels
+ """
+ return self._inactive_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:
+ """
+ Gets the description for a particular channel
+ """
+ data = self._download_url(f"channels/{channel_id}")
+ return data['description']
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage