tests.system.providers.amazon.aws.example_google_api_youtube_to_s3

This is a more advanced example dag for using GoogleApiToS3Operator which uses xcom to pass data between tasks to retrieve specific information about YouTube videos:

First it searches for up to 50 videos (due to pagination) in a given time range (YOUTUBE_VIDEO_PUBLISHED_AFTER, YOUTUBE_VIDEO_PUBLISHED_BEFORE) on a YouTube channel (YOUTUBE_CHANNEL_ID) saves the response in S3 + passes over the YouTube IDs to the next request which then gets the information (YOUTUBE_VIDEO_FIELDS) for the requested videos and saves them in S3 (S3_DESTINATION_KEY).

Further information:

YOUTUBE_VIDEO_PUBLISHED_AFTER and YOUTUBE_VIDEO_PUBLISHED_BEFORE needs to be formatted YYYY-MM-DDThh:mm:ss.sZ. See https://developers.google.com/youtube/v3/docs/search/list for more information. YOUTUBE_VIDEO_PARTS depends on the fields you pass via YOUTUBE_VIDEO_FIELDS. See https://developers.google.com/youtube/v3/docs/videos/list#parameters for more information. YOUTUBE_CONN_ID is optional for public videos. It does only need to authenticate when there are private videos on a YouTube channel you want to retrieve.

Authentication: In order for the DAG to run, the GoogleApiToS3Operator needs to authenticate to Google Cloud APIs. Further information about authenticating can be found: https://cloud.google.com/docs/authentication/getting-started https://cloud.google.com/docs/authentication/provide-credentials-adc

https://airflow.apache.org/docs/apache-airflow-providers-google/stable/connections/gcp.html

The required scope for this DAG is https://www.googleapis.com/auth/youtube.readonly. This can be set via the environment variable AIRFLOW_CONN_GOOGLE_CLOUD_DEFAULT, or by creating a custom connection.

Module Contents

Functions

create_connection_gcp(conn_id_name, secret_arn)

wait_for_bucket(s3_bucket_name)

transform_video_ids(**kwargs)

Attributes

DAG_ID

YOUTUBE_CHANNEL_ID

YOUTUBE_VIDEO_PUBLISHED_AFTER

YOUTUBE_VIDEO_PUBLISHED_BEFORE

YOUTUBE_VIDEO_PARTS

YOUTUBE_VIDEO_FIELDS

SECRET_ARN_KEY

sys_test_context_task

test_context

test_run

tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.DAG_ID = 'example_google_api_youtube_to_s3'[source]
tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.YOUTUBE_CHANNEL_ID = 'UCSXwxpWZQ7XZ1WL3wqevChA'[source]
tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.YOUTUBE_VIDEO_PUBLISHED_AFTER = '2019-09-25T00:00:00Z'[source]
tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.YOUTUBE_VIDEO_PUBLISHED_BEFORE = '2019-10-18T00:00:00Z'[source]
tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.YOUTUBE_VIDEO_PARTS = 'snippet'[source]
tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.YOUTUBE_VIDEO_FIELDS = 'items(id,snippet(description,publishedAt,tags,title))'[source]
tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.SECRET_ARN_KEY = 'SECRET_ARN'[source]
tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.sys_test_context_task[source]
tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.create_connection_gcp(conn_id_name, secret_arn)[source]
tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.wait_for_bucket(s3_bucket_name)[source]
tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.transform_video_ids(**kwargs)[source]
tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.test_context[source]
tests.system.providers.amazon.aws.example_google_api_youtube_to_s3.test_run[source]

Was this entry helpful?