阿里云盘上传脚本

Overview

阿里云盘上传脚本

如有侵权,请联系我删除

禁止用于非法用途,违者后果自负

环境要求

  • python3

使用方法

安装

git clone https://github.com/Hidove/aliyundrive-uploader.git
cd aliyundrive-uploader
pip install -r requirements.txt

如果执行pip install时提示-bash: pip: command not found 就是pip命令没有安装,执行下方命令安装即可,然后再执行即可

wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
  • 重命名example.config.jsonconfig.json
  • 填写好config.json的内容

{
  "REFRESH_TOKEN": "refresh_token",
  "DRIVE_ID": "drive_id",
  "ROOT_PATH": "网盘目录",
  "FILE_PATH": "D:\\Pictures\\",
  "MULTITHREADING": false,
  "MAX_WORKERS": 5,
  "CHUNK_SIZE": 104857600
}
参数 注释
REFRESH_TOKEN 阿里云盘刷新的token
DRIVE_ID 阿里云盘驱动ID,目前不知道做何使用的,可能后续官方有新想法吧
ROOT_PATH 阿里云盘目录 我的照片
FILE_PATH 文件夹目录,填写绝对路径 D:\Pictures\
MULTITHREADING 是否启用多线程 true/false
MAX_WORKERS 线程池最大线程数,请根据自己机器填写 5
CHUNK_SIZE 分块上传大小,请根据自己机器填写,单位:字节 104857600
RESUME 断点续传,分块续传 true/false

运行

chmod +x main.py

多文件上传

python3 main.py
python3 main.py /www/wwwroot/download/

单文件上传

python3 main.py /www/lixiaoen.jpg

更新

cd ~/aliyundrive-uploader
git fetch --all 
git reset --hard origin/master 
git pull

文件解读

  • config.json
    • 脚本配置文件
  • task.json
    • 脚本上传任务记录文件
  • /log
    • 脚本执行记录

支持

觉得写得不错可以给我打赏哦

Comments
  • 上传文件时报错

    上传文件时报错

    {"code":"InvalidParameter.ContentHash","message":"The input parameter content_hash is not valid. file content hash is not matched with content_hash in complete file request"}

    opened by gifyic 12
  • 开始上传后报错

    开始上传后报错

    检索目录中 目录id获取成功60898fee4524df8614d74fa6a9df689e35b4ea0a 正在上传: 1%|1 | 53.0M/6.84G [00:30<1:06:53, 1.82MB/s] Traceback (most recent call last): File "/root/aliyundrive-uploader/main.py", line 137, in if res.result(): File "/usr/lib/python3.9/concurrent/futures/_base.py", line 438, in result return self.__get_result() File "/usr/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result raise self._exception File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/root/aliyundrive-uploader/main.py", line 61, in upload_file drive.upload(upload_url) File "/root/aliyundrive-uploader/AliyunDrive.py", line 117, in upload res.raise_for_status() File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://bj29.cn-beijing.data.alicloudccp.com/xYBXOEkb%2F69848%2F608991ae51a2863ccd5b466b8bf84ab711c83d46%2F608991ae11f21bbc22964fbbaf08e0f2fca9d24f?Expires=1619632062&OSSAccessKeyId=LTAIsE5mAn2F493Q&Signature=IUxxWsQ36QnVxA0W%2FnwWESNHsfs%3D&partNumber=1&uploadId=658982D766A74E5AB6BB7D64A564C38C

    opened by zsbai 9
  • 能加断点续传吗?

    能加断点续传吗?

    我一个1G的文件从Ubuntu 20.04服务器上传到阿里云网盘老是出错,每次都有重新开始传,错误提示:

    pipes-presentation-20210423.mp4正在校检文件中,耗时与文件大小有关 文件名:11-pipes-presentation-20210423.mp4 hash:4817bcc8425ac8be2264ff379887a64b0f46e661 文件大小:1134460273 文件路径:youtube/11-pipes-presentation-20210423.mp4

    检索目录中 目录id获取成功6073f804da645896ab184012afdfd4e0c7fe9ab3 Traceback (most recent call last): File "main.py", line 137, in if res.result(): File "/usr/lib/python3.8/concurrent/futures/_base.py", line 432, in result return self.__get_result() File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result raise self._exception File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "main.py", line 61, in upload_file drive.upload(upload_url) File "/root/aliyundrive-uploader/AliyunDrive.py", line 117, in upload res.raise_for_status() File "/usr/local/lib/python3.8/dist-packages/requests/models.py", line 943, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://bj29.cn-beijing.data.alicloudccp.com/4oW5G1mH%2F27564%2F6088ab6af27e6944c74c4b0aa509838b6182e85d%2F6088ab6a58520b3afd2b480a8a7b020fa7df8982?Expires=1619573114&OSSAccessKeyId=LTAIsE5mAn2F493Q&Signature=xEewGJ4QSlF1Ir8u7%2Bd0biuKyp4%3D&partNumber=1&uploadId=BD00C9F4C9CF4E2B8C71C5620236BB42

    opened by ddfiberglass 7
  • 是否可以跳过文件校检(哈希),直接上传

    是否可以跳过文件校检(哈希),直接上传

    现在上传文件前都需要检查文件哈希值,如果云端存在该文件,就会秒传。

    我会打包并加密上传的照片,因此每个文件必定是独一无二的,因此希望直接跳过哈希计算,直接上传。

    由于每次会上传数百G的文件,浪费CPU也浪费电,浪费煤炭,产生二氧化碳,污染环境。。。(喂扯远了。。)

    希望能稍微增加一个配置选项。谢谢!

    opened by lesca 5
  • 关于应用性能的建议

    关于应用性能的建议

    建议重写ACCESS_TOKEN管理服务

    • Aliyundrive当前阶段ACCESS_TOKEN约每2h刷新一次,而本项目关于ACCESS_TOKEN管理方案似乎并不科学。

    • 大概看了一下源码,本人认为本项目的ACCESS_TOKEN处于欠初始化状态。配置文件中只要求开发者(首次)手动获取DRIVE_IDREFRESH_TOKEN(然而完全可以手动初始化ACCESS_TOKEN因为它们就隔了一行,如README中的截图所示),于是程序运行后(无论ACCESS_TOKEN是否真的失效),都会在上传任务正式开始前被重新更新一次,并且在后续长段时间内子线程通过强竞争的方式进行”倒计时600s被动更新ACCESS_TOKEN“的任务。

    • 这会引发一系列难以应付的问题,check_auth()被放置在如“新建网盘目录”等多个核心业务当中。当用户配置多线程下载大量(指向目录的)小文件时,每个“分发线程”都会执行一次ACCESS_TOKEN更新请求。

    • 此外,ThreadPoolExecutor(max_workers=None, thread_name_prefix='', initializer=None, initargs=())在 3.5 版本后,如果 max_workers 为 None 或没有指定,将默认为机器处理器的个数而非1;在3.8版本后则默认启动至少5个核心线程min(32, os.cpu_count() + 4),所以我们可能消耗了成倍的资源的去”计算“更新时间,程序也会在某个时间点频繁更新权限出现“绊脚”的情况。

    建议使用 Coroutine-Pool 多路复用协程池管理任务队列

    使用通信共享内存,而不是使用内存通信。

    本项目中写满了子线程的竞争行为,这在批量传输小文件时将带来极大的性能损耗。可以使用gevent等优秀的协程框架处理密集I/O业务,在虚拟线程阻塞时让出资源,也能更加方便地管理事务回滚以及标记异常实例。

    opened by QIN2DIM 4
  • 后台运行机制代码存在bug

    后台运行机制代码存在bug

    Client.py文件中,第77行判断是否有后台运行参数时,如果存在,立刻删除会导致后面数组访问越界,原始代码如下。

    77 def init_command_line_parameter(self): 78 for k in range(len(sys.argv)): 79 if sys.argv[k] == '--resident' or sys.argv[k] == '-r': 80 DATA['config']['RESIDENT'] = True 81 del sys.argv[k]

    报错情况为: Traceback (most recent call last): File "/root/aliyundrive-uploader-master/main.py", line 26, in client.init_command_line_parameter() File "/root/aliyundrive-uploader-master/Client.py", line 77, in init_command_line_parameter if sys.argv[k] == '--resident' or sys.argv[k] == '-r': IndexError: list index out of range

    修改建议,增加标识位,for循环后再删除,如 label = -1 for k in range(len(sys.argv)): if sys.argv[k] == '--resident' or sys.argv[k] == '-r': DATA['config']['RESIDENT'] = True label = k if label>-1: del sys.argv[label]

    bug 
    opened by Nuaalzy 4
  • 上传中出现错误

    上传中出现错误

    win10 编译版本

    Traceback (most recent call last): File "main.py", line 51, in File "common.py", line 161, in print_info File "common.py", line 208, in log UnicodeEncodeError: 'gbk' codec can't encode character '\u200b' in position 69: illegal multibyte sequence

    [4044] Failed to execute script 'main' due to unhandled exception!

    opened by seeblog 2
  • 这种报错能否跳过,程序停下来了。

    这种报错能否跳过,程序停下来了。

    正在上传【0138 - 五一假期带孩子出去玩怎么拍美美的亲子照?.mp4】: 100MB [00:00, ?B/s] {'code': 'InvalidParameter.ContentHash', 'message': 'The input parameter content_hash is not valid. file content hash is not matched with content_hash in complete file request'}

    opened by luolovehk 2
  • Update common.py

    Update common.py

    优化大文件,添加从文件读取sha1。

    超过1T的文件,由于上传太长,上传过程中会出现上传地址失效的情况。这时如果重新上传,会再次计算sha1,然而每次计算sha1都会花费好几个小时,因此添加了这个功能。 实现比较简单,也没有考虑太多异常情况,希望作者在此基础上优化一下。这个功能对于大文件来说至关重要!感谢作者! PS: 尝试了rclone/WebDAV和其他的API后,发现这个工具是最棒的,真心感谢!

    opened by ihobin 2
  • 无法使用绝对路径上传

    无法使用绝对路径上传

    image

    单文件上传如果是传入绝对路径参数,config里的FILE_PATH为空时会出现如图的报错,文件路径变成了脚本的运行目录,如果将FILE_PATH改成文件路径就能正常上传

    所以这个FILE_PATH有什么作用吗,能否直接通过传入的路径参数修改该值?如果每次上传都要填一遍FILE_PATH岂不是很麻烦

    opened by auqhjjqdo 2
  • 建议增加日志功能

    建议增加日志功能

    首先非常感谢作者的无私分享,这个项目相当实用好用,我也非常有需求。相比Rclone机械性的上传,这个项目最大优势是支持秒传,我现在主要是利用qbittorrent下载完成后调用这个项目上传下载完的文件至阿里云盘,由于该过程均在VPS后台运行,故希望增加日志功能,便于时候查看上传的具体情况,最后再次致敬!

    opened by xiatao 1
Releases(v2.2.1)
Owner
Hidove
Hidove
A Telegram Bot with(Forwarder Bot + User Bot + More Features )

A Telegram Bot with(Forwarder Bot + User Bot + More Features )

Kaif 3 Feb 16, 2022
CyberTKR - CyberTK-API

CyberTKR - CyberTK-API

TKR 2 Apr 08, 2022
A Telegram Bot written in Python for mirroring files on the Internet to Google Drive

No support is going to be provided of any kind, only maintaining this for vps user on request. This is a Telegram Bot written in Python for mirroring

0 Dec 26, 2021
Deploy your apps on any Cloud provider in just a few seconds

The simplest way to deploy your apps in the Cloud Deploy your apps on any Cloud providers in just a few seconds ⚡ Qovery Engine is an open-source abst

Qovery 1.9k Dec 26, 2022
Get some python in google cloud functions

[NOTE]: This is a highly experimental (and proof of concept) library so do not expect all python packages to work flawlessly. Also, cloud functions ar

Martin Abelson Sahlen 200 Nov 24, 2022
Video Stream: an Advanced Telegram Bot that's allow you to play Video & Music on Telegram Group Video Chat

Video Stream is an Advanced Telegram Bot that's allow you to play Video & Music on Telegram Group Video Chat 🧪 Get SESSION_NAME from below: Pyrogram

Jonathan 6 Feb 08, 2022
A Telegram bot to download from Youtube server.

IDN-YoutubeDL-Bot A Telegram bot to download from Youtube server. Configs 📖 API_ID - Your APP ID. Get it from my.telegram.org API_HASH - Your API_HAS

IDNCoderX 4 Dec 02, 2022
A light wrapper around FedEx's SOAP API.

Python FedEx SOAP API Module Author: Greg Taylor, Radek Wojcik Maintainer: Python FedEx Developers License: BSD Status: Stable What is it? A light wra

155 Dec 16, 2022
A stack-based systems language that supports structures, functions, expressions, and user-defined operator behaviour

A stack-based systems language that supports structures, functions, expressions, and user-defined operator behaviour. Currently compiles to URCL with plans to add additional formats in the future.

Lucida Dragon 3 Nov 03, 2022
A website application running in Google app engine, deliver rss news to your kindle. generate mobi using python, multilanguages supported.

Readme of english version refers to Readme_EN.md 简介 这是一个运行在Google App Engine(GAE)上的Kindle个人推送服务应用,生成排版精美的杂志模式mobi/epub格式自动每天推送至您的Kindle或其他邮箱。 此应用目前的主要

2.6k Jan 06, 2023
A python based Telegram Bot for Compressing Videos with negligible Quality change

𝕍𝕚𝕕𝕖𝕠 ℂ𝕆𝕄ℙℝ𝔼𝕊𝕊𝕆ℝ 𝔹𝕆𝕋 ᴍᴜʟᴛɪғᴜɴᴄᴛɪᴏɴ ǫᴜᴀʟɪᴛʏ ᴄᴏᴍᴘʀᴇssᴏʀ A Telegram Video CompressorBot it compress videos with negligible Quality change.

Danish 154 Dec 04, 2022
unofficial library for discord components(on development)

discord.py-buttons unofficial library for discord buttons(on development) Install pip install --upgrade discord_buttons Example from discord import Cl

kiki7000 129 Dec 31, 2022
Boto is a Python package that provides interfaces to Amazon Web Services.

Boto is a Python package that provides interfaces to Amazon Web Services.

the boto project 6.5k Jan 01, 2023
Fetch the details of assets hosted on AWS.

onaws onaws is a simple tool to check if an IP/hostname belongs to the AWS IP space or not. It uses the AWS IP address ranges data published by AWS to

Amal Murali 80 Dec 29, 2022
Upvotes and karma for Discord: Heart 💗 or Crush 💔 a comment to give points to an user, or Star ⭐ it to add it to the Best Of!

🤖 Reto Reto is a community-oriented Discord bot, featuring a karma system, a way to reward the best comments, leaderboards, and so much more! React t

Erik Bianco Vera 3 May 07, 2022
An script where it logs in your instagram account and follows people and likes their posts

InstaFollower An script where it logs in your instagram account and follows people and likes their posts (uses the tags to fetch people) Requirements:

Bless 3 Nov 29, 2022
veez music bot is a telegram music bot project, allow you to play music on voice chat group telegram.

🎶 VEEZ MUSIC BOT Veez Music is a telegram bot project that's allow you to play music on telegram voice chat group. Requirements 📝 FFmpeg NodeJS node

levina 143 Jun 19, 2022
Multi-purpose bot made with discord.py

PizzaHat Discord Bot A multi-purpose bot for your server! ℹ️ • Info PizzaHat is a multi-purpose bot, made to satisfy your needs, as well as your serve

DTS 28 Dec 16, 2022
Yes, it's true :purple_heart: This repository has 353 stars.

Yes, it's true! Inspired by a similar repository from @RealPeha, but implemented using a webhook on AWS Lambda and API Gateway, so it's serverless! If

510 Dec 28, 2022
A fully responsive interface to manage all your favorite software on your HTPC.

Python 3 port of Hellowlol's HTPC Manager fork We made this an organization repository to be more independent from single developers. If you want to j

26 Jan 04, 2023