「鲑鱼均,因为一场鲑鱼之乱被主管称为鲑鱼世代,广义来说以年龄和脸蛋分类的话这应该算是一种 KNN 的机器学习,不正经的数据分析师,毕业後把人生暂停了半年,在 Google 和 AWS 办过几场演讲,缓下脚步的同时找了份跨领域工作。偶而慢跑、爱跟小动物玩耍。曾立过很多志,最近是希望当一个有细节的人。」
YouTube Reports API 能够使开发人员安排报告的排程,并且批量下载生成报告。对於 YouTube Reports API 而言, API 支持预先所以定义好的报告内容,并且每个报告都包含一组针对频道使用者或内容管理员 YouTube 资讯。灵活的追踪每 Youtube 影片的影片资讯,也有了更加弹性的资料运用方式。这篇是 Python - 数位行销的 Youtube 分析教学系列文章的第 28 篇,也是我参加 2021 iThome 铁人赛中系列文章的第 28 天。
系列文章:Python — 数位行销分析与 Youtube API 教学
昨日回顾:Youtube Reports API 教学 - 最後一次做 OAuth2.0 授权
YouTube Reports API 的目的在於,让开发人员与使用者可以快速生成报告,并且对於报告进行取用和分析,对於 YouTube Reports API 的使用来说我们大致上分为几个步骤。
def list_report_types(youtube_reporting, **kwargs):
kwargs = remove_empty_kwargs(**kwargs)
results = youtube_reporting.reportTypes().list(**kwargs).execute()
reportTypes = results['reportTypes']
if 'reportTypes' in results and results['reportTypes']:
reportTypes = results['reportTypes']
for reportType in reportTypes:
print ('Report type id: %s\n name: %s\n' % (reportType['id'], reportType['name']))
else:
print ('No report types found')
return False
return True
def create_reporting_job(youtube_reporting, report_type_id, **kwargs):
kwargs = remove_empty_kwargs(**kwargs)
reporting_job = youtube_reporting.jobs().create(
body=dict(
reportTypeId=args.report_type,
name=args.name
),
**kwargs
).execute()
print('Reporting job "%s" created for reporting type "%s" at "%s"'
% (reporting_job['name'], reporting_job['reportTypeId'],
reporting_job['createTime']))
def retrieve_reports(youtube_reporting, **kwargs):
kwargs = remove_empty_kwargs(**kwargs)
results = youtube_reporting.jobs().reports().list(
**kwargs
).execute()
if 'reports' in results and results['reports']:
reports = results['reports']
for report in reports:
print('Report dates: %s \n download URL: %s\n'
% (report['startTime'], report['downloadUrl']))
def download_report(youtube_reporting, report_url, local_file):
request = youtube_reporting.media().download(
resourceName=' '
)
request.uri = report_url
fh = FileIO(local_file, mode='wb')
downloader = MediaIoBaseDownload(fh, request, chunksize=-1)
done = False
while done is False:
status, done = downloader.next_chunk()
if status:
print('Download %d%%.' % int(status.progress() * 100))
print('Download Complete!')
在介绍完上方的步骤後,我们完成 OAuth2.0 验证,并且完成身分验证後,回传得到 Report dates 的资料列表,资料列表虽非按照日期排序,办事可以得到该有的日期都拥有,完成本次测试
终於迈入 Reporting API 了,等於我们的挑战赛到达了赛末点,还蛮高兴的,如果有时间也欢迎看看我的夥伴们的文章
lu23770127 — SASS 基础初学三十天
10u1 — 糟了!是世界奇观!
juck30808 — Python — 数位行销分析与 Youtube API 教学
HLD — 浅谈物件导向与Design Pattern介绍
SiQing47 — 前端?後端?你早晚都要全端的,何不从现在开始?
【鲑鱼均】 现职是 200 多万订阅 Youtuber 的数据分析师,专长在 Python 的开发与使用,大学虽然是资讯背景但总是斜杠跑到商管行销领域,以工作角度来说的话,待过 FMCG、通讯软件、社群影音产业,也算是个数位行销体系出生的资讯人。这 30 天铁人挑战赛会从数位行销角度去重新切入数据分析这件事情,期待这个社会中,每个人能在各个角力间不断冲突而渐能找到一个平衡点回归最初的统计建立最终的初心。
下一篇:Youtube Reports API 教学 - 告一个段落
<<: day28 等一下啦,会坏掉的/// Coroutine并发操作的重复请求
Widget乐高积木 在开始实作App之前,我们需要认识 Flutter 程序架构的基本概念。 回顾...
既然可以将音档转为文字回传了,接下来我们可以尝试看看将收到的 Text message 转为音档去进...
大家安安,小弟弟要来接续上一篇的结尾 上一篇的进度是列出了宠物的清单 而现在我们想实现在点击清单的时...
延续昨天,今天来完成一个导览列吧!! 首先先在components创一个navbar.vue 像昨天...
本篇公开自身学会切版的秘密武器是...,及分享学习CSS当中最重要的css盒模型概念 昨天文章中我...