AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 684116
Accepted
student
student
Asked: 2021-12-28 15:06:29 +0800 CST2021-12-28 15:06:29 +0800 CST 2021-12-28 15:06:29 +0800 CST

使用 youtube-dl 从 youtube 频道下载和排序所有视频列表

  • 772

我想下载一个 youtube 频道的所有视频列表并按时长排序。这是我用youtube-dl resp 尝试过的。yt-dlp:

yt-dlp --skip-download "url_to_channel" --get-duration --get-title > list

然后像cat list | sed '$!N;s/\n/ /g' | sort. 但是,这不起作用,因为持续时间是第二个打印的(并且sort -k2由于标题包含空格而无济于事)。

在一天结束时,我还想获取 url 和标题,然后将其通过管道传输到 html 文件(或乳胶-> pdf)以获取带有可点击 url 和缩略图的列表(这不是这个问题的内容,但是你写答案时可能会想到这一点;我只想先解决上面的简单案例)。

编辑

例如:

yt-dlp --skip-download "https://www.youtube.com/user/emacsrocks/videos" --get-duration --get-title > list_test

结果是

cat list_test

Parens of the Dead Live - Preparing for a new game, bonus stream, live on Twitch
1:06:45
Parens of the Dead Live - Improving the code 3 years later, live on Twitch
1:55:55
Emacs Rocks! Episode 17: Magit
2:39
Emacs Rocks! Episode 16: Dired
1:35
Parens of the Dead - Episode 8: The Hour of Reckoning
9:52
Parens of the Dead - Episode 7: Eaten by Zombies
3:50
Parens of the Dead - Episode 6: Quickly, hide!
9:44
Parens of the Dead - Episode 5: Re-animated
9:09
Parens of the Dead - Episode 4: Waking the Dead
4:59
Parens of the Dead - Episode 3: What Lies Beneath
9:27
Parens of the Dead - Episode 2: Frontal Assault
8:02
Parens of the Dead - Episode 1: Lying in the Ground
11:33
Emacs Rocks! Episode 15: restclient-mode
2:24
Emacs Rocks at WebRebels! Part 05: more js2-refactor
55
Emacs Rocks at WebRebels! Part 04: more js2-refactor
1:58
Emacs Rocks at WebRebels! Part 03: js2-refactor
59
Emacs Rocks at WebRebels! Part 02: multiple-cursors
41
Emacs Rocks at WebRebels! Part 01: Jumping to the next slide
2:19
Emacs Rocks! Episode 14: Paredit
3:25
Extending Emacs Rocks! Episode 08
8:10
Extending Emacs Rocks! Episode 07
11:06
Emacs Rocks! Episode 13: multiple-cursors
3:56
Emacs Rocks! Episode 12: Working with HTML
1:54
Extending Emacs Rocks! Episode 06
9:26
Emacs Rocks! Episode 11: swank-js
4:35
Extending Emacs Rocks! Episode 05
9:18
Extending Emacs Rocks! Episode 04
10:44
Extending Emacs Rocks! Episode 03
10:32
Extending Emacs Rocks! Episode 01
11:15
Extending Emacs Rocks! Episode 02
8:00
Emacs Rocks! Live at WebRebels
18:18
Emacs Rocks! Episode 10: Jumping around
2:07
Emacs Rocks! Episode 09: expand-region
2:39
Emacs Rocks! Episode 08: mark-multiple
1:30
Emacs Rocks! Episode 07: Mind. Exploded.
1:30
Emacs Rocks! Episode 06: Yeah! Snippets!
1:41
Emacs Rocks! Episode 05: Macros in style
1:31
Emacs Rocks! Episode 04: A rebind controversy
2:32
Emacs Rocks! Episode 03: A vimgolf albatross
2:15
Emacs Rocks! Episode 02: A vimgolf eagle
3:15
Emacs Rocks! Episode 01: From var to this
2:47
awk sed
  • 1 1 个回答
  • 1866 Views

1 个回答

  • Voted
  1. Best Answer
    Eduardo Trápani
    2021-12-28T17:29:35+08:002021-12-28T17:29:35+08:00

    您可以要求youtube-dl输出json数据,然后对其进行处理jq(您将可以访问所有字段,而不仅仅是带有get-...标志的字段)。

    这个命令:

    youtube-dl --dump-json "https://www.youtube.com/user/emacsrocks/videos" | jq -r '[.duration,.title]|@csv'
    

    将输出:

    4005,"Parens of the Dead Live - Preparing for a new game, bonus stream, live on Twitch"
    6955,"Parens of the Dead Live - Improving the code 3 years later, live on Twitch"
    159,"Emacs Rocks! Episode 17: Magit"
    95,"Emacs Rocks! Episode 16: Dired"
    592,"Parens of the Dead - Episode 8: The Hour of Reckoning"
    230,"Parens of the Dead - Episode 7: Eaten by Zombies"
    ...
    91,"Emacs Rocks! Episode 05: Macros in style"
    152,"Emacs Rocks! Episode 04: A rebind controversy"
    135,"Emacs Rocks! Episode 03: A vimgolf albatross"
    195,"Emacs Rocks! Episode 02: A vimgolf eagle"
    167,"Emacs Rocks! Episode 01: From var to this"
    

    然后,您可以使用例如sort.

    • 3

相关问题

  • 如何改进这个字符转换脚本?

  • 如何删除两行之间的单行

  • 重新排列字母并比较两个单词

  • 多行文件洗牌

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve