Skip to content

Commit

Permalink
Add description and sample program for OneDrive Personal Edition down…
Browse files Browse the repository at this point in the history
…load method
  • Loading branch information
gaowanliang committed Dec 13, 2024
1 parent b812b98 commit a7be157
Show file tree
Hide file tree
Showing 6 changed files with 665 additions and 200 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ local-chromium
*.html
__pycache__
example.png
test
test
*.txt
52 changes: 32 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[简体中文](docs/Readme_zh-cn.md)

# OneDriveShareLinkPushAria2

Extract download URLs from OneDrive or SharePoint share links and push them to aria2, even on systems without a GUI (such as Linux).

从OneDrive或SharePoint共享链接提取下载URL并将其推送到aria2,即使在无图形界面的系统中(如Linux)依然可以使用。
从 OneDrive 或 SharePoint 共享链接提取下载 URL 并将其推送到 aria2,即使在无图形界面的系统中(如 Linux)依然可以使用。

# Dependent

Expand All @@ -15,43 +16,53 @@ pyppeteer==0.2.5

At present, this program supports the following download methods:

* xxx-my.sharepoint.com Download of share links
* Downloading multiple files without password for shared links
* Downloading multiple files with password for shared links
* Download of files in nested folders
* Download any file of your choice
* Traversal view and download for multiple files (more than 30) of shared links
* xxx.sharepoint.com Downloads with share links
* xxx-my.sharepoint.cn Download of share links (theoretically supported)
- xxx-my.sharepoint.com Download of share links
- Downloading multiple files without password for shared links
- Downloading multiple files with password for shared links
- Download of files in nested folders
- Download any file of your choice
- Traversal view and download for multiple files (more than 30) of shared links
- xxx.sharepoint.com Downloads with share links
- xxx-my.sharepoint.cn Download of share links (theoretically supported)

**Note: aria2 itself does not support HTTP POST download links, while onedrive folder package download is HTTP POST download links, so this program will not support onedrive folder package download**

## Output file list

input this command then you can get file list in list.txt

``` bash
```bash
python main.py > list.txt
```

It maybe output gibberish in powershell, you can input this command before to fix

``` bash
```bash
[System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8
```

## OneDrive Personal

As of December 13, 2024, OneDrive Personal download links are direct links. You can open F12 and refresh the page, then find the request `https://my.microsoftpersonalcontent.com/_api/v2.0/drives/{}/items/{}children?%24top=100&orderby=folder%2Cname&%24expand=thumbnails%2Ctags&select=*%2Cocr%2CwebDavUrl%2CsharepointIds%2CisRestricted%2CcommentSettings%2CspecialFolder%2CcontainingDrivePolicyScenarioViewpoint&ump=1` in the Network tab (the content in the curly braces will change with different files), and check the returned JSON data to find the `@content.downloadUrl` field, which is the download link.

Alternatively, go to the Network tab, press Ctrl + F, and enter `@content.downloadUrl` to find the corresponding request. Check the returned data to find the `@content.downloadUrl` field, which is the download link.
![alt text](docs/image.png)

You can refer to the [test.py](test.py) file, which contains an example that can be run directly to obtain the corresponding JSON data.

## Without password for shared links

Take this download link as an example:

https://gitaccuacnz2-my.sharepoint.com/:f:/g/personal/mail_finderacg_com/EheQwACFhe9JuGUn4hlg9esBsKyk5jp9-Iz69kqzLLF5Xw?e=FG7SHh

At this time, you need to use the download code for no password link, that is, [main.py](main.py). Open this file and you can see that there are some global variables:
* OneDriveShareURL: The download address, which should be filled in here https://gitaccuacnz2-my.sharepoint.com/:f:/g/personal/mail_finderacg_com/EheQwACFhe9JuGUn4hlg9esBsKyk5jp9-Iz69kqzLLF5Xw?e=FG7SHh
* aria2Link: aria2's rpc address, usually `http://localhost:Port/jsonrpc` if it's native
* aria2Secret: the password of aria2
* isDownload: whether to download or not, if `False`, only the file list is output
* downloadNum: List of files to download, **0** means all of them

- OneDriveShareURL: The download address, which should be filled in here https://gitaccuacnz2-my.sharepoint.com/:f:/g/personal/mail_finderacg_com/EheQwACFhe9JuGUn4hlg9esBsKyk5jp9-Iz69kqzLLF5Xw?e=FG7SHh
- aria2Link: aria2's rpc address, usually `http://localhost:Port/jsonrpc` if it's native
- aria2Secret: the password of aria2
- isDownload: whether to download or not, if `False`, only the file list is output
- downloadNum: List of files to download, **0** means all of them

If you want to download the second file, you need `downloadNum="2"`

Expand All @@ -63,19 +74,20 @@ and so on.

After modifying, make sure the target aria2 is on and execute `python3 main.py`


## With password for shared links

Take this download link as an example:

https://jia666-my.sharepoint.com/:f:/g/personal/1025_xkx_me/EsqNMFlDoyZKt-RGcsI1F2EB6AiQMBIpQM4Ka247KkyOQw?e=oC1y7r

At this time, you need to use the download code for have password link, that is, [havepassword.py](havepassword.py). Open this file and you can see that there are some global variables (repeated without further ado):
* OneDriveSharePwd: Password for the OneDrive link


- OneDriveSharePwd: Password for the OneDrive link

Usage is similar to the above.

# Note

Before you use it, clone the whole project with `git clone https://github.com/gaowanliang/OneDriveShareLinkPushAria2.git` to use it. havepassword.py depends on main.py, if you want to use the version that requires a password If you want to use a version that requires a password, you need to `pip install pyppeteer`

The basic functions of this program have been realized. For a long time, if the software is not unusable, it will not be maintained. If there is a running problem, please bring a download link when raising the issue. The bug type issue that does not provide a download link will not be solved.
The basic functions of this program have been realized. For a long time, if the software is not unusable, it will not be maintained. If there is a running problem, please bring a download link when raising the issue. The bug type issue that does not provide a download link will not be solved.
66 changes: 41 additions & 25 deletions docs/Readme_zh-cn.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,65 @@
# OneDriveShareLinkPushAria2

Extract download URLs from OneDrive or SharePoint share links and push them to aria2, even on systems without a GUI.

从OneDrive或SharePoint共享链接提取下载URL并将其推送到aria2,即使在无图形界面的系统中依然可以使用。
从 OneDrive 或 SharePoint 共享链接提取下载 URL 并将其推送到 aria2,即使在无图形界面的系统中依然可以使用。

# 依赖

requests==2.25.1

pyppeteer==0.2.5

# 特点

目前本程序支持的下载方式:
* xxx-my.sharepoint.com 下载链接的下载
* 无下载密码的多文件推送
* 有下载密码的多文件推送
* 嵌套文件夹的文件推送
* 任意选择文件推送
* 针对超多文件(超过30个)的分享链接,实现了的遍历查看和下载
* xxx.sharepoint.com 下载链接的下载
* xxx-my.sharepoint.cn 下载链接的下载(理论上支持)

**注意:Aria2本身不支持HTTP POST型的下载链接,而OneDrive文件夹打包下载为HTTP POST型的下载链接,所以本程序将不会支持OneDrive文件夹打包下载**
- xxx-my.sharepoint.com 下载链接的下载
- 无下载密码的多文件推送
- 有下载密码的多文件推送
- 嵌套文件夹的文件推送
- 任意选择文件推送
- 针对超多文件(超过 30 个)的分享链接,实现了的遍历查看和下载
- xxx.sharepoint.com 下载链接的下载
- xxx-my.sharepoint.cn 下载链接的下载(理论上支持)

**注意:Aria2 本身不支持 HTTP POST 型的下载链接,而 OneDrive 文件夹打包下载为 HTTP POST 型的下载链接,所以本程序将不会支持 OneDrive 文件夹打包下载**

## 输出文件列表

使用以下命令输出文件列表到list.txt
使用以下命令输出文件列表到 list.txt

``` bash
```bash
python main.py > list.txt
```

使用powershell运行此命令可能会输出乱码, 先运行以下命令即可修复
使用 powershell 运行此命令可能会输出乱码, 先运行以下命令即可修复

``` bash
```bash
[System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8
```

## OneDrive 个人版

截至 2024 年 12 月 13 日,OneDrive 个人版的下载链接为直链,可以打开 F12 后刷新页面,找到 Network(网络)中的`https://my.microsoftpersonalcontent.com/_api/v2.0/drives/{}/items/{}children?%24top=100&orderby=folder%2Cname&%24expand=thumbnails%2Ctags&select=*%2Cocr%2CwebDavUrl%2CsharepointIds%2CisRestricted%2CcommentSettings%2CspecialFolder%2CcontainingDrivePolicyScenarioViewpoint&ump=1`请求 (花括号中的内容会随着不同的文件而改变),查看返回的 json 数据,找到`@content.downloadUrl`字段,即为下载链接。

或者转到Network中,按下Ctrl + F,输入`@content.downloadUrl`,找到对应的请求,查看返回的数据,找到`@content.downloadUrl`字段,即为下载链接。
![alt text](image.png)


可以查看[test.py](../test.py)文件,里面有一个示例,可以直接运行,获取对应的json数据。

## 无密码的链接

https://gitaccuacnz2-my.sharepoint.com/:f:/g/personal/mail_finderacg_com/EheQwACFhe9JuGUn4hlg9esBsKyk5jp9-Iz69kqzLLF5Xw?e=FG7SHh 这个下载链接为例

此时需要使用无密码的下载代码,也就是[main.py](../main.py),打开这个文件,可以看到有一些全局变量:
* OneDriveShareURL: 下载地址,此处应该填写 https://gitaccuacnz2-my.sharepoint.com/:f:/g/personal/mail_finderacg_com/EheQwACFhe9JuGUn4hlg9esBsKyk5jp9-Iz69kqzLLF5Xw?e=FG7SHh
* aria2Link: aria2 的rpc地址,如果是本机,一般是 `http://localhost:端口号/jsonrpc`
* aria2Secret: aria2 的密码
* isDownload: 是否下载,如果是`False`,只输出文件列表
* downloadNum: 要下载的文件列表,**0**表示全部下载

- OneDriveShareURL: 下载地址,此处应该填写 https://gitaccuacnz2-my.sharepoint.com/:f:/g/personal/mail_finderacg_com/EheQwACFhe9JuGUn4hlg9esBsKyk5jp9-Iz69kqzLLF5Xw?e=FG7SHh
- aria2Link: aria2 的 rpc 地址,如果是本机,一般是 `http://localhost:端口号/jsonrpc`
- aria2Secret: aria2 的密码
- isDownload: 是否下载,如果是`False`,只输出文件列表
- downloadNum: 要下载的文件列表,**0**表示全部下载

如果想要下载第二个文件,则需要`downloadNum="2"`

Expand All @@ -54,19 +69,20 @@ python main.py > list.txt

以此类推

修改好后,确保目标aria2处于开启状态,执行`python3 main.py`
修改好后,确保目标 aria2 处于开启状态,执行`python3 main.py`

## 有密码的链接


https://jia666-my.sharepoint.com/:f:/g/personal/1025_xkx_me/EsqNMFlDoyZKt-RGcsI1F2EB6AiQMBIpQM4Ka247KkyOQw?e=oC1y7r 这个下载链接为例

此时需要使用有密码的下载代码,也就是[havepassword.py](../havepassword.py),打开这个文件,可以看到有一些全局变量(重复的不再赘述):
* OneDriveSharePwd: OneDrive链接的密码


- OneDriveSharePwd: OneDrive 链接的密码

使用方法和上面类似。

# 注意
使用前,使用 `git clone https://github.com/gaowanliang/OneDriveShareLinkPushAria2.git` 将项目整个克隆,才能使用,havepassword.py依赖于main.py,如果要使用需要密码的版本,需要 `pip install pyppeteer`

此程序基本功能都已实现,之后很长的一段时间内,如果不是软件无法使用了,则不再维护,如有运行问题,请在提出issue时带上下载链接,不提供下载链接的bug类型的issue将不会解决。
使用前,使用 `git clone https://github.com/gaowanliang/OneDriveShareLinkPushAria2.git` 将项目整个克隆,才能使用,havepassword.py 依赖于 main.py,如果要使用需要密码的版本,需要 `pip install pyppeteer`

此程序基本功能都已实现,之后很长的一段时间内,如果不是软件无法使用了,则不再维护,如有运行问题,请在提出 issue 时带上下载链接,不提供下载链接的 bug 类型的 issue 将不会解决。
Binary file added docs/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a7be157

Please sign in to comment.