mirror of
https://github.com/KazooTTT/kazoottt-blog.git
synced 2025-06-22 18:21:33 +08:00
Update docs and sort content
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
---
|
||||
title: 2023-09-12 星期二
|
||||
slug: diary-2023-09-12
|
||||
date: 2023-09-12T00:00:00.000Z
|
||||
date: 2023-09-12
|
||||
author: KazooTTT
|
||||
tags:
|
||||
- 日记
|
||||
|
@ -5,7 +5,23 @@ day_of_week: 星期五
|
||||
author: KazooTTT
|
||||
tags:
|
||||
- 日记
|
||||
description: null
|
||||
description: >-
|
||||
Qube可以集成到GitHub上,详细了解如何进行集成请参考YouTube上的视频。
|
||||
|
||||
如果出现HTTP 409错误,首先删除使用该码的容器,然后再删除相关容器。
|
||||
|
||||
在深度学习工具中,Ollama是一个非常好的沉浸式翻译工具。
|
||||
|
||||
区分重启和刷新按钮时需要注意到不同操作的差异。在Windows系统上,虽然没有macOS类似的窗口管理工具,但仍可以使用Raycast等第三方应用进行任务
|
||||
automation。
|
||||
|
||||
Adobe Express可以帮助我们将图片转换为SVG格式,并提供了一个简单易用的工具。
|
||||
|
||||
在使用ECharts时,Canvas和SVG两个渲染器的选择主要取决于软硬件环境、数据量和功能需求。在需要优化性能的问题场景下,尝试结合实验来确定使用哪种渲-render器更合适。
|
||||
|
||||
只有在你熟悉用canvas手搓图表时,你才能在网页上创建这种图。
|
||||
|
||||
最近的工作包括编辑器图片上传重构、移动端应用程序的开发以及学习VTK和图形学。
|
||||
slug: diary-2024-11-29
|
||||
published: true
|
||||
toAstro: true
|
||||
|
@ -5,7 +5,13 @@ day_of_week: 星期六
|
||||
author: KazooTTT
|
||||
tags:
|
||||
- 日记
|
||||
description: null
|
||||
description: >-
|
||||
为了更快地启动 Visual Studio Code(VSCode)extention,先按下 Ctrl+Shift+P或Cmd+Shift+P进入
|
||||
Command Pallete。然后输入“Startup Performance”并选择相关选项,完成后记得激活功能以保持其设置。
|
||||
|
||||
|
||||
如果存在占用特定端口的程序,请使用命令“lsof -i :<PORT>”识别端口对应的进程ID(PID),再使用命令“kill -9
|
||||
<PID>”终止该进程。也可以使用更方便的方式“kill -9 $(lsof -t -i :<PORT>)”,即直接杀死占用端口的进程。
|
||||
slug: diary-2024-11-30
|
||||
published: true
|
||||
toAstro: true
|
||||
|
@ -5,7 +5,11 @@ day_of_week: 星期三
|
||||
author: KazooTTT
|
||||
tags:
|
||||
- 日记
|
||||
description:
|
||||
description: >-
|
||||
我上周忙得满不在乎,wakatime 的数据显示,我加班的时间直接进入了全球前 100。主要是做 vtk.js
|
||||
的开发花了很多时间,不仅没有做到原先计划的需求,还对 polydata
|
||||
的变化感到困惑。虽然我耐下了心理压力,能清晰地理解项目里的复杂数据流转,但是写文档还是头昏眼花,一时起走神来。除了上周加班外,我也试用了
|
||||
react-scan 和安卓视频下载软件,好看的个人主页让我感动。
|
||||
slug: diary-2024-12-11
|
||||
published: true
|
||||
toAstro: true
|
||||
|
@ -8,7 +8,9 @@ tags:
|
||||
- 数据可视化
|
||||
- 人工智能
|
||||
- 图表生成
|
||||
description:
|
||||
description: >-
|
||||
这一天的碎片化记录,包含了对深Seek
|
||||
API和其新版聊天功能的感想,以及工作、生活中的各种感受和体验。作者在这段时间内进行了一些个人思考和记录,包括购买了智能工具Diagen,感受到了一种计算收益的模式,并且在思考自己的精神层面,希望能够创作出更能让自己满意的作品。
|
||||
slug: diary-2024-12-12
|
||||
published: true
|
||||
toAstro: true
|
||||
|
@ -5,11 +5,33 @@ date: 2024-11-29
|
||||
author: KazooTTT
|
||||
type: Post
|
||||
status: Published
|
||||
tags: null
|
||||
tags:
|
||||
- github action
|
||||
- build docs
|
||||
- OBSidian模板
|
||||
finished: true
|
||||
published: true
|
||||
category: 编程-前端
|
||||
description: null
|
||||
description: >-
|
||||
这个 GitHub Action 通过 Node.js 脚本在每次推送到 content 目录和 build_docs.cjs
|
||||
脚本时更新博客内容,并将其复制到另一个目标仓库。它支持多个环境,包括本地和服务器。该过程依赖于 Obsidian 模板和 Gray Matter 脚本。
|
||||
|
||||
|
||||
此 Action 通过在每次推送中运行其特定步骤来保持 blog 内容的最新。这些步骤包括:
|
||||
|
||||
|
||||
- 运行 npm install 和 npm run build:docs:server 批量安装并构建博客内容。
|
||||
|
||||
- 复制更新的 content 到目标仓库。
|
||||
|
||||
- 运行 npm install 和 npm run sort 批量安装和排序博客内容。
|
||||
|
||||
|
||||
该 Action 通过使用 Gray Matter 脚本来处理 Markdown文件,并根据其 frontMatter
|
||||
信息决定是否需要将其复制到目标仓库中。它还支持从特定目录忽略某些文件或文件夹。
|
||||
|
||||
|
||||
该 Action 的主要功能是自动化 blog 内容的更新和复制,确保 content ALWAYS 是最新的。
|
||||
toAstro: true
|
||||
---
|
||||
|
||||
|
145
src/content/post/编程/前端/使用google sheet + api定时获取油管播放量.md
Normal file
145
src/content/post/编程/前端/使用google sheet + api定时获取油管播放量.md
Normal file
@ -0,0 +1,145 @@
|
||||
---
|
||||
title: 使用google sheet + api定时获取油管播放量
|
||||
date: 2024-12-15T00:00:00.000Z
|
||||
author: KazooTTT
|
||||
type: Post
|
||||
status: Published
|
||||
tags:
|
||||
- milklove
|
||||
- YouTube
|
||||
- Google
|
||||
- Sheet
|
||||
- Apps
|
||||
- Script
|
||||
- 脚本
|
||||
- 自动更新播放量
|
||||
finished: true
|
||||
published: true
|
||||
category: 编程-前端
|
||||
slug: use-google-sheet-api-to-get-youtube-playbacks-on-a-regular-basis
|
||||
description: "在 MilkLove 的二搭剧 Whale Store xoxo 的 YouTube 预告片中,使用 Google Sheets 脚本可以定时获取视频播放量并存入表格。脚本主要包括以下步骤: 1. **检查是否有 access token**: 脚本首先检查是否存在 access token。如果不存在,则会返回一个错误信息。 2. **获取 video 的统计数据**: 脚本使用 YouTube API 来获取视频的统计数据,包括播放量等。若统计数据成功则将播放量返回给脚本。 3. **记录播放量和时间到表格中**:如果在获取播放量后没有发生错误,则会向表格中插入一行,其中包含当前时间和播放量。 因此,通过这个脚本,可以定时地获取 YouTube 视频的播放量并存入 Google Sheets 表格。"
|
||||
toAstro: true
|
||||
---
|
||||
|
||||
起因是想要记录一下 milklove 的二搭剧 Whale Store xoxo 在油管上的预告片的播放量的 [คุณวาฬร้านชำ (Whale Store xoxo) \| GMMTV 2025 - YouTube](https://www.youtube.com/watch?v=Eia_Sh_ZTyQ)
|
||||
|
||||
于是先搜了一下有没有可以直接使用的开源项目或者接口,然后在 [批量统计YouTube视频播放量方法 - 杨哥的出海营销笔记](https://marketingyang.com/%E6%89%B9%E9%87%8F%E7%BB%9F%E8%AE%A1youtube%E8%A7%86%E9%A2%91%E6%92%AD%E6%94%BE%E9%87%8F%E6%96%B9%E6%B3%95/) 这篇文章中了解到了可以使用 google sheet 的 apps 脚本 直接获取油管的播放量。
|
||||
|
||||
不过这篇文章中的脚本更多的获取当前的播放量,而不是定时获取,因此我在这个脚本的基础上进行了一些修改,来实现定时获取播放量,然后把时间和对应的播放量的信息存到 sheet 中。
|
||||
|
||||
最终的效果如图所示。[杂货铺播放量记录 - Google 表格](https://docs.google.com/spreadsheets/d/12l5v7V-lyHFXw1KkgGAFtnvbVejrKshOLGsulLf8P1A/edit?usp=sharing)
|
||||
|
||||

|
||||
|
||||
## 操作教程
|
||||
|
||||
第一步,在 sheet 中的原始模板是这样的:
|
||||
|
||||
| 链接 | 视频 id | 时间 | 播放量 |
|
||||
| ------------------------------------------------------------------------------------------ | ---------------------------------------------------------- | --- | --- |
|
||||
| [https://www.youtube.com/watch?v=Eia_Sh_ZTyQ](https://www.youtube.com/watch?v=Eia_Sh_ZTyQ) | =MID(A2, FIND("v=", A2) + 2, LEN(A2) - FIND("v=", A2) - 1) | | |
|
||||
|
||||
在第一列写上要监听的油管的链接,然后视频的 id 通过公式直接计算出来。
|
||||
|
||||
第二步,点击 extentions - apps script 这里,跳转到脚本配置界面。
|
||||
|
||||

|
||||
|
||||
点击左侧的 services 的加号,添加 YouTube Data API v3,标识符、版本直接默认就可以了。
|
||||
|
||||

|
||||
|
||||
第三步,把代码复制到 Code.gs 中,效果如图:
|
||||
|
||||
``` js
|
||||
function onOpenFunc() {
|
||||
PropertiesService.getScriptProperties().setProperty("accessToken", ScriptApp.getOAuthToken());
|
||||
}
|
||||
|
||||
function getVideoViews(videoid) {
|
||||
var accessToken = PropertiesService.getScriptProperties().getProperty('accessToken');
|
||||
|
||||
// Check if the access token exists
|
||||
if (!accessToken) {
|
||||
Logger.log('No access token found.');
|
||||
return 'Error: No access token';
|
||||
}
|
||||
|
||||
try {
|
||||
var videoStatsResponse = YouTube.Videos.list('statistics', {
|
||||
'id': videoid,
|
||||
'access_token': accessToken
|
||||
});
|
||||
|
||||
// Check if the response contains the expected data
|
||||
if (videoStatsResponse.items && videoStatsResponse.items[0] && videoStatsResponse.items[0].statistics) {
|
||||
return videoStatsResponse.items[0].statistics.viewCount;
|
||||
} else {
|
||||
Logger.log('No statistics found for video ID: ' + videoid);
|
||||
return 'Error: No statistics';
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.log('Error fetching statistics for video ID ' + videoid + ': ' + error.toString());
|
||||
return 'Error: ' + error.toString();
|
||||
}
|
||||
}
|
||||
|
||||
function recordYouTubeViewCount() {
|
||||
// 获取活动表格
|
||||
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
|
||||
|
||||
// 获取第二行的 ID
|
||||
var videoId = sheet.getRange(2, 2).getValue();
|
||||
|
||||
// 获取当前时间
|
||||
var currentTime = new Date();
|
||||
|
||||
try {
|
||||
// 获取播放量
|
||||
var viewCount = getVideoViews(videoId);
|
||||
|
||||
// 获取当前表格的最后一行
|
||||
var lastRow = sheet.getLastRow();
|
||||
|
||||
// 在最后一行之后插入新行,并填写时间和播放量
|
||||
sheet.insertRowAfter(lastRow);
|
||||
sheet.getRange(lastRow + 1, 3).setValue(currentTime); // 设置时间
|
||||
sheet.getRange(lastRow + 1, 4).setValue(viewCount); // 设置播放量
|
||||
} catch (error) {
|
||||
// 错误处理
|
||||
Logger.log('Error processing video ' + videoId + ': ' + error.toString());
|
||||
|
||||
// 如果发生错误,记录错误信息
|
||||
var lastRow = sheet.getLastRow();
|
||||
sheet.insertRowAfter(lastRow);
|
||||
sheet.getRange(lastRow + 1, 3).setValue(currentTime); // 设置时间
|
||||
sheet.getRange(lastRow + 1, 4).setValue('Error: ' + error.toString()); // 设置错误信息
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||

|
||||
|
||||
然后如果要验证是否正确,选择 recordYouTubeViewCount,然后点击 run 按钮。不出意外的话会在 sheet 中新增一行记录。
|
||||
|
||||

|
||||
|
||||
第四步,也是最后一步,我们要设置一下 trigger,来实现定时地查询播放量并且写入到 sheet 中。点击左边侧边栏的 trigger 菜单,再点击右下角的 add trigger.
|
||||
|
||||

|
||||
|
||||
设置如下,配置完成后点击 save 按钮。
|
||||
|
||||

|
||||
|
||||
点击完之后,可能出现一个验证弹窗,需要你选择自己的 google 账号,然后点击 go to xxx project (unsave), 点击 allow 进行授权。(这里没有保留截图,但或许大概应该能直接看懂?)
|
||||
|
||||
然后我们就完成了所有的配置,等待一小时后看是否运行正常即可。
|
||||
|
||||
## 参考和鸣谢
|
||||
|
||||
这个脚本是在 [批量统计YouTube视频播放量方法 - 杨哥的出海营销笔记](https://marketingyang.com/%E6%89%B9%E9%87%8F%E7%BB%9F%E8%AE%A1youtube%E8%A7%86%E9%A2%91%E6%92%AD%E6%94%BE%E9%87%8F%E6%96%B9%E6%B3%95/) 的脚本的基础上改的,感谢作者提供了很详细的教程和代码。
|
||||
|
||||
同时也要感谢 google 提供的 api.
|
@ -13,7 +13,10 @@ finished: true
|
||||
published: true
|
||||
category: 软件
|
||||
slug: raycast-imessage-2fa
|
||||
description:
|
||||
description: >-
|
||||
我做过一个messAuto的安利,使用raycast + iMessage
|
||||
2fa插件来实现iPhone和mac信息同步和自动复制验证码。最近发现作者删库了,我现在找到了一种快速获取验证码的方法。使用方法是在获取到验证码之后访问iMessage
|
||||
2fa插件,然后可以看到当前接收到的验证码,敲回车复制验证码到粘贴板。但这种方法缺点是没有messAuto方便,多了额外的步骤。
|
||||
toAstro: true
|
||||
---
|
||||
|
||||
@ -38,4 +41,4 @@ toAstro: true
|
||||
|
||||

|
||||
|
||||
缺点:没有 messauto 方便,多了访问 imessage 2fa 插件和敲回车复制验证码的步骤。
|
||||
缺点:没有 messauto 方便,多了访问 imessage 2fa 插件和敲回车复制验证码的步骤。
|
||||
|
Reference in New Issue
Block a user