pyTube 下载的音乐不能在收割者中使用

pyTube downloaded music cannot be used in reaper

提问人:MonadoMaster0 提问时间:11/1/2023 更新时间:11/1/2023 访问量:21

问:

我使用 pytube 下载我在 YouTube 上创建的播放列表。我尝试过的媒体播放器(经典媒体播放器,VLC 媒体播放器,Windows Media Player)可以播放所有文件,但由于某种原因,收割者无法导入它们。有谁知道为什么会这样?

这是我使用的代码


from pytube import Playlist, YouTube
from pathlib import Path

actual = Path.cwd()
guerilla = Playlist("https://www.youtube.com/playlist?list=PL8ig_PduC0sKgSva6_tzdfZCkLp7jdAFF")
ext = "mp3"

def checkAuthor(yt):
    if "-" not in yt.title:
        try:
            return yt.author.split(sep=" - ")[1]
        except IndexError:
            return yt.author
    else: return ""

for index, music in enumerate(guerilla):

    curr = YouTube(
        music,
        use_oauth=True,
        allow_oauth_cache=True
        )

    id = curr.streams.get_audio_only()

    Path.mkdir(filePath, exist_ok=True)
    filePath = actual / "music"
    name = str(index+1) + " " + checkAuthor(curr) + " - " + curr.title + "." + ext
    completePath = filePath/name
    curr.streams.filter(file_extension=ext)

    toDown = curr.streams.get_by_itag(id.itag)
    toDown.download(filePath,name, skip_existing=True)


我尝试安装 LAME、ffmpeg 和 VLC,但没有帮助。此外,我意识到我可以使用我从互联网上下载的任何其他音频文件。

Python 音频 损坏 pytube 收割者

评论

0赞 Random Davis 11/1/2023
id = curr.streams.get_audio_only()仅供参考,您不应该调用某些东西或任何其他内置名称。id
0赞 Random Davis 11/1/2023
有很多很多潜在的调试信息没有包含。如果运行,结果是什么?可用音频的实际流媒体格式是什么?当您通过 过滤时,还剩下哪些流?它真的会从中删除不需要的吗,你验证过吗?从该库的源代码来看,它似乎只是返回过滤后的结果,但我还没有完全检查。curr.streams.filter(only_audio=True)curr.streams.filtercurrcurr
0赞 ApaxPhoenix 11/2/2023
^,过滤掉具有不受支持的收割者视频文件类型的视频,并尝试将其加载。

答: 暂无答案