阿里云盘上传脚本

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
Python client for the iNaturalist APIs

pyinaturalist Introduction iNaturalist is a community science platform that helps people get involved in the natural world by observing and identifyin

Nicolas Noé 79 Dec 22, 2022
Stackoverflow Telegram Bot With Python

Template for Telegram Bot Template to create a telegram bot in python. How to Run Set your telegram bot token as environment variable TELEGRAM_BOT_TOK

PyTopia 10 Mar 07, 2022
A Webhook spammer For Python

Webhooker Optimizations Asynchronous Fast & Efficient Multi Tasked Usage Put high threads/tasks for maximum impact Webhook must be valid Proof of conc

andria 1 Dec 20, 2021
Template to create a telegram bot in python

Template for Telegram Bot Template to create a telegram bot in python. How to Run First add src to PYTHONPATH: export PYTHONPATH=${PWD} Then run: pyt

Ali Hejazizo 12 Dec 24, 2022
A simple versatile telgeram bot written in Python using pyTelegramBotAPI library.

A simple versatile telgeram bot written in Python using pyTelegramBotAPI library.

Benyamin Zojaji 15 Jun 17, 2022
Windows版本微信客户端(非网页版)自动化,可实现简单的发送、接收微信消息

wxauto Windows版本微信客户端自动化,可实现简单的发送、接收微信消息

357 Dec 29, 2022
Cyber Userbot

Cyber Userbot

Irham 0 May 26, 2022
Python script to Funge NFTs.

Python script to Funge NFTs. It scrapes OpenSea for a given list of NFT collections and downloads a certain number of NFTs from each collection or the entire collections.

3 Apr 28, 2022
→ Comando Básico para Python Discord

Discord.py · Código @client.event async def on_ready(): print('He iniciado sessión en: {0.user}'.format(client)) @client.event async def on_messa

Panda.xyz 4 Mar 12, 2022
Simple stock price analytics

mune · Mune is an open source python web application built to analyze stocks, named after Homma Munehisa. Currently, the forecasting component is powe

Richard Hong 14 Aug 30, 2021
buys ethereum based on graphics card moving average price on ebay

ebay_trades buys ethereum based on graphics card moving average price on ebay Built as a meme, this application will scrape the first 3 pages of ebay

ConnorCreate 41 Jan 05, 2023
Graviti TensorBay Python SDK

TensorBay Python SDK is a python library to access TensorBay and manage your datasets. It provides: A pythonic way to access your

Graviti 72 Aug 22, 2022
Discord Bot written in Python that plays music in your voice channel

Discord Bot that plays music! I decided to create a simple Discord bot using Python in order to advance my coding skills. Please don't ask me for help

Eric Yeung 39 Jan 01, 2023
Frwdit-V1 - A Simple Bot can copy any media to a private channel provided

📠 Auto Forward V2 A Simple Bot can copy any media to a private channel provided

FUCK OFF ANE 3 Dec 03, 2022
Sukoshi is a proof-of-concept Python implant that leverages the MQTT protocol for C2 and uses AWS IoT Core as infrastructure.

Sukoshi | 少し Overview Sukoshi is a proof-of-concept Python implant that leverages the MQTT protocol for C2 and uses AWS IoT Core as infrastructure. It

Steven Patterson 37 Oct 29, 2022
A zero-dependency Python library for getting the Kubernetes token of a AWS EKS cluster

tokeks A zero-dependency Python library for getting the Kubernetes token of a AWS EKS cluster. No AWS CLI, third-party client or library (boto3, botoc

Chris Karageorgiou Kaneen 6 Nov 04, 2022
A muti pairs martingle trading bot for Binance exchange.

multi_pairs_martingle_bot English Documentation A muti pairs martingle trading bot for Binance exchange. Configuration { "platform": "binance_futur

51bitquant 62 Nov 16, 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
Best Buy Bot used to add products to cart for purchase.

To Install the Best Buy Bot These instructions are for Mac users only. Clone this Repo to your machine. BestBuyBot Open in VScode. Is Python installed

Robert Estrella 1 Dec 11, 2021
To send an Instagram message using Python

To send an Instagram message using Python, you must have an Instagram account and install the Instabot library in your Python virtual environment.

Coding Taggers 1 Dec 18, 2021