跳转至

将Youtube视频转为podcast播客源

Tip

必备:

  1. 可访问Youtube的机器,机器安装dockercompose

  2. YouTube API Key,可看这篇教程获取

安装podsync

新建目录podsync,创建compose文件

docker-compose.yml
services:
  podsync:
    container_name: podsync
    image: mxpv/podsync:latest
    restart: always
    ports:
      - 8080:8080
    volumes:
      - ./data:/app/data/
      - ./config.toml:/app/config.toml
      - ./cookies.txt:/app/cookies.txt  # (1)!
  1. 可选,如果下载时报Sign in to confirm you’re not a bot.需添加cookies 具体看F&Q

配置文件

podsync目录内新建配置文件config.toml

config.toml
[server]
port = 8080
hostname = "http://192.168.1.1:8080/" # 如果是本地服务器,就是需要播客抓取源的地址;此处填写 IP 地址或者域名,如果有HTTPS证书的话记得改成 https://
data_dir = "/app/data" # 不要改动这个地方!

# Tokens from `Access tokens` section
[tokens]
youtube = "YouTube API Key" # 引号内填写 YouTube API Key.

[feeds]
  [feeds.ID1]
  # ID1 为最终生成的RSS文件的名称,可以修改
  url = "www.youtube.com/playlist" # 引号内填写Youtube频道/组织/用户/播放列表的链接,注意不要有 http:// 部分!!!
  page_size = 10 # 每次更新节目时的分页大小
  playlist_sort = "desc" #倒序,正序asc
  update_period = "24h" # 更新周期,例如: "60m", "4h", "2h45m"
  cron_schedule = "10 1 * * *" #crontab更新方式
  quality = "high" # 文件品质高-high,或低-low
  format = "audio" # 文件类型音频-audio,视频-video,通常播客使用音频类型即可
  # filters = { title = "111", not_title = "222", description = "333", not_description = "444" } # [可选项,使用时去除行首井号]过滤节目,只保留「标题含有111,不含222,描述包含 333,不含 444 的节目」
  # clean = { keep_last = 10 } # 自动清理,只保留最近10期节目
  # 是否将该 feed 包含在 OPML 文件中(默认 false)
  opml = true
  # 下载视频时提示 Sign in to confirm you’re not a bot.时需用cookies
  youtube_dl_args =  [ "--cookies", "/app/cookies.txt"]

  # 可以配置多个 feeds
  [feeds.ID2]
  url = "www.youtube.com/playlist"
  page_size = 10
  update_period = "24h"
  cron_schedule = "20 2 * * *" #crontab更新方式
  quality = "high"
  format = "audio"
  # clean = { keep_last = 10 } # 自动清理,只保留最近10期节目
  youtube_dl_args =  [ "--cookies", "/app/cookies.txt"]
  # playlist_sort = "desc"
  # 是否将该 feed 包含在 OPML 文件中(默认 false)
  opml = true


[database]
  badger = { truncate = true, file_io = true } # 数据库配置,无需改动


# 程序运行日志配置,无需改动
[log]
filename = "podsync.log"
max_size = 50 # MB
max_age = 30 # days
max_backups = 7
compress = true

[downloader]
self_update = true
timeout = 15
cookies = "/app/cookies.txt"

播客添加源

创建成功后,访问http://192.168.1.1:8080/打开页面,里面会有多个feeds索引,及音频文件夹,找到ID1.xml文件,播客客户端内添加即可

F&Q

  1. Sign in to confirm you’re not a bot.

    YouTube 为了防止恶意爬虫或大规模自动化下载,对部分请求触发「Sign in to confirm you’re not a bot」的验证,并拒绝返回内容,提示需要登录后才能访问

    可导出cookies并上传到podsync目录。

    导出cookies可用插件Get cookies.txt LOCALLY导出为 Netscape 格式

  2. error="update failed: failed to parse duration : bad format string"

    这个报错是因为视频尚未播出,导致的,可以不用管,等播出后再下载也行

    据说这段代码可以生效,我试了下无效

    config.toml
    youtube_dl_args = [
        "--match-filters",
        "live_status!=is_upcoming",
    ]