home · contact · privacy
Remove unused TypeVar.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 15 Nov 2024 04:11:41 +0000 (05:11 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 15 Nov 2024 04:11:41 +0000 (05:11 +0100)
ytplom.py

index 22af6845955fd98b4b377753a4fbc97b22a21fb9..692f26adbd782c82a4c2f4ae3cf4d99c635236f0 100755 (executable)
--- a/ytplom.py
+++ b/ytplom.py
@@ -32,7 +32,6 @@ ProseText = NewType('ProseText', str)
 SqlText = NewType('SqlText', str)
 AmountDownloads = NewType('AmountDownloads', int)
 PlayerUpdateId = NewType('PlayerUpdateId', str)
-QuotaLog: TypeAlias = dict[DatetimeStr, QuotaCost]
 DownloadsDb: TypeAlias = dict[VideoId, PathStr]
 TemplateContext: TypeAlias = dict[
         str, None | bool | PlayerUpdateId | PathStr | VideoId | QueryText
@@ -258,7 +257,7 @@ class VideoData(DbData):
                   (query_id, self.id_))
 
 
-class DbQuotaCost(DbData):
+class QuotaLog(DbData):
     """Collects API access quota costs."""
     _table_name = 'quota_costs'
     _cols = ('id_', 'timestamp', 'cost')
@@ -506,7 +505,7 @@ class TaskHandler(BaseHTTPRequestHandler):
         def collect_results(query_txt: QueryText) -> list[VideoData]:
             youtube = googleapiclient.discovery.build('youtube', 'v3',
                                                       developerKey=API_KEY)
-            DbQuotaCost.update(conn, QUOTA_COST_YOUTUBE_SEARCH)
+            QuotaLog.update(conn, QUOTA_COST_YOUTUBE_SEARCH)
             search_request = youtube.search().list(
                     q=query_txt,
                     part='snippet',
@@ -525,7 +524,7 @@ class TaskHandler(BaseHTTPRequestHandler):
                                       title=snippet['title'],
                                       description=snippet['description'],
                                       published_at=snippet['publishedAt'])]
-            DbQuotaCost.update(conn, QUOTA_COST_YOUTUBE_DETAILS)
+            QuotaLog.update(conn, QUOTA_COST_YOUTUBE_DETAILS)
             ids_for_details = ','.join([r.id_ for r in results])
             videos_request = youtube.videos().list(id=ids_for_details,
                                                    part='content_details')
@@ -623,7 +622,7 @@ class TaskHandler(BaseHTTPRequestHandler):
 
     def _send_queries_index_and_search(self) -> None:
         conn = DatabaseConnection()
-        quota_count = DbQuotaCost.current(conn)
+        quota_count = QuotaLog.current(conn)
         queries_data = QueryData.get_all(conn)
         conn.commit_close()
         queries_data.sort(key=lambda q: q.retrieved_at, reverse=True)