File tree Expand file tree Collapse file tree 4 files changed +37
-3
lines changed
Expand file tree Collapse file tree 4 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 2424 'YouTubeDataApiReportFetcher' ,
2525]
2626
27- __version__ = '0.0.5 '
27+ __version__ = '0.0.6 '
Original file line number Diff line number Diff line change 1818from googleapiclient .discovery import build
1919from typing_extensions import override
2020
21- from garf_core import api_clients , query_editor
21+ from garf_core import api_clients , exceptions , query_editor
22+
23+
24+ class YouTubeDataApiClientError (exceptions .GarfYouTubeDataApiError ):
25+ """API client specific exception."""
2226
2327
2428class YouTubeDataApiClient (api_clients .BaseClient ):
29+ """Handles fetching data form YouTube Data API."""
30+
2531 def __init__ (
2632 self ,
2733 api_key : str = os .getenv ('GOOGLE_API_KEY' ),
2834 api_version : str = 'v3' ,
2935 ** kwargs : str ,
3036 ) -> None :
3137 """Initializes YouTubeDataApiClient."""
38+ if not api_key :
39+ raise YouTubeDataApiClientError (
40+ 'api_key is not found. Either pass to YouTubeDataApiClient as api_key '
41+ 'parameter or expose as GOOGLE_API_KEY ENV varible'
42+ )
3243 self .api_key = api_key
3344 self .api_version = api_version
3445 self .api_key
Original file line number Diff line number Diff line change 1+ # Copyright 2025 Google LLC
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # https://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ """Defines common library exceptions."""
16+
17+
18+ class GarfYouTubeDataApiError (Exception ):
19+ """Base class for all library exceptions."""
Original file line number Diff line number Diff line change 2323from typing_extensions import override
2424
2525from garf_core import parsers , report , report_fetcher
26+ from garf_youtube_data_api import query_editor
2627from garf_youtube_data_api .api_clients import YouTubeDataApiClient
2728
2829ALLOWED_FILTERS : Final [set [str ]] = (
@@ -54,10 +55,13 @@ def __init__(
5455 self ,
5556 api_client : YouTubeDataApiClient = YouTubeDataApiClient (),
5657 parser : parsers .BaseParser = parsers .NumericConverterDictParser ,
58+ query_spec : query_editor .YouTubeDataApiQuery = (
59+ query_editor .YouTubeDataApiQuery
60+ ),
5761 ** kwargs : str ,
5862 ) -> None :
5963 """Initializes YouTubeDataApiReportFetcher."""
60- super ().__init__ (api_client , parser , ** kwargs )
64+ super ().__init__ (api_client , parser , query_spec , ** kwargs )
6165
6266 @override
6367 def fetch (
You can’t perform that action at this time.
0 commit comments