├── .gitignore ├── LICENSE ├── app.py ├── readme.md ├── requirements.txt └── uwsgi.ini /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Windows template 3 | # Windows image file caches 4 | Thumbs.db 5 | ehthumbs.db 6 | 7 | # Folder config file 8 | Desktop.ini 9 | 10 | # Recycle Bin used on file shares 11 | $RECYCLE.BIN/ 12 | 13 | # Windows Installer files 14 | *.cab 15 | *.msi 16 | *.msm 17 | *.msp 18 | 19 | .idea 20 | 21 | # Windows shortcuts 22 | *.lnk 23 | ### Vim template 24 | # swap 25 | [._]*.s[a-w][a-z] 26 | [._]s[a-w][a-z] 27 | # session 28 | Session.vim 29 | # temporary 30 | .netrwhist 31 | *~ 32 | # auto-generated tag files 33 | tags 34 | ### JetBrains template 35 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 36 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 37 | 38 | ## File-based project format: 39 | *.iws 40 | 41 | ## Plugin-specific files: 42 | 43 | # IntelliJ 44 | /out/ 45 | 46 | # mpeltonen/sbt-idea plugin 47 | .idea_modules/ 48 | 49 | # JIRA plugin 50 | atlassian-ide-plugin.xml 51 | 52 | # Crashlytics plugin (for Android Studio and IntelliJ) 53 | com_crashlytics_export_strings.xml 54 | crashlytics.properties 55 | crashlytics-build.properties 56 | fabric.properties 57 | ### NotepadPP template 58 | # Notepad++ backups # 59 | *.bak 60 | ### Python template 61 | # Byte-compiled / optimized / DLL files 62 | __pycache__/ 63 | *.py[cod] 64 | *$py.class 65 | 66 | # C extensions 67 | *.so 68 | 69 | # Distribution / packaging 70 | .Python 71 | env/ 72 | build/ 73 | develop-eggs/ 74 | dist/ 75 | downloads/ 76 | eggs/ 77 | .eggs/ 78 | lib/ 79 | lib64/ 80 | parts/ 81 | sdist/ 82 | var/ 83 | *.egg-info/ 84 | .installed.cfg 85 | *.egg 86 | 87 | # PyInstaller 88 | # Usually these files are written by a python script from a template 89 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 90 | *.manifest 91 | *.spec 92 | 93 | # Installer logs 94 | pip-log.txt 95 | pip-delete-this-directory.txt 96 | 97 | # Unit test / coverage reports 98 | htmlcov/ 99 | .tox/ 100 | .coverage 101 | .coverage.* 102 | .cache 103 | nosetests.xml 104 | coverage.xml 105 | *,cover 106 | .hypothesis/ 107 | 108 | # Translations 109 | *.mo 110 | *.pot 111 | 112 | # Django stuff: 113 | *.log 114 | local_settings.py 115 | 116 | # Flask stuff: 117 | instance/ 118 | .webassets-cache 119 | 120 | # Scrapy stuff: 121 | .scrapy 122 | 123 | # Sphinx documentation 124 | docs/_build/ 125 | 126 | # PyBuilder 127 | target/ 128 | 129 | # Jupyter Notebook 130 | .ipynb_checkpoints 131 | 132 | # pyenv 133 | .python-version 134 | 135 | # celery beat schedule file 136 | celerybeat-schedule 137 | 138 | # dotenv 139 | .env 140 | 141 | # virtualenv 142 | .venv/ 143 | venv/ 144 | ENV/ 145 | 146 | # Spyder project settings 147 | .spyderproject 148 | 149 | # Rope project settings 150 | .ropeproject 151 | 152 | /ap_api/settings.py 153 | /db.sqlite3 154 | /ddns/ddns.ini 155 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Aploium 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import requests 3 | from flask import Flask, request, Response 4 | from cachetools.func import ttl_cache 5 | 6 | app = Flask(__name__) 7 | 8 | 9 | @ttl_cache(1024, ttl=600) 10 | def get_direct_url(ch, share_token): 11 | url_step1 = 'https://1drv.ms/{ch}/s!{share_token}'.format( 12 | ch=ch, # the ch could be w u t or more 13 | share_token=share_token 14 | ) 15 | resp_step1 = requests.get(url_step1, timeout=10, allow_redirects=False) 16 | url_step2 = resp_step1.headers['Location'] 17 | url_step3 = url_step2.replace('/redir?', '/download?') 18 | resp_step3 = requests.get(url_step3, timeout=10, allow_redirects=False) 19 | url_final = resp_step3.headers['Location'] 20 | 21 | return url_final 22 | 23 | 24 | @app.route('//s!') 25 | def share_ts(ch, share_token): 26 | url_direct = get_direct_url(ch, share_token) 27 | 28 | if 'txt' in request.args: 29 | # display plain text 30 | return url_direct 31 | else: 32 | # 301 redirect 33 | return Response('', 34 | status=301, 35 | headers={'Location': url_direct}, 36 | content_type='text/plain' 37 | ) 38 | 39 | 40 | @app.route('/') 41 | def index(): 42 | return """ 43 | 44 | 45 | The OneDrive Direct Download Link Helper 46 | 47 | 48 | 49 | 50 |

The OneDrive Direct Download Link Helper

51 |

Get OneDrive direct download link by just changing the "1drv.ms" to "1drv.ws"

52 |

Usage

53 | 1. Get the share link, like this: https://1drv.ms/u/s!Aiw77soXua44hb4CEu6eSveUl0xUoA
54 | 2. Change the domain 1drv.ms to 1drv.ws, I mean, just flip the m to w
55 | which becomes https://1drv.ws/t/s!Aiw77soXua44hb4CEu6eSveUl0xUoA
56 | 3. This IS the direct link, you can paste it to browser and see.
57 |

58 |

btw, you can add ?txt at the end of url, to display text link, instead of a 301 redirect.
59 | eg: https://1drv.ws/t/s!Aiw77soXua44hb4CEu6eSveUl0xUoA?txt 60 |

61 |
62 |

How it works

63 |
64 | https://1drv.ms/t/s!Aiw11soXua11pxigLnclZsYIU_Rx
65 | -- HTTP --> https://onedrive.live.com/redir?resid=...&authkey=!...&ithint=file%1ctxt
66 | --MODIFY--> https://onedrive.live.com/download?resid=...!1111&authkey=!...&ithint=file%1ctxt
67 | -- HTTP --> https://jlohlg.by.files.1drv.com/some-long-long-link/file.txt?download&psid=1
68 | 
69 |
70 |

Tips

71 | 76 | 77 |
78 |

More Info: GitHub OneDrive-Direct-Link

79 | 80 | 81 | """ 82 | 83 | 84 | if __name__ == '__main__': 85 | app.run() 86 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 由于被黑客利用与传播病毒文件,站点永久关闭 2 | Due to being used by hackers to spread virus files, the site is permanently closed 3 | 4 | 5 |
6 | # The OneDrive Direct Download Link Helper 7 | 8 | Get OneDrive direct download link by just changing the "1drv.ms" to "1drv.ws" 9 | 通过简单地改域名, 来获取OneDrive的直接下载链接。 10 | 11 | ## Usage 12 | 13 | 1. Get the share link, like this: https://1drv.ms/u/s!Aiw77soXua44hb4CEu6eSveUl0xUoA 14 | 2. Change the domain `1drv.ms` to `1drv.ws`, I mean, just flip the **m** to **w** 15 | which becomes https://1drv.ws/u/s!Aiw77soXua44hb4CEu6eSveUl0xUoA 16 | 3. This IS the direct link, you can paste it to browser and see. 17 | 18 | btw, you can add `?txt` at the end of url, to display text link, instead of a 301 redirect.
19 | eg: https://1drv.ws/u/s!Aiw77soXua44hb4CEu6eSveUl0xUoA?txt 20 | 21 | ## How it works 22 | 23 | https://1drv.ms/t/s!Aiw11soXua11pxigLnclZsYIU_Rx 24 | -- HTTP --> https://onedrive.live.com/redir?resid=...&authkey=!...&ithint=file%1ctxt 25 | --MODIFY--> https://onedrive.live.com/download?resid=...!1111&authkey=!...&ithint=file%1ctxt 26 | -- HTTP --> https://jlohlg.by.files.1drv.com/some-long-long-link/file.txt?download&psid=1 27 | 28 | ## Tips 29 | 30 | * Play OneDrive video directly in local player (eg:PotPlayer), most player support "play from url" 31 | * dispaly as image `` 32 | 33 | ## Deploy Your Self 34 | 35 | 1. Python 3.5+ is required. 36 | 2. `git clone https://github.com/aploium/OneDrive-Direct-Link` 37 | 3. `cd OneDrive-Direct-Link` 38 | 4. `pip3 install -r requirements.txt` 39 | 5. `python3 app.py` 40 | 6. Now you got this services in your localhost. 41 | 42 | warning: this code is simple and not fool-proof. 43 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests 2 | flask 3 | cachetools -------------------------------------------------------------------------------- /uwsgi.ini: -------------------------------------------------------------------------------- 1 | [uwsgi] 2 | chdir = %d 3 | wsgi-file = app.py 4 | master = true 5 | daemonize = /var/log/uwsgi-onedrive-direct-link.log 6 | pidfile = /var/run/uwsgi-onedrive-direct-link.pid 7 | env = LANG=en_US.UTF-8 8 | enable-threads = true 9 | processes = 1 10 | uid = www-data 11 | gid = www-data 12 | threads = 16 13 | chmod-socket = 666 14 | callable = app 15 | socket = /tmp/uwsgi-onedrive-direct-link.sock 16 | 17 | --------------------------------------------------------------------------------