-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hwfan
committed
Aug 20, 2021
1 parent
02b57aa
commit 4b03d4c
Showing
10 changed files
with
98 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,3 +126,5 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
pack.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,7 @@ | |
# E-mail: [email protected] # | ||
# Homepage: https://github.com/hwfan # | ||
############################################# | ||
from DriveDownloader.netdrives.googledrive import GoogleDriveSession | ||
from DriveDownloader.netdrives.onedrive import OneDriveSession | ||
from DriveDownloader.netdrives import * | ||
import argparse | ||
import os | ||
import sys | ||
|
@@ -18,8 +17,7 @@ def parse_args(): | |
return args | ||
|
||
def simple_cli(): | ||
|
||
sys.stdout.write('============ Drive Downloader V1.2 ============\n') | ||
sys.stdout.write('============ Drive Downloader ============\n') | ||
|
||
if len(sys.argv) > 1: | ||
# non-interactive mode | ||
|
@@ -45,6 +43,10 @@ def simple_cli(): | |
download_session = OneDriveSession(final_proxy) | ||
elif 'drive.google.com' in url: | ||
download_session = GoogleDriveSession(final_proxy) | ||
elif 'sharepoint' in url: | ||
download_session = SharePointSession(final_proxy) | ||
elif 'dropbox' in url: | ||
download_session = DropBoxSession(final_proxy) | ||
else: | ||
raise NotImplementedError("The drive type is not supported!") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .googledrive import GoogleDriveSession | ||
from .onedrive import OneDriveSession | ||
from .sharepoint import SharePointSession | ||
from .dropbox import DropBoxSession |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
############################################# | ||
# Author: Hongwei Fan # | ||
# E-mail: [email protected] # | ||
# Homepage: https://github.com/hwfan # | ||
############################################# | ||
import urllib.parse as urlparse | ||
from DriveDownloader.netdrives.basedrive import DriveSession | ||
|
||
class DropBoxSession(DriveSession): | ||
def __init__(self, proxy, chunk_size=32768): | ||
DriveSession.__init__(self, proxy, chunk_size) | ||
|
||
def generate_url(self, url): | ||
''' | ||
Solution provided by: | ||
https://www.qian.blue/archives/OneDrive-straight.html | ||
''' | ||
parsed_url = urlparse.urlparse(url) | ||
netloc = parsed_url.netloc.replace('www', 'dl-web') | ||
query = '' | ||
parsed_url = parsed_url._replace(netloc=netloc, query=query) | ||
resultUrl = urlparse.urlunparse(parsed_url) | ||
return resultUrl | ||
|
||
def connect(self, url, custom_filename=''): | ||
onedrive_url = self.generate_url(url) | ||
DriveSession.connect(self, onedrive_url, download=True, custom_filename=custom_filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,9 @@ | |
# E-mail: [email protected] # | ||
# Homepage: https://github.com/hwfan # | ||
############################################# | ||
from DriveDownloader.netdrives.basedrive import DriveSession | ||
import base64 | ||
from DriveDownloader.netdrives.basedrive import DriveSession | ||
|
||
class OneDriveSession(DriveSession): | ||
def __init__(self, proxy, chunk_size=32768): | ||
DriveSession.__init__(self, proxy, chunk_size) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
############################################# | ||
# Author: Hongwei Fan # | ||
# E-mail: [email protected] # | ||
# Homepage: https://github.com/hwfan # | ||
############################################# | ||
import urllib.parse as urlparse | ||
from DriveDownloader.netdrives.basedrive import DriveSession | ||
|
||
class SharePointSession(DriveSession): | ||
def __init__(self, proxy, chunk_size=32768): | ||
DriveSession.__init__(self, proxy, chunk_size) | ||
|
||
def generate_url(self, url): | ||
''' | ||
Solution provided by: | ||
https://www.qian.blue/archives/OneDrive-straight.html | ||
''' | ||
parsed_url = urlparse.urlparse(url) | ||
path = parsed_url.path | ||
netloc = parsed_url.netloc | ||
splitted_path = path.split('/') | ||
personal_attr, domain, sharelink = splitted_path[3:6] | ||
resultUrl = f"https://{netloc}/{personal_attr}/{domain}/_layouts/52/download.aspx?share={sharelink}" | ||
return resultUrl | ||
|
||
def connect(self, url, custom_filename=''): | ||
onedrive_url = self.generate_url(url) | ||
DriveSession.connect(self, onedrive_url, download=True, custom_filename=custom_filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters