Skip to content

Commit bf262c4

Browse files
feat(youtube): add garf-youtube library
Combine youtube-reporting-api and youtube-data-api into one library
1 parent 67c44bc commit bf262c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+581
-438
lines changed

.github/workflows/test_garf_youtube_data_api.yaml renamed to .github/workflows/test_garf_youtube.yaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: Run e2e tests for garf-youtube-data-api
1+
name: Run tests for garf-youtube
22

33
on:
44
workflow_dispatch:
55
pull_request:
66
branches: [main]
77
paths:
8-
- 'libs/community/google/youtube/youtube-data-api/**'
8+
- 'libs/community/google/youtube/**'
99

1010
env:
1111
UV_SYSTEM_PYTHON: 1
@@ -26,14 +26,24 @@ jobs:
2626
enable-cache: true
2727
- name: Install dependencies
2828
run: |
29-
uv pip install pytest python-dotenv
30-
- name: Test ${{ matrix.library }}
29+
- name: Run unit tests
3130
run: |
3231
uv pip install -e libs/core/.[all]
3332
uv pip install -e libs/io/.[test,all]
3433
uv pip install -e libs/executors/.[all]
35-
cd libs/community/google/youtube/youtube-data-api/
36-
uv pip install -e .
34+
cd libs/community/google/youtube/
35+
uv pip install -e .[test]
36+
pytest tests/unit
37+
env:
38+
GARF_YOUTUBE_DATA_API_KEY: ${{ secrets.GARF_YOUTUBE_DATA_API_KEY }}
39+
YOUTUBE_ID: ${{ secrets.YOUTUBE_ID }}
40+
- name: Run end-to-end tests
41+
run: |
42+
uv pip install -e libs/core/.[all]
43+
uv pip install -e libs/io/.[test,all]
44+
uv pip install -e libs/executors/.[all]
45+
cd libs/community/google/youtube/
46+
uv pip install -e .[test]
3747
pytest tests/e2e
3848
env:
3949
GARF_YOUTUBE_DATA_API_KEY: ${{ secrets.GARF_YOUTUBE_DATA_API_KEY }}

libs/community/google/youtube/youtube-data-api/README.md renamed to libs/community/google/youtube/README.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,39 @@
77

88
## Prerequisites
99

10+
### YouTube Data API
11+
1012
* [YouTube Data API](https://console.cloud.google.com/apis/library/youtube.googleapis.com) enabled.
1113
* [API key](https://support.google.com/googleapi/answer/6158862?hl=en) to access to access YouTube Data API.
1214
> Once generated expose API key as `export GARF_YOUTUBE_DATA_API_KEY=<YOUR_API_KEY>`
1315
16+
### YouTube Reporting API
17+
* [YouTube Reporting API](https://console.cloud.google.com/apis/library/youtubereporting.googleapis.com) enabled.
18+
* [Client ID, client secret](https://support.google.com/cloud/answer/6158849?hl=en) and refresh token generated. \
19+
> Please note you'll need to use another OAuth2 credentials type - *Web application*, and set "https://developers.google.com/oauthplayground" as redirect url in it.
20+
* Refresh token. You can use [OAuth Playground](https://developers.google.com/oauthplayground/) to generate refresh token.
21+
* Select `https://www.googleapis.com/auth/yt-analytics.readonly` scope
22+
* Enter OAuth Client ID and OAuth Client secret under *Use your own OAuth credentials*;
23+
* Click on *Authorize APIs*
24+
25+
* Expose client id, client secret and refresh token as environmental variables:
26+
27+
```
28+
export GARF_YOUTUBE_REPORTING_API_CLIENT_ID=
29+
export GARF_YOUTUBE_REPORTING_API_CLIENT_SECRET=
30+
export GARF_YOUTUBE_REPORTING_API_REFRESH_TOKEN=
31+
```
32+
1433
## Installation
1534

16-
`pip install garf-youtube-data-api`
35+
`pip install garf-youtube`
1736

1837
## Usage
1938

2039
### Run as a library
2140
```
22-
from garf_youtube_data_api import report_fetcher
23-
from garf_io import writer
41+
from garf.community.google.youtube import report_fetcher
42+
from garf.io import writer
2443
2544
2645
# Specify query
@@ -37,7 +56,7 @@ console_writer = writer.create_writer('console')
3756
console_writer.write(fetched_report, 'output')
3857
```
3958

40-
Learn [more](https://google.github.io/garf/fetchers/youtube-data-api/#python) on library usage.
59+
Learn [more](https://google.github.io/garf/fetchers/youtube/#python) on library usage.
4160

4261
### Run via CLI
4362

@@ -53,13 +72,13 @@ where:
5372

5473
* `<PATH_TO_QUERIES>` - local or remove files containing queries
5574
* `<OUTPUT_TYPE>` - output supported by [`garf-io` library](https://google.github.io/garf/usage/writers/).
56-
* `<SOURCE_PARAMETER=VALUE` - key-value pairs to refine fetching, check [available source parameters](https://google.github.io/garf/fetchers/youtube-data-api/#available-source-parameters).
75+
* `<SOURCE_PARAMETER=VALUE` - key-value pairs to refine fetching, check [available source parameters](https://google.github.io/garf/fetchers/youtube/#available-source-parameters).
5776

58-
Learn [more](https://google.github.io/garf/fetchers/youtube-data-api/#cli) on CLI usage.
77+
Learn [more](https://google.github.io/garf/fetchers/youtube/#cli) on CLI usage.
5978

6079
## Documentation
6180

62-
You can find a documentation on `garf-youtube-data-api` [here](https://google.github.io/garf/fetchers/youtube-data-api/).
81+
You can find a documentation on `garf-youtube` [here](https://google.github.io/garf/fetchers/youtube/).
6382

6483
## Samples
6584

libs/community/google/youtube/youtube-data-api/examples/README.md renamed to libs/community/google/youtube/examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Example queries for `garf-youtube-data-api`
1+
# Example queries for `garf-youtube`
22

33
Contains sample queries for everyone's reference.
44

libs/community/google/youtube/youtube-data-api/examples/channel_info.sql renamed to libs/community/google/youtube/examples/youtube-data-api/channel_info.sql

File renamed without changes.

libs/community/google/youtube/youtube-data-api/examples/channel_statistics.sql renamed to libs/community/google/youtube/examples/youtube-data-api/channel_statistics.sql

File renamed without changes.

libs/community/google/youtube/youtube-data-api/examples/channel_videos.sql renamed to libs/community/google/youtube/examples/youtube-data-api/channel_videos.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ SELECT
1111
privacy_status,
1212
definition,
1313
caption
14-
FROM builtin.channelVideos
14+
FROM builtin.channelVideos

libs/community/google/youtube/youtube-data-api/examples/commentaries.sql renamed to libs/community/google/youtube/examples/youtube-data-api/commentaries.sql

File renamed without changes.

libs/community/google/youtube/youtube-data-api/examples/video_dimensions.sql renamed to libs/community/google/youtube/examples/youtube-data-api/video_dimensions.sql

File renamed without changes.

libs/community/google/youtube/youtube-data-api/examples/video_info.sql renamed to libs/community/google/youtube/examples/youtube-data-api/video_info.sql

File renamed without changes.

libs/community/google/youtube/youtube-data-api/examples/video_statistics.sql renamed to libs/community/google/youtube/examples/youtube-data-api/video_statistics.sql

File renamed without changes.

0 commit comments

Comments
 (0)