下载Dropbox文件夹中存在的所有.mp4文件

问题描述 投票:2回答:1

具有访问令牌后,从Dropbox using the API下载文件很简单。

然后,使用方法sharing_get_shared_link_file可以简单地运行

import dropbox
dbx = dropbox.Dropbox("ACCESS_TOKEN")
#dbx.users_get_current_account()
with open("test1.mp4", "wb") as f:
    metadata, res = dbx.sharing_get_shared_link_file("https://www.dropbox.com/s/kowz06jo7i3xyv2/you_saved_me.mp4?dl=0")
    f.write(res.content)

您可以在URL中看到,/ s /表示我们正在处理一个文件。

实际上,有时它不是一个文件,而是文件所在的文件夹,因此链接将包含/ sh /

如何下载一个特定文件夹中的所有.mp4文件(without .zip?]

作为参考,创建了一个包含三个.mp4文件的文件夹-https://www.dropbox.com/sh/r85vzhq0xxa146s/AAASRlyR-C9ITAd0Cww0Sr9Za?dl=0

Dropbox folder with multiple .mp4 files in it

python python-3.x download dropbox mp4
1个回答
2
投票

[如果具有指向包含文件的文件夹的共享链接,而不仅仅是指向特定文件的共享链接,则可以使用files_list_folderfiles_list_folder列出该文件夹的内容。您可以通过在files_list_folder_continuefiles_list_folder_continue参数中输入URL来实现。

结果将包含有关内容的信息,例如每个的shared_link

然后您可以使用它来构建files_list_folder,然后传递给files_list_folder以下载每个所需的文件。

根据您现有的代码和URL,看起来像这样:

name
© www.soinside.com 2019 - 2024. All rights reserved.