3

このスクリプトを使用して、Pythonを使用してYouTubeビデオをダウンロードしようとしています。

現在私はこれを次のように使用しています

youtube-dl "http://www.youtube.com/watch?v=dvsdgyuv"

ドキュメントでは、私がこれらを使用できると書いています

id: The sequence will be replaced by the video identifier.
url: The sequence will be replaced by the video URL.
uploader: The sequence will be replaced by the nickname of the person who uploaded the video.
upload_date: The sequence will be replaced by the upload date in YYYYMMDD format.
title: The sequence will be replaced by the literal video title.
stitle: The sequence will be replaced by a simplified video title, restricted to alphanumeric characters and dashes.
ext: The sequence will be replaced by the appropriate extension (like flv or mp4).
epoch: The sequence will be replaced by the Unix epoch when creating the file.
autonumber: The sequence will be replaced by a five-digit number that will be increased with each download, starting at zero.`enter code here`

彼らは私がそれをどのように使うことができるかを書いていません。

ビデオファイル名をタイトルと同じにするためにどのように使用できますか?

彼らはこれを使うように言いました、しかし私はこれをコマンドラインで使う方法を知りません。

%(title)s-%(id)s.%(ext)s.
4

3 に答える 3

4

最善の策はhttp://np1.github.io/pafy/です。それは揺れる、100%!

于 2013-10-14T07:31:29.317 に答える
3

ドキュメントの下部には、次のように記載されています。

-oオプションを使用すると、ユーザーは出力ファイル名のテンプレートを指定できます。基本的な使用法は、youtube-dl -o Funny_video.flv "http:// some / video"のように、単一のファイルをダウンロードするときにテンプレート引数を設定しないことです。ただし、各ビデオをダウンロードするときに置き換えられる特別なシーケンスが含まれている場合があります。 特別なシーケンスの形式は%(NAME)sです。明確にするために、これはパーセント記号の後に括弧で囲まれた名前が続き、その後に小文字のSが続きます。許可される名前は次のとおりです。

次のようなコマンドを実行して、これらの特別な出力パラメーターを使用します。

youtube-dl "http://www.youtube.com/watch?v=dvsdgyuv" -o "%(title)s-%(id)s.%(ext)s."
于 2011-05-29T05:26:29.123 に答える
0

Pythonスクリプトの場合:

import youtube_dl

youtube_playlist_url = 'youtube_playlist_url'
destination_folder = './youtube_playlist/'

ydl_opts = {'outtmpl': destination_folder+'/%(title)s.%(ext)s'}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download([youtube_playlist_url])

出典:https ://www.youtube.com/watch?v = Mn0zj8Ql7Fs

于 2020-08-19T10:02:33.470 に答える