qdown 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qdown-1.0.0/MANIFEST.in +0 -0
- qdown-1.0.0/PKG-INFO +16 -0
- qdown-1.0.0/README.md +50 -0
- qdown-1.0.0/qdown/__init__.py +24 -0
- qdown-1.0.0/qdown/gdown.py +168 -0
- qdown-1.0.0/qdown.egg-info/PKG-INFO +16 -0
- qdown-1.0.0/qdown.egg-info/SOURCES.txt +12 -0
- qdown-1.0.0/qdown.egg-info/dependency_links.txt +1 -0
- qdown-1.0.0/qdown.egg-info/entry_points.txt +2 -0
- qdown-1.0.0/qdown.egg-info/requires.txt +2 -0
- qdown-1.0.0/qdown.egg-info/top_level.txt +2 -0
- qdown-1.0.0/setup.cfg +4 -0
- qdown-1.0.0/setup.py +34 -0
- qdown-1.0.0/z_examples/__init__.py +0 -0
qdown-1.0.0/MANIFEST.in
ADDED
File without changes
|
qdown-1.0.0/PKG-INFO
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: qdown
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: Client for QualitegDrive
|
5
|
+
Home-page: https://github.com/qualiteg/qdown
|
6
|
+
Author: Qualiteg Inc.
|
7
|
+
Author-email: qualiteger@qualiteg.com
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
9
|
+
Classifier: Intended Audience :: Developers
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
16
|
+
Requires-Python: >=3.7
|
qdown-1.0.0/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# qdown
|
2
|
+
|
3
|
+
A Python client for downloading files from QualitegDrive operated by Qualiteg Inc.
|
4
|
+
|
5
|
+
# install
|
6
|
+
|
7
|
+
```
|
8
|
+
pip install qdown
|
9
|
+
```
|
10
|
+
|
11
|
+
or
|
12
|
+
|
13
|
+
```
|
14
|
+
pip install git+https://github.com/qualiteg/qdown.git
|
15
|
+
```
|
16
|
+
|
17
|
+
# usage
|
18
|
+
|
19
|
+
```
|
20
|
+
|
21
|
+
qdown ID [options]
|
22
|
+
|
23
|
+
Options:
|
24
|
+
-O FILENAME Specify output filename
|
25
|
+
-o DIR Specify output directory
|
26
|
+
-s SERVER Specify server URL (default: https://drive.qualiteg.com)
|
27
|
+
-q, --quiet Hide progress display
|
28
|
+
-h, --help Display help
|
29
|
+
```
|
30
|
+
|
31
|
+
## download example1
|
32
|
+
|
33
|
+
```
|
34
|
+
gdown xxxxxxxxxxxxx -O my_file.txt
|
35
|
+
```
|
36
|
+
|
37
|
+
## download example2
|
38
|
+
|
39
|
+
From Your Original HTTP Server
|
40
|
+
|
41
|
+
```
|
42
|
+
gdown xxxxxxxxxxxxx -O my_file.txt -s http://host.docker.internal:3000
|
43
|
+
```
|
44
|
+
|
45
|
+
|
46
|
+
# uninstall
|
47
|
+
|
48
|
+
```
|
49
|
+
pip uninstall qdown -y
|
50
|
+
```
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"""
|
2
|
+
|
3
|
+
Copyright (c) 2023 Qualiteg Inc. all rights reserved.
|
4
|
+
|
5
|
+
This program is dual-licensed under the terms of the:
|
6
|
+
1) GNU Affero General Public License, version 3, or any later version.
|
7
|
+
2) A commercial license agreement provided by Qualiteg Inc.
|
8
|
+
|
9
|
+
If you choose to use or redistribute this program under the terms of AGPLv3:
|
10
|
+
This program is free software: you can redistribute it and/or modify
|
11
|
+
it under the terms of the GNU Affero General Public License as
|
12
|
+
published by the Free Software Foundation, either version 3 of the
|
13
|
+
License, or (at your option) any later version.
|
14
|
+
This program is distributed in the hope that it will be useful,
|
15
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
GNU Affero General Public License for more details.
|
18
|
+
You should have received a copy of the GNU Affero General Public License
|
19
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
If you wish to use or redistribute this program under a commercial license:
|
22
|
+
Please contact Qualiteg Inc.(https://qualiteg.com/contact) directly to obtain the terms and pricing.
|
23
|
+
|
24
|
+
"""
|
@@ -0,0 +1,168 @@
|
|
1
|
+
|
2
|
+
"""
|
3
|
+
qdown - Client for QualitegDrive
|
4
|
+
|
5
|
+
使用方法:
|
6
|
+
qdown ID [オプション]
|
7
|
+
|
8
|
+
オプション:
|
9
|
+
-O FILENAME 出力ファイル名を指定
|
10
|
+
-o DIR 出力ディレクトリを指定
|
11
|
+
-s SERVER サーバーURLを指定 (デフォルト: https://drive.qualiteg.com)
|
12
|
+
-q, --quiet 進捗表示を非表示
|
13
|
+
-h, --help ヘルプを表示
|
14
|
+
"""
|
15
|
+
|
16
|
+
import httpx
|
17
|
+
import os
|
18
|
+
import sys
|
19
|
+
import argparse
|
20
|
+
import asyncio
|
21
|
+
from pathlib import Path
|
22
|
+
from tqdm import tqdm
|
23
|
+
|
24
|
+
|
25
|
+
class QDown:
|
26
|
+
"""
|
27
|
+
ID認証付きファイルサーバー用のPythonクライアント
|
28
|
+
"""
|
29
|
+
|
30
|
+
def __init__(self, server_url="https://drive.qualiteg.com", quiet=False):
|
31
|
+
"""
|
32
|
+
クライアントの初期化
|
33
|
+
|
34
|
+
Args:
|
35
|
+
server_url (str): ファイルサーバーのベースURL
|
36
|
+
quiet (bool): 進捗表示を非表示にするかどうか
|
37
|
+
"""
|
38
|
+
self.server_url = server_url.rstrip('/')
|
39
|
+
self.quiet = quiet
|
40
|
+
self.timeout = httpx.Timeout(10.0, connect=60.0)
|
41
|
+
|
42
|
+
async def download(self, file_id, output=None, output_dir=None):
|
43
|
+
"""
|
44
|
+
ファイルIDを指定してファイルをダウンロード
|
45
|
+
|
46
|
+
Args:
|
47
|
+
file_id (str): ダウンロードするファイルのID (qd_id)
|
48
|
+
output (str, optional): 出力ファイル名
|
49
|
+
output_dir (str, optional): 出力ディレクトリ
|
50
|
+
|
51
|
+
Returns:
|
52
|
+
str: ダウンロードしたファイルのパス
|
53
|
+
"""
|
54
|
+
url = f"{self.server_url}/download/{file_id}"
|
55
|
+
|
56
|
+
# 出力ディレクトリの設定
|
57
|
+
if output_dir:
|
58
|
+
os.makedirs(output_dir, exist_ok=True)
|
59
|
+
else:
|
60
|
+
output_dir = "."
|
61
|
+
|
62
|
+
async with httpx.AsyncClient(timeout=self.timeout) as client:
|
63
|
+
# まず、ヘッド要求を送信してファイル情報を取得
|
64
|
+
try:
|
65
|
+
head_response = await client.head(url)
|
66
|
+
|
67
|
+
if head_response.status_code == 404:
|
68
|
+
print(f"エラー: ID '{file_id}' のファイルが見つかりませんでした", file=sys.stderr)
|
69
|
+
return None
|
70
|
+
|
71
|
+
if head_response.status_code != 200:
|
72
|
+
print(f"エラー: ステータスコード {head_response.status_code}", file=sys.stderr)
|
73
|
+
return None
|
74
|
+
|
75
|
+
# Content-Dispositionヘッダーからファイル名を取得
|
76
|
+
original_filename = None
|
77
|
+
if "content-disposition" in head_response.headers:
|
78
|
+
cd = head_response.headers["content-disposition"]
|
79
|
+
if "filename=" in cd:
|
80
|
+
original_filename = cd.split("filename=")[1].strip('"')
|
81
|
+
|
82
|
+
# 保存用のファイル名を決定
|
83
|
+
if not output:
|
84
|
+
if original_filename:
|
85
|
+
output_filename = original_filename
|
86
|
+
else:
|
87
|
+
output_filename = f"download_{file_id}"
|
88
|
+
else:
|
89
|
+
output_filename = output
|
90
|
+
|
91
|
+
file_path = os.path.join(output_dir, output_filename)
|
92
|
+
|
93
|
+
# ファイルサイズを取得(プログレスバー用)
|
94
|
+
total_size = int(head_response.headers.get("content-length", 0))
|
95
|
+
|
96
|
+
# ストリーミングダウンロードを開始
|
97
|
+
async with client.stream("GET", url) as response:
|
98
|
+
if response.status_code != 200:
|
99
|
+
print(f"エラー: ダウンロード中にエラーが発生しました。ステータスコード: {response.status_code}", file=sys.stderr)
|
100
|
+
return None
|
101
|
+
|
102
|
+
with open(file_path, "wb") as f:
|
103
|
+
if not self.quiet and total_size > 0:
|
104
|
+
progress_bar = tqdm(
|
105
|
+
total=total_size,
|
106
|
+
unit="B",
|
107
|
+
unit_scale=True,
|
108
|
+
desc=f"ダウンロード中: {output_filename}"
|
109
|
+
)
|
110
|
+
|
111
|
+
downloaded = 0
|
112
|
+
|
113
|
+
async for chunk in response.aiter_bytes():
|
114
|
+
f.write(chunk)
|
115
|
+
if not self.quiet and total_size > 0:
|
116
|
+
downloaded += len(chunk)
|
117
|
+
progress_bar.update(len(chunk))
|
118
|
+
|
119
|
+
if not self.quiet and total_size > 0:
|
120
|
+
progress_bar.close()
|
121
|
+
|
122
|
+
if not self.quiet:
|
123
|
+
print(f"\nファイルを保存しました: {file_path}")
|
124
|
+
return file_path
|
125
|
+
|
126
|
+
except httpx.RequestError as e:
|
127
|
+
print(f"エラー: リクエストに失敗しました - {e}", file=sys.stderr)
|
128
|
+
return None
|
129
|
+
except Exception as e:
|
130
|
+
print(f"エラー: {e}", file=sys.stderr)
|
131
|
+
return None
|
132
|
+
|
133
|
+
|
134
|
+
def main():
|
135
|
+
parser = argparse.ArgumentParser(
|
136
|
+
description="qdown - IDベースファイルダウンロードツール",
|
137
|
+
add_help=False
|
138
|
+
)
|
139
|
+
|
140
|
+
parser.add_argument("id", nargs="?", help="ダウンロードするファイルのID")
|
141
|
+
parser.add_argument("-O", dest="output", help="出力ファイル名")
|
142
|
+
parser.add_argument("-o", dest="output_dir", help="出力ディレクトリ")
|
143
|
+
parser.add_argument("-s", dest="server", default="https://drive.qualiteg.com", help="サーバーURL")
|
144
|
+
parser.add_argument("-q", "--quiet", action="store_true", help="進捗表示を非表示")
|
145
|
+
parser.add_argument("-h", "--help", action="store_true", help="ヘルプを表示")
|
146
|
+
|
147
|
+
args = parser.parse_args()
|
148
|
+
|
149
|
+
if args.help or not args.id:
|
150
|
+
print(__doc__)
|
151
|
+
sys.exit(0)
|
152
|
+
|
153
|
+
client = QDown(server_url=args.server, quiet=args.quiet)
|
154
|
+
|
155
|
+
result = asyncio.run(client.download(
|
156
|
+
file_id=args.id,
|
157
|
+
output=args.output,
|
158
|
+
output_dir=args.output_dir
|
159
|
+
))
|
160
|
+
|
161
|
+
if result:
|
162
|
+
sys.exit(0)
|
163
|
+
else:
|
164
|
+
sys.exit(1)
|
165
|
+
|
166
|
+
|
167
|
+
if __name__ == "__main__":
|
168
|
+
main()
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: qdown
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: Client for QualitegDrive
|
5
|
+
Home-page: https://github.com/qualiteg/qdown
|
6
|
+
Author: Qualiteg Inc.
|
7
|
+
Author-email: qualiteger@qualiteg.com
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
9
|
+
Classifier: Intended Audience :: Developers
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
16
|
+
Requires-Python: >=3.7
|
@@ -0,0 +1,12 @@
|
|
1
|
+
MANIFEST.in
|
2
|
+
README.md
|
3
|
+
setup.py
|
4
|
+
qdown/__init__.py
|
5
|
+
qdown/gdown.py
|
6
|
+
qdown.egg-info/PKG-INFO
|
7
|
+
qdown.egg-info/SOURCES.txt
|
8
|
+
qdown.egg-info/dependency_links.txt
|
9
|
+
qdown.egg-info/entry_points.txt
|
10
|
+
qdown.egg-info/requires.txt
|
11
|
+
qdown.egg-info/top_level.txt
|
12
|
+
z_examples/__init__.py
|
@@ -0,0 +1 @@
|
|
1
|
+
|
qdown-1.0.0/setup.cfg
ADDED
qdown-1.0.0/setup.py
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
from setuptools import setup, find_packages
|
5
|
+
|
6
|
+
setup(
|
7
|
+
name="qdown",
|
8
|
+
version="1.0.0",
|
9
|
+
description="Client for QualitegDrive",
|
10
|
+
author="Qualiteg Inc.",
|
11
|
+
author_email="qualiteger@qualiteg.com",
|
12
|
+
url="https://github.com/qualiteg/qdown",
|
13
|
+
packages=find_packages(),
|
14
|
+
install_requires=[
|
15
|
+
"httpx>=0.23.0",
|
16
|
+
"tqdm>=4.64.0",
|
17
|
+
],
|
18
|
+
entry_points={
|
19
|
+
"console_scripts": [
|
20
|
+
"qdown=qdown.gdown:main", # ファイル名をgdown.pyに修正
|
21
|
+
],
|
22
|
+
},
|
23
|
+
classifiers=[
|
24
|
+
"Development Status :: 3 - Alpha",
|
25
|
+
"Intended Audience :: Developers",
|
26
|
+
"License :: OSI Approved :: MIT License",
|
27
|
+
"Programming Language :: Python :: 3",
|
28
|
+
"Programming Language :: Python :: 3.7",
|
29
|
+
"Programming Language :: Python :: 3.8",
|
30
|
+
"Programming Language :: Python :: 3.9",
|
31
|
+
"Programming Language :: Python :: 3.10",
|
32
|
+
],
|
33
|
+
python_requires=">=3.7",
|
34
|
+
)
|
File without changes
|