Skip to content

搞英语 → 看世界

翻译英文优质信息和名人推特

Menu
  • 首页
  • 作者列表
  • 独立博客
  • 专业媒体
  • 名人推特
  • 邮件列表
  • 关于本站
Menu

如何使用 Google 表格自动将播客下载到 Google Drive

Posted on 2022-05-04

本教程介绍如何使用 Google 表格构建自己的播客管理器。您可以在 Google 表格中指定您最喜欢的播客节目列表,它会自动将新剧集下载到您的 Google 云端硬盘中整齐有序的文件夹中。

设置非常简单,该应用程序是完全开源的,您不需要编程语言。

Drive Podcast Manager 的工作原理是什么?

您必须将您喜欢的播客的链接放在 Google 表格的 A 列中,如下面的屏幕截图所示。

Podcasts to Google Drive

该应用程序会自动将每个播客的最新剧集下载到您的 Google 云端硬盘。您可以从 Google Drive 打开 MP3 文件,也可以直接在同一个 Google Sheet 中找到它们。

Google Sheets Podcast List

该应用程序将在您的 Google Drive 中创建一个名为Podcasts的新文件夹。在此文件夹中,它将为每个播客节目创建子文件夹,文件夹名称与播客的标题相同。

Google Drive Podcasts Folder

将播客下载到 Google 云端硬盘

以下是使用 Google 表格和 Google Drive 构建自己的播客管理器的方法。

  1. 单击此处在您的 Google 帐户中制作 Google 表格的副本。

  2. 打开复制的电子表格,切换到Subscriptions表并在 A 列中输入您最喜欢的播客的 RSS 提要链接。您可以使用我们的Apple 播客查找实用程序来查找 Apple 播客上列出的任何播客的 RSS 提要。

  3. 转到扩展菜单并选择Script Editor以打开底层 Google Apps 脚本文件。

  4. 从函数列表中选择Install函数,然后单击Run以安装应用程序。您可能必须授权该应用程序一次,因为它需要代表您将文件保存到 Google 云端硬盘的权限。

就是这样。该应用程序将创建一个在后台每隔几个小时运行一次的 cron 作业,并将您喜爱的播客的最新剧集下载到您的 Google Drive。

我们甚至在 Google 表格中嵌入了一个内置MP3 播放器,当您单击“ Play按钮时,它将播放每个播客的最新一集。

Google 表格中的 MP3 播放器

技术细节

如果你想知道整个事情是如何运作的,这里是技术细节。

该应用程序使用电子表格 API 从 Google 表格中读取播客列表。然后,它使用 Apps Script 的 XML 服务来解析 RSS 提要并提取自上次检查以来已发布的新播客剧集。

所有播客 RSS 提要都需要有一个<item>标记,其中包含一个<enclosure>标记。 <enclosure>标签包含 MP3 文件的 URL,这是应用程序用来获取相应剧集的下载 URL 的内容。

 const parseRSS = ( xmlUrl , lastUpdatedTime ) => { const feed = UrlFetchApp . fetch ( xmlUrl ) . getContentText ( ) ; const doc = XmlService . parse ( feed ) ; const root = doc . getRootElement ( ) ; const channel = root . getChild ( 'channel' ) ; const episodes = channel . getChildren ( 'item' ) . map ( ( item ) => ( { date : new Date ( item . getChildText ( 'pubDate' ) ) , title : item . getChildText ( 'title' ) , enclosure : item . getChild ( 'enclosure' ) ?. getAttribute ( 'url' ) ?. getValue ( ) , } ) ) . filter ( ( { date } ) => date > lastUpdatedTime ) . filter ( ( { enclosure } ) => enclosure ) ; return { title : channel . getChildText ( 'title' ) , episodes } ; } ;

一旦应用程序有了新剧集列表,它就会使用UrlFetch 服务下载播客,并将它们保存到 Google Drive 中特定于播客节目的文件夹中。

然后,该应用程序会在 Google 表格中写入一个新行,其中包含 Google Drive 文件的链接和下载剧集的时间戳。

 const getPodcastFolder = ( folderName ) => { const parentFolder = DriveApp . getFoldersByName ( 'Podcasts' ) . next ( ) ; const folders = parentFolder . getFoldersByName ( folderName ) ; if ( folders . hasNext ( ) ) return folders . next ( ) ; return parentFolder . createFolder ( folderName ) ; } ; const downloadPodcast = ( podcastTitle , episodeUrl , episodeTitle ) => { try { const blob = UrlFetchApp . fetch ( episodeUrl ) . getBlob ( ) ; const folder = getPodcastFolder ( podcastTitle ) ; const file = folder . createFile ( blob ) ; SpreadsheetApp . getActiveSheet ( ) . appendRow ( [ new Date ( ) , ` =HYPERLINK(" ${ episodeUrl } ";" ${ episodeTitle } ") ` , ` https://drive.google.com/file/d/ ${ file . getId ( ) } /view ` , ] ) ; } catch ( f ) { console . error ( f ) ; } } ;

原文: https://www.labnol.org/auto-download-podcasts-google-drive-220503

本站文章系自动翻译,站长会周期检查,如果有不当内容,请点此留言,非常感谢。
  • Abhinav
  • Abigail Pain
  • Adam Fortuna
  • Alberto Gallego
  • Alex Wlchan
  • Answer.AI
  • Arne Bahlo
  • Ben Carlson
  • Ben Kuhn
  • Bert Hubert
  • Bits about Money
  • Brian Krebs
  • ByteByteGo
  • Chip Huyen
  • Chips and Cheese
  • Christopher Butler
  • Colin Percival
  • Cool Infographics
  • Dan Sinker
  • David Walsh
  • Dmitry Dolzhenko
  • Dustin Curtis
  • Elad Gil
  • Ellie Huxtable
  • Ethan Marcotte
  • Exponential View
  • FAIL Blog
  • Founder Weekly
  • Geoffrey Huntley
  • Geoffrey Litt
  • Greg Mankiw
  • Henrique Dias
  • Hypercritical
  • IEEE Spectrum
  • Investment Talk
  • Jaz
  • Jeff Geerling
  • Jonas Hietala
  • Josh Comeau
  • Lenny Rachitsky
  • Liz Danzico
  • Lou Plummer
  • Luke Wroblewski
  • Matt Baer
  • Matt Stoller
  • Matthias Endler
  • Mert Bulan
  • Mostly metrics
  • News Letter
  • NextDraft
  • Non_Interactive
  • Not Boring
  • One Useful Thing
  • Phil Eaton
  • Product Market Fit
  • Readwise
  • ReedyBear
  • Robert Heaton
  • Ruben Schade
  • Sage Economics
  • Sam Altman
  • Sam Rose
  • selfh.st
  • Shtetl-Optimized
  • Simon schreibt
  • Slashdot
  • Small Good Things
  • Taylor Troesh
  • Telegram Blog
  • The Macro Compass
  • The Pomp Letter
  • thesephist
  • Thinking Deep & Wide
  • Tim Kellogg
  • Understanding AI
  • 英文媒体
  • 英文推特
  • 英文独立博客
©2025 搞英语 → 看世界 | Design: Newspaperly WordPress Theme