├── LICENSE
├── README.md
├── contract.html
├── document
├── authentication-v8.png
├── authentication.png
├── clientID.png
├── icon.fw.png
└── permission.png
├── icon.png
├── images
├── Image 29.png
├── Image 30.png
├── Image 31.png
├── Image 32.png
├── cloud-white-18dp.svg
├── share-1.webp
├── share-2.webp
├── share-3.webp
├── share-4-2.webp
├── share-4.webp
├── share-5.webp
├── share-6.webp
└── share-white-18dp.svg
├── index.html
├── privacy.html
├── script.js
├── scripts
└── auth.js
└── style.css
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 获取OneDrive直链
2 | ===========
3 | 本应用的目的是为了**批量**获取 OneDrive 直链,方便在其他站点外链。前身为[提取OneDrive直链地址工具](http://bbs.comicdd.com/thread-354826-1-1.html)的网页版,因为原来的工具失效了,软件版也不是那么好用了,因此决定使用 OneDrive 官方 SDK 来进行获取,确保不失效。
4 |
5 | 2024年7月8日 以前的 SDK v7.2 好像用不了了,切换 SDK 到 v8 版本,只能获取到基本信息了。找了很久也不知道怎么获取更多的文件信息,就这样将就着用吧。
6 |
7 | # 马上使用
8 | https://mapaler.github.io/GetOneDriveDirectLink/
9 |
10 | > 因为使用官方 API 直接访问 onedrive.live.com 选择文件,因此可能需要翻墙。
11 |
12 | # 隐私声明
13 |
14 | 使用微软官方 [文件选取器 v8](https://learn.microsoft.com/zh-cn/onedrive/developer/controls/file-pickers/),本应用不会得到你的账号密码和其他用户资料。
15 | 目前仅申请了 `Files.Read`、`Files.Read.Selected` 两个权限,SDK 只会返回用户选择的文件的信息,不会获得未授权的其他内容。
16 |
17 | # 如何自行搭建
18 |
19 | ## 文件选取器 v8 教程
20 |
21 | 我不想注册收费的 Azure,所以只提到在原有 v7.2 上的变化。注册 Azure 的流程区别请自己想办法了。
22 |
23 | 1. 身份验证不能用 Web ,得改成单页应用程序,不然会报错:[The provided request must include a 'client_secret' input parameter in the sample project](https://github.com/Azure-Samples/ms-identity-javascript-react-spa-dotnetcore-webapi-obo/issues/30)
24 | 
25 | 2. 应用 ID,替换本程序 `scripts/auth.js` 内的 `msalParams.auth.clientId`。
26 |
27 | ## JavaScript SDK v7.2 教程
28 |
29 | 2024年7月8日 目前时间点登录会显示以下警告,也就是需要迁移到收费的 Azure,我不想搞,所以以下自行搭建教程已不适用于目前的内容,就这样将就着用吧。
30 |
31 | > 自 2020 年 6 月 30 日起,我们将不再向 Azure Active Directory 身份验证库(ADAL)和 Azure Active Directory Graph 添加任何新功能。我们将继续提供技术支持和安全更新程序,但将不再提供功能更新。应用程序将需要升级到 Microsoft 身份验证库(MSAL)和 Microsoft Graph。[了解更多信息](https://go.microsoft.com/fwlink/?linkid=2132805)
32 |
33 | > 这些应用程序与帐户 xxxx@outlook.com 关联,但不包含在任何目录中。在目录外部创建应用程序的功能已被弃用。你可通过加入 [M365 开发人员计划](https://aka.ms/joinM365DeveloperProgram)或[注册 Azure](https://aka.ms/signUpForAzure) 来获取新目录。[了解详细信息](https://aka.ms/MsaDeprecateInfo)
34 |
35 | ### 原内容
36 |
37 | >按照[OneDrive file picker SDK](https://docs.microsoft.com/onedrive/developer/controls/file-pickers/js-v72/)内的说明进行,由于旧有的*Microsoft 应用注册门户*已经迁移到*Azure门户*,特此做出更新,此版本更新于2020年2月6日。
38 |
39 | 1. 应用注册
40 | 在 [Azure 门户](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade) 创建应用,自己申请一个应用 ID,然后替换本程序 `script.js` 内底部的 `clientId`。
41 | 
42 | 其中 `odOptions.advanced.queryParameters` 内容参见 [DriveItem 资源类型](https://docs.microsoft.com/onedrive/developer/rest-api/resources/driveitem?view=odsp-graph-online),若不设定,将只返回基本信息。
43 | 1. 设置**身份验证**
44 | 将网页的各种东西上传到你申请 ID 时设置的 重定向 URL 即可,页面 URL 不在重定向内会发生错误。注:这个页面必须为 https(仅 localhost 可为 http,且 localhost 也需添加到 重定向 URL)
45 | 需要勾选**隐式授权**的**访问令牌**、**ID 令牌**。*讨论见[#9](//github.com/Mapaler/GetOneDriveDirectLink/issues/9)*
46 | 
47 | 1. 设置**API 权限**
48 | 添加 `Microsoft Graph` ▶ `委托的权限` ▶ `Files.Read`、`Files.Read.Selected`
49 | 
50 |
51 | ## 原理
52 | `http://storage.live.com/items/文件ID` 是很早之前就流传的 SkyDrive 官方的真实直链重定向地址,出处不可考。
53 | 开始一般是用`http://storage.live.com/items/文件ID?filename=xxx.jpg`来外链图片,后面的文件名用来欺骗DiscuzX论坛系统,但是浏览器下载该文件还是没有正确文件名。
54 | 后来有高手发现的`http://storage.live.com/items/文件ID:/xxx.jpg`这个地址格式不会影响 SkyDrive 识别ID,还同时可以欺骗浏览器为普通文件地址,识别出文件的文件名与扩展名。
55 | 访问 `onedrive.live.com` 域名需要翻墙,但是生成的 `storage.live.com` 链接不需要。
56 |
57 | ### 1drv.ws 原理
58 |
59 | > 由于 *1drv.ws* 项目自身停止运行,已删除对此功能的支持
60 |
61 | **1drv.ws** 是 *[The OneDrive Direct Download Link Helper](//github.com/aploium/OneDrive-Direct-Link)* 项目的实现。
62 | 原理为
63 | 1. 获取OneDrive的分享链接 `https://1drv.ms/u/分享ID`
64 | 2. 重定向到 `https://onedrive.live.com/redir?resid=文件ID&authkey=通行证`
65 | 3. 将访问网页的地址修改为下载地址 `https://onedrive.live.com/download?resid=文件ID&authkey=通行证`
66 | 4. 再次重定向到真实CDN地址 `https://public.ch.files.1drv.com/很长一串字符/文件名?download&psid=1`
67 |
68 | 其中,对 `onedrive.live.com` 的重定向需要墙外后端支持。
69 |
70 | 在 OneDrive SDK 中,使用 `share` 操作才能新增并获取到分享链接,因此添加了“额外创建分享链接”按钮。
71 | 掩码将获取到的分享链接中的 1drv.**m**s 修改为 1drv.**w**s ,即可得到下载链接。但是这种方式的 http header `content-Dispositong` 值为 `attachemen` 会弹出下载窗口,而不是内部预览。
--------------------------------------------------------------------------------
/contract.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |