We have our own reporting database for a Youtube content owner to monitor performance of our Youtube channels. We have an ETL job that pulls latest reports everyday of type content_owner_basic_a3
.
Since Youtube automatically generates backfill data reports that update the metrics for a past date, we would like to download these backfill reports and update metrics in our own database as well. However, no such backfill reports are available to download for dates where video metrics have been updated. Here's how we are accessing it:
from google_auth_oauthlib.flow import InstalledAppFlowfrom googleapiclient.discovery import buildimport argparseCLIENT_SECRETS_FILE = "client_secret.json"SCOPES = NoneAPI_SERVICE_NAME = "youtubereporting"API_VERSION = "v1"# Authorize the request and store authorization credentials.def get_authenticated_service(): flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES) credentials = flow.run_console() return build(API_SERVICE_NAME, API_VERSION, credentials=credentials)if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--content_owner", default="", help="ID of content owner for which you are retrieving jobs and reports", ) parser.add_argument("--job_id", default=None, help="job ID for job with reportTypeId: content_owner_basic_a3", ) args = parser.parse_args() youtube_reporting = get_authenticated_service() created_after = "2023-06-22T00:00:00.00Z" results = ( youtube_reporting.jobs() .reports() .list( jobId=args.job_id, onBehalfOfContentOwner=args.content_owner, createdAfter=created_after, ) .execute() )
Is there a different job for accessing backfill reports or are we missing something?