zipline-cli 0.2.1__tar.gz → 0.2.2__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.
- {zipline_cli-0.2.1/src/zipline_cli.egg-info → zipline_cli-0.2.2}/PKG-INFO +36 -33
- {zipline_cli-0.2.1 → zipline_cli-0.2.2}/README.md +24 -23
- {zipline_cli-0.2.1 → zipline_cli-0.2.2}/pyproject.toml +13 -11
- zipline_cli-0.2.2/src/zipline/py.typed +0 -0
- {zipline_cli-0.2.1 → zipline_cli-0.2.2}/src/zipline/zipline.py +62 -33
- {zipline_cli-0.2.1 → zipline_cli-0.2.2/src/zipline_cli.egg-info}/PKG-INFO +36 -33
- {zipline_cli-0.2.1 → zipline_cli-0.2.2}/src/zipline_cli.egg-info/SOURCES.txt +1 -0
- {zipline_cli-0.2.1 → zipline_cli-0.2.2}/src/zipline_cli.egg-info/requires.txt +0 -1
- {zipline_cli-0.2.1 → zipline_cli-0.2.2}/LICENSE +0 -0
- {zipline_cli-0.2.1 → zipline_cli-0.2.2}/MANIFEST.in +0 -0
- {zipline_cli-0.2.1 → zipline_cli-0.2.2}/setup.cfg +0 -0
- {zipline_cli-0.2.1 → zipline_cli-0.2.2}/src/zipline/__init__.py +0 -0
- {zipline_cli-0.2.1 → zipline_cli-0.2.2}/src/zipline_cli.egg-info/dependency_links.txt +0 -0
- {zipline_cli-0.2.1 → zipline_cli-0.2.2}/src/zipline_cli.egg-info/entry_points.txt +0 -0
- {zipline_cli-0.2.1 → zipline_cli-0.2.2}/src/zipline_cli.egg-info/top_level.txt +0 -0
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: zipline-cli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Python 3 CLI File Uploader for Diced/Zipline v3/v4 Upload Server and Django Files.
|
|
5
5
|
Author: Shane
|
|
6
6
|
License: MIT License
|
|
7
|
-
Project-URL:
|
|
8
|
-
Project-URL: Documentation, https://zipline-cli.cssnr.com/
|
|
9
|
-
Project-URL: Source, https://github.com/cssnr/zipline-cli
|
|
7
|
+
Project-URL: GitHub, https://github.com/cssnr/zipline-cli
|
|
10
8
|
Project-URL: Issues, https://github.com/cssnr/zipline-cli/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/cssnr/zipline-cli/releases
|
|
10
|
+
Project-URL: Documentation, https://zipline-cli.cssnr.com/
|
|
11
|
+
Project-URL: Homepage, https://cssnr.com/
|
|
11
12
|
Project-URL: Funding, https://ko-fi.com/cssnr
|
|
12
|
-
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Classifier: Natural Language :: English
|
|
13
|
+
Project-URL: Discord, https://discord.gg/wXy6m2X8wY
|
|
15
14
|
Classifier: Programming Language :: Python
|
|
16
15
|
Classifier: Programming Language :: Python :: 3
|
|
17
16
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
-
Classifier:
|
|
19
|
-
Classifier:
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Natural Language :: English
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Classifier: Topic :: Communications :: File Sharing
|
|
22
|
+
Classifier: Topic :: Terminals
|
|
20
23
|
Requires-Python: >=3.9
|
|
21
24
|
Description-Content-Type: text/markdown
|
|
22
25
|
License-File: LICENSE
|
|
23
|
-
Requires-Dist: binaryornot
|
|
24
26
|
Requires-Dist: python-decouple
|
|
25
27
|
Requires-Dist: python-dotenv
|
|
26
28
|
Requires-Dist: requests
|
|
@@ -31,6 +33,7 @@ Dynamic: license-file
|
|
|
31
33
|
[](https://github.com/cssnr/zipline-cli?tab=readme-ov-file#readme)
|
|
32
34
|
[](https://pypistats.org/packages/zipline-cli)
|
|
33
35
|
[](https://clickpy.clickhouse.com/dashboard/zipline-cli)
|
|
36
|
+
[](https://app.codacy.com/gh/cssnr/zipline-cli/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
|
34
37
|
[](https://sonarcloud.io/summary/new_code?id=cssnr_zipline-cli)
|
|
35
38
|
[](https://github.com/cssnr/zipline-cli/actions/workflows/test.yaml)
|
|
36
39
|
[](https://github.com/cssnr/zipline-cli/actions/workflows/lint.yaml)
|
|
@@ -54,17 +57,17 @@ Dynamic: license-file
|
|
|
54
57
|
<a title="Zipline CLI" href="https://zipline-cli.cssnr.com/" target="_blank">
|
|
55
58
|
<img alt="Zipline CLI" align="right" width="128" height="auto" src="https://raw.githubusercontent.com/smashedr/repo-images/refs/heads/master/zipline/cli/logo128.png"></a>
|
|
56
59
|
|
|
57
|
-
- [Quick Start](#
|
|
58
|
-
- [Install](#
|
|
59
|
-
- [Usage](#
|
|
60
|
-
- [Environment Variables](#
|
|
61
|
-
- [API Reference](#
|
|
62
|
-
- [Support](#
|
|
63
|
-
- [Contributing](#
|
|
60
|
+
- [Quick Start](#quick-start)
|
|
61
|
+
- [Install](#install)
|
|
62
|
+
- [Usage](#usage)
|
|
63
|
+
- [Environment Variables](#environment-variables)
|
|
64
|
+
- [API Reference](#api-reference)
|
|
65
|
+
- [Support](#support)
|
|
66
|
+
- [Contributing](#contributing)
|
|
64
67
|
|
|
65
68
|
Python 3 CLI File Uploader for [Diced/Zipline](https://github.com/diced/zipline) v3/v4 Upload Server and [Django Files](https://github.com/django-files/django-files).
|
|
66
69
|
|
|
67
|
-
- Zipline: [https://zipline.diced.
|
|
70
|
+
- Zipline: [https://zipline.diced.sh/](https://zipline.diced.sh/)
|
|
68
71
|
- Django Files: [https://django-files.github.io/](https://django-files.github.io/)
|
|
69
72
|
|
|
70
73
|
> [!TIP]
|
|
@@ -72,16 +75,16 @@ Python 3 CLI File Uploader for [Diced/Zipline](https://github.com/diced/zipline)
|
|
|
72
75
|
> You can also [request new features](https://github.com/cssnr/zipline-cli/discussions/new?category=feature-requests)
|
|
73
76
|
> or report any [issues](https://github.com/cssnr/zipline-cli/issues/new).
|
|
74
77
|
|
|
75
|
-
## Quick Start
|
|
78
|
+
## Quick Start<a id="quick-start"></a>
|
|
76
79
|
|
|
77
80
|
```shell
|
|
78
81
|
python -m pip install zipline-cli
|
|
79
82
|
zipline --setup
|
|
80
83
|
```
|
|
81
84
|
|
|
82
|
-
Documentation
|
|
85
|
+
[](https://zipline-cli.cssnr.com/)
|
|
83
86
|
|
|
84
|
-
## Install
|
|
87
|
+
## Install<a id="install"></a>
|
|
85
88
|
|
|
86
89
|
From PyPI: https://pypi.org/p/zipline-cli
|
|
87
90
|
|
|
@@ -108,7 +111,7 @@ Uninstall.
|
|
|
108
111
|
python -m pip uninstall zipline-cli
|
|
109
112
|
```
|
|
110
113
|
|
|
111
|
-
## Usage
|
|
114
|
+
## Usage<a id="usage"></a>
|
|
112
115
|
|
|
113
116
|
> [!TIP]
|
|
114
117
|
> View the [Getting Started](https://zipline-cli.cssnr.com/) guide online.
|
|
@@ -144,19 +147,19 @@ zipline
|
|
|
144
147
|
# Paste or Type contents, followed by a newline, then Ctrl+D (Ctrl+Z on Windows)
|
|
145
148
|
```
|
|
146
149
|
|
|
147
|
-
## Environment Variables
|
|
150
|
+
## Environment Variables<a id="environment-variables"></a>
|
|
148
151
|
|
|
149
152
|
Environment Variables are stored in the `.zipline` file in your home directory.
|
|
150
153
|
|
|
151
154
|
- Location: `~/.zipline` or `$HOME/.zipline`
|
|
152
155
|
|
|
153
|
-
| Variable | Description
|
|
154
|
-
| ---------------- |
|
|
155
|
-
| `ZIPLINE_URL` | URL to your Zipline Instance
|
|
156
|
-
| `ZIPLINE_TOKEN` | Authorization Token from Zipline
|
|
157
|
-
| `ZIPLINE_EMBED` | Set this enable Embed on your uploads
|
|
158
|
-
| `ZIPLINE_FORMAT` | Output Format. Variables: `{filename}`, `{url}` and `{raw_url}`
|
|
159
|
-
| `ZIPLINE_EXPIRE` | Reference: [Zipline](https://zipline.diced.
|
|
156
|
+
| Variable | Description |
|
|
157
|
+
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
158
|
+
| `ZIPLINE_URL` | URL to your Zipline Instance |
|
|
159
|
+
| `ZIPLINE_TOKEN` | Authorization Token from Zipline |
|
|
160
|
+
| `ZIPLINE_EMBED` | Set this enable Embed on your uploads |
|
|
161
|
+
| `ZIPLINE_FORMAT` | Output Format. Variables: `{filename}`, `{url}` and `{raw_url}` |
|
|
162
|
+
| `ZIPLINE_EXPIRE` | Reference: [Zipline](https://zipline.diced.sh/docs/guides/upload-options#image-expiration) / [Django Files](https://github.com/onegreyonewhite/pytimeparse2#pytimeparse2-time-expression-parser) |
|
|
160
163
|
|
|
161
164
|
See [.zipline.example](.zipline.example) for an example `.zipline` file.
|
|
162
165
|
|
|
@@ -167,7 +170,7 @@ or using the corresponding command line arguments.
|
|
|
167
170
|
zipline -h
|
|
168
171
|
```
|
|
169
172
|
|
|
170
|
-
## API Reference
|
|
173
|
+
## API Reference<a id="api-reference"></a>
|
|
171
174
|
|
|
172
175
|
Initialize the class with your Zipline URL.
|
|
173
176
|
Everything else is a header passed as a kwarg.
|
|
@@ -190,7 +193,7 @@ with open('text.txt') as f:
|
|
|
190
193
|
print(url)
|
|
191
194
|
```
|
|
192
195
|
|
|
193
|
-
# Support
|
|
196
|
+
# Support<a id="support"></a>
|
|
194
197
|
|
|
195
198
|
For general help or to request a feature, see:
|
|
196
199
|
|
|
@@ -204,7 +207,7 @@ If you are experiencing an issue/bug or getting unexpected results, you can:
|
|
|
204
207
|
- Provide General Feedback: [https://cssnr.github.io/feedback/](https://cssnr.github.io/feedback/?app=zipline-cli)
|
|
205
208
|
- Chat with us on Discord: https://discord.gg/wXy6m2X8wY
|
|
206
209
|
|
|
207
|
-
# Contributing
|
|
210
|
+
# Contributing<a id="contributing"></a>
|
|
208
211
|
|
|
209
212
|
All contributions are welcome including [bug reports](https://github.com/cssnr/zipline-cli/issues),
|
|
210
213
|
[feature requests](https://github.com/cssnr/zipline-cli/discussions/categories/feature-requests),
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
[](https://github.com/cssnr/zipline-cli?tab=readme-ov-file#readme)
|
|
4
4
|
[](https://pypistats.org/packages/zipline-cli)
|
|
5
5
|
[](https://clickpy.clickhouse.com/dashboard/zipline-cli)
|
|
6
|
+
[](https://app.codacy.com/gh/cssnr/zipline-cli/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
|
6
7
|
[](https://sonarcloud.io/summary/new_code?id=cssnr_zipline-cli)
|
|
7
8
|
[](https://github.com/cssnr/zipline-cli/actions/workflows/test.yaml)
|
|
8
9
|
[](https://github.com/cssnr/zipline-cli/actions/workflows/lint.yaml)
|
|
@@ -26,17 +27,17 @@
|
|
|
26
27
|
<a title="Zipline CLI" href="https://zipline-cli.cssnr.com/" target="_blank">
|
|
27
28
|
<img alt="Zipline CLI" align="right" width="128" height="auto" src="https://raw.githubusercontent.com/smashedr/repo-images/refs/heads/master/zipline/cli/logo128.png"></a>
|
|
28
29
|
|
|
29
|
-
- [Quick Start](#
|
|
30
|
-
- [Install](#
|
|
31
|
-
- [Usage](#
|
|
32
|
-
- [Environment Variables](#
|
|
33
|
-
- [API Reference](#
|
|
34
|
-
- [Support](#
|
|
35
|
-
- [Contributing](#
|
|
30
|
+
- [Quick Start](#quick-start)
|
|
31
|
+
- [Install](#install)
|
|
32
|
+
- [Usage](#usage)
|
|
33
|
+
- [Environment Variables](#environment-variables)
|
|
34
|
+
- [API Reference](#api-reference)
|
|
35
|
+
- [Support](#support)
|
|
36
|
+
- [Contributing](#contributing)
|
|
36
37
|
|
|
37
38
|
Python 3 CLI File Uploader for [Diced/Zipline](https://github.com/diced/zipline) v3/v4 Upload Server and [Django Files](https://github.com/django-files/django-files).
|
|
38
39
|
|
|
39
|
-
- Zipline: [https://zipline.diced.
|
|
40
|
+
- Zipline: [https://zipline.diced.sh/](https://zipline.diced.sh/)
|
|
40
41
|
- Django Files: [https://django-files.github.io/](https://django-files.github.io/)
|
|
41
42
|
|
|
42
43
|
> [!TIP]
|
|
@@ -44,16 +45,16 @@ Python 3 CLI File Uploader for [Diced/Zipline](https://github.com/diced/zipline)
|
|
|
44
45
|
> You can also [request new features](https://github.com/cssnr/zipline-cli/discussions/new?category=feature-requests)
|
|
45
46
|
> or report any [issues](https://github.com/cssnr/zipline-cli/issues/new).
|
|
46
47
|
|
|
47
|
-
## Quick Start
|
|
48
|
+
## Quick Start<a id="quick-start"></a>
|
|
48
49
|
|
|
49
50
|
```shell
|
|
50
51
|
python -m pip install zipline-cli
|
|
51
52
|
zipline --setup
|
|
52
53
|
```
|
|
53
54
|
|
|
54
|
-
Documentation
|
|
55
|
+
[](https://zipline-cli.cssnr.com/)
|
|
55
56
|
|
|
56
|
-
## Install
|
|
57
|
+
## Install<a id="install"></a>
|
|
57
58
|
|
|
58
59
|
From PyPI: https://pypi.org/p/zipline-cli
|
|
59
60
|
|
|
@@ -80,7 +81,7 @@ Uninstall.
|
|
|
80
81
|
python -m pip uninstall zipline-cli
|
|
81
82
|
```
|
|
82
83
|
|
|
83
|
-
## Usage
|
|
84
|
+
## Usage<a id="usage"></a>
|
|
84
85
|
|
|
85
86
|
> [!TIP]
|
|
86
87
|
> View the [Getting Started](https://zipline-cli.cssnr.com/) guide online.
|
|
@@ -116,19 +117,19 @@ zipline
|
|
|
116
117
|
# Paste or Type contents, followed by a newline, then Ctrl+D (Ctrl+Z on Windows)
|
|
117
118
|
```
|
|
118
119
|
|
|
119
|
-
## Environment Variables
|
|
120
|
+
## Environment Variables<a id="environment-variables"></a>
|
|
120
121
|
|
|
121
122
|
Environment Variables are stored in the `.zipline` file in your home directory.
|
|
122
123
|
|
|
123
124
|
- Location: `~/.zipline` or `$HOME/.zipline`
|
|
124
125
|
|
|
125
|
-
| Variable | Description
|
|
126
|
-
| ---------------- |
|
|
127
|
-
| `ZIPLINE_URL` | URL to your Zipline Instance
|
|
128
|
-
| `ZIPLINE_TOKEN` | Authorization Token from Zipline
|
|
129
|
-
| `ZIPLINE_EMBED` | Set this enable Embed on your uploads
|
|
130
|
-
| `ZIPLINE_FORMAT` | Output Format. Variables: `{filename}`, `{url}` and `{raw_url}`
|
|
131
|
-
| `ZIPLINE_EXPIRE` | Reference: [Zipline](https://zipline.diced.
|
|
126
|
+
| Variable | Description |
|
|
127
|
+
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
128
|
+
| `ZIPLINE_URL` | URL to your Zipline Instance |
|
|
129
|
+
| `ZIPLINE_TOKEN` | Authorization Token from Zipline |
|
|
130
|
+
| `ZIPLINE_EMBED` | Set this enable Embed on your uploads |
|
|
131
|
+
| `ZIPLINE_FORMAT` | Output Format. Variables: `{filename}`, `{url}` and `{raw_url}` |
|
|
132
|
+
| `ZIPLINE_EXPIRE` | Reference: [Zipline](https://zipline.diced.sh/docs/guides/upload-options#image-expiration) / [Django Files](https://github.com/onegreyonewhite/pytimeparse2#pytimeparse2-time-expression-parser) |
|
|
132
133
|
|
|
133
134
|
See [.zipline.example](.zipline.example) for an example `.zipline` file.
|
|
134
135
|
|
|
@@ -139,7 +140,7 @@ or using the corresponding command line arguments.
|
|
|
139
140
|
zipline -h
|
|
140
141
|
```
|
|
141
142
|
|
|
142
|
-
## API Reference
|
|
143
|
+
## API Reference<a id="api-reference"></a>
|
|
143
144
|
|
|
144
145
|
Initialize the class with your Zipline URL.
|
|
145
146
|
Everything else is a header passed as a kwarg.
|
|
@@ -162,7 +163,7 @@ with open('text.txt') as f:
|
|
|
162
163
|
print(url)
|
|
163
164
|
```
|
|
164
165
|
|
|
165
|
-
# Support
|
|
166
|
+
# Support<a id="support"></a>
|
|
166
167
|
|
|
167
168
|
For general help or to request a feature, see:
|
|
168
169
|
|
|
@@ -176,7 +177,7 @@ If you are experiencing an issue/bug or getting unexpected results, you can:
|
|
|
176
177
|
- Provide General Feedback: [https://cssnr.github.io/feedback/](https://cssnr.github.io/feedback/?app=zipline-cli)
|
|
177
178
|
- Chat with us on Discord: https://discord.gg/wXy6m2X8wY
|
|
178
179
|
|
|
179
|
-
# Contributing
|
|
180
|
+
# Contributing<a id="contributing"></a>
|
|
180
181
|
|
|
181
182
|
All contributions are welcome including [bug reports](https://github.com/cssnr/zipline-cli/issues),
|
|
182
183
|
[feature requests](https://github.com/cssnr/zipline-cli/discussions/categories/feature-requests),
|
|
@@ -8,20 +8,20 @@ readme = "README.md"
|
|
|
8
8
|
dynamic = ["version"]
|
|
9
9
|
requires-python = ">=3.9"
|
|
10
10
|
classifiers = [
|
|
11
|
-
"License :: OSI Approved :: MIT License",
|
|
12
|
-
"Operating System :: OS Independent",
|
|
13
|
-
"Natural Language :: English",
|
|
14
11
|
"Programming Language :: Python",
|
|
15
12
|
"Programming Language :: Python :: 3",
|
|
16
13
|
"Programming Language :: Python :: 3 :: Only",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
14
|
+
"Operating System :: OS Independent",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Natural Language :: English",
|
|
17
|
+
"Typing :: Typed",
|
|
18
|
+
"Topic :: Communications :: File Sharing",
|
|
19
|
+
"Topic :: Terminals",
|
|
19
20
|
]
|
|
20
21
|
license = { text = "MIT License" }
|
|
21
22
|
#license = { file = "LICENSE" }
|
|
22
23
|
|
|
23
24
|
dependencies = [
|
|
24
|
-
"binaryornot",
|
|
25
25
|
"python-decouple",
|
|
26
26
|
"python-dotenv",
|
|
27
27
|
"requests",
|
|
@@ -38,11 +38,10 @@ dev = [
|
|
|
38
38
|
"psycopg2",
|
|
39
39
|
"ruff",
|
|
40
40
|
"setuptools",
|
|
41
|
-
"twine",
|
|
42
41
|
"ty",
|
|
43
|
-
"types-binaryornot",
|
|
44
42
|
"types-psycopg2",
|
|
45
43
|
"types-requests",
|
|
44
|
+
"validate-pyproject[all]",
|
|
46
45
|
"wheel",
|
|
47
46
|
]
|
|
48
47
|
|
|
@@ -50,11 +49,14 @@ dev = [
|
|
|
50
49
|
zipline = "zipline.zipline:main"
|
|
51
50
|
|
|
52
51
|
[project.urls]
|
|
53
|
-
|
|
54
|
-
Documentation = "https://zipline-cli.cssnr.com/"
|
|
55
|
-
Source = "https://github.com/cssnr/zipline-cli"
|
|
52
|
+
GitHub = "https://github.com/cssnr/zipline-cli"
|
|
56
53
|
Issues = "https://github.com/cssnr/zipline-cli/issues"
|
|
54
|
+
Changelog = "https://github.com/cssnr/zipline-cli/releases"
|
|
55
|
+
Documentation = "https://zipline-cli.cssnr.com/"
|
|
56
|
+
|
|
57
|
+
Homepage = "https://cssnr.com/"
|
|
57
58
|
Funding = "https://ko-fi.com/cssnr"
|
|
59
|
+
Discord = "https://discord.gg/wXy6m2X8wY"
|
|
58
60
|
|
|
59
61
|
# Setup Tools
|
|
60
62
|
# https://setuptools.pypa.io/en/latest/
|
|
File without changes
|
|
@@ -8,10 +8,9 @@ import string
|
|
|
8
8
|
import sys
|
|
9
9
|
from importlib.metadata import version
|
|
10
10
|
from pathlib import Path
|
|
11
|
-
from typing import IO, Any, Dict, List,
|
|
11
|
+
from typing import IO, Any, Dict, List, Optional, TextIO
|
|
12
12
|
|
|
13
13
|
import requests
|
|
14
|
-
from binaryornot.check import is_binary
|
|
15
14
|
from decouple import config
|
|
16
15
|
from dotenv import find_dotenv, load_dotenv
|
|
17
16
|
|
|
@@ -19,7 +18,7 @@ from dotenv import find_dotenv, load_dotenv
|
|
|
19
18
|
class ZipURL(object):
|
|
20
19
|
"""
|
|
21
20
|
Zipline URL Object
|
|
22
|
-
:param file_url:
|
|
21
|
+
:param file_url: Zipline File Display URL
|
|
23
22
|
"""
|
|
24
23
|
|
|
25
24
|
__slots__ = ["url", "raw"]
|
|
@@ -46,7 +45,7 @@ class ZipURL(object):
|
|
|
46
45
|
class Zipline(object):
|
|
47
46
|
"""
|
|
48
47
|
Zipline Python API
|
|
49
|
-
:param base_url:
|
|
48
|
+
:param base_url: Zipline URL
|
|
50
49
|
:param kwargs: Zipline Headers
|
|
51
50
|
"""
|
|
52
51
|
|
|
@@ -93,12 +92,11 @@ class Zipline(object):
|
|
|
93
92
|
|
|
94
93
|
def send_file(self, file_name: str, file_object: IO, overrides: Optional[dict] = None) -> ZipURL:
|
|
95
94
|
"""
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
:param
|
|
99
|
-
:param
|
|
100
|
-
:
|
|
101
|
-
:return: str: File URL
|
|
95
|
+
Upload File to Zipline
|
|
96
|
+
:param file_name: Name of File for files tuple
|
|
97
|
+
:param file_object: File to Upload
|
|
98
|
+
:param overrides: Header Overrides
|
|
99
|
+
:return: File URL
|
|
102
100
|
"""
|
|
103
101
|
url = self.base_url + "/api/upload"
|
|
104
102
|
|
|
@@ -106,7 +104,8 @@ class Zipline(object):
|
|
|
106
104
|
if not path.is_file():
|
|
107
105
|
raise ValueError(f"Not a File: {path.resolve()}")
|
|
108
106
|
|
|
109
|
-
mime_type = get_type(
|
|
107
|
+
mime_type = get_type(path)
|
|
108
|
+
# print(f"mime_type: {mime_type}")
|
|
110
109
|
files = {"file": (file_name, file_object, mime_type)}
|
|
111
110
|
headers = self._headers | overrides if overrides else self._headers
|
|
112
111
|
r = requests.post(url, headers=headers, files=files) # nosec
|
|
@@ -120,31 +119,61 @@ class Zipline(object):
|
|
|
120
119
|
return ZipURL(data)
|
|
121
120
|
|
|
122
121
|
|
|
123
|
-
def get_type(
|
|
122
|
+
def get_type(file_path: Path) -> str:
|
|
124
123
|
# Deprecated since version 3.13: Passing a file path instead of URL is soft deprecated. Use guess_file_type() for this.
|
|
125
124
|
# https://docs.python.org/3/library/mimetypes.html#mimetypes.guess_type
|
|
126
|
-
mime_type, _ = mimetypes.guess_type(
|
|
125
|
+
mime_type, _ = mimetypes.guess_type(file_path, strict=False)
|
|
127
126
|
if mime_type:
|
|
128
127
|
return mime_type
|
|
129
|
-
return
|
|
128
|
+
return magic_type(file_path)
|
|
130
129
|
|
|
131
130
|
|
|
132
|
-
def
|
|
131
|
+
def magic_type(file_path: Path) -> str: # NOSONAR
|
|
133
132
|
try:
|
|
134
133
|
with open(file_path, "rb") as file:
|
|
135
|
-
chunk = file.read(
|
|
134
|
+
chunk = file.read(512)
|
|
135
|
+
# print(chunk)
|
|
136
|
+
if chunk[0:3] == b"\xff\xd8\xff" or chunk[6:10] in (b"JFIF", b"Exif"):
|
|
137
|
+
return "image/jpeg"
|
|
138
|
+
elif chunk.startswith(b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a"):
|
|
139
|
+
return "image/png"
|
|
140
|
+
elif chunk.startswith(b"RIFF") and chunk[8:12] == b"WEBP":
|
|
141
|
+
return "image/webp"
|
|
142
|
+
elif chunk.startswith((b"\x47\x49\x46\x38\x37\x61", b"\x47\x49\x46\x38\x39\x61")):
|
|
143
|
+
return "image/gif"
|
|
144
|
+
elif chunk.startswith(b"\x66\x74\x79\x70\x68\x65\x69\x63\x66\x74\79\70\6d"):
|
|
145
|
+
return "image/heic"
|
|
146
|
+
elif chunk.startswith(b"\x00\x00\x01\x00"):
|
|
147
|
+
return "image/ico"
|
|
148
|
+
|
|
149
|
+
elif chunk[3:11] in (b"\x66\x74\x79\x70\x4d\x53\x4e\x56", b"\x66\x74\x79\x70\x69\x73\x6f\x6d"):
|
|
150
|
+
return "video/mp4"
|
|
151
|
+
elif chunk[4:12] == b"ftypisom" or chunk[4:12] == b"ftypMSNV" or chunk[4:12] == b"ftypmp42":
|
|
152
|
+
return "video/mp4"
|
|
153
|
+
elif chunk.startswith(b"\x1a\x45\xdf\xa3"):
|
|
154
|
+
return "video/x-matroska"
|
|
155
|
+
elif chunk.startswith(b"\x6d\x6f\x6f\x76"):
|
|
156
|
+
return "video/quicktime"
|
|
157
|
+
|
|
158
|
+
elif chunk.startswith((b"\xff\xfb", b"\xff\xfb", b"\xff\xfb", b"\x49\x44\x33")):
|
|
159
|
+
return "audio/mp3"
|
|
160
|
+
elif chunk.startswith(b"RIFF") and chunk[8:12] == b"WAVE":
|
|
161
|
+
return "audio/wav"
|
|
162
|
+
elif chunk.startswith(b"OggS"):
|
|
163
|
+
return "application/ogg"
|
|
164
|
+
|
|
136
165
|
chunk.decode("utf-8")
|
|
166
|
+
return "text/plain"
|
|
137
167
|
except UnicodeDecodeError:
|
|
138
|
-
return "
|
|
139
|
-
return "r"
|
|
168
|
+
return "application/octet-stream"
|
|
140
169
|
|
|
141
170
|
|
|
142
171
|
def format_output(filename: str, url: ZipURL) -> str:
|
|
143
172
|
"""
|
|
144
173
|
Format URL Output
|
|
145
|
-
:param filename:
|
|
146
|
-
:param url: ZipURL
|
|
147
|
-
:return:
|
|
174
|
+
:param filename: Original or File Name
|
|
175
|
+
:param url: ZipURL to Format
|
|
176
|
+
:return: Formatted Output
|
|
148
177
|
"""
|
|
149
178
|
zipline_format = config("ZIPLINE_FORMAT", "{filename}\n{url}\n{raw_url}")
|
|
150
179
|
return zipline_format.format(filename=filename, url=url, raw_url=url.raw)
|
|
@@ -152,9 +181,9 @@ def format_output(filename: str, url: ZipURL) -> str:
|
|
|
152
181
|
|
|
153
182
|
def gen_rand(length: int = 4) -> str:
|
|
154
183
|
"""
|
|
155
|
-
Generate Random Streng
|
|
156
|
-
:param length:
|
|
157
|
-
:return:
|
|
184
|
+
Generate Random Streng
|
|
185
|
+
:param length: Length of String
|
|
186
|
+
:return: Random String
|
|
158
187
|
"""
|
|
159
188
|
r = "".join(secrets.choice(string.ascii_letters) for _ in range(length))
|
|
160
189
|
return "".join(r)
|
|
@@ -169,12 +198,12 @@ def get_default(
|
|
|
169
198
|
) -> Optional[str]:
|
|
170
199
|
"""
|
|
171
200
|
Get Default Environment Variable from List of values
|
|
172
|
-
:param values:
|
|
173
|
-
:param default:
|
|
174
|
-
:param cast:
|
|
175
|
-
:param pre:
|
|
176
|
-
:param suf:
|
|
177
|
-
:return:
|
|
201
|
+
:param values: List of Values to Check
|
|
202
|
+
:param default: Default Value if None
|
|
203
|
+
:param cast: Type to Cast Value
|
|
204
|
+
:param pre: Environment Variable Prefix
|
|
205
|
+
:param suf: Environment Variable Suffix
|
|
206
|
+
:return: Environment Variable or None
|
|
178
207
|
"""
|
|
179
208
|
for value in values:
|
|
180
209
|
result = config(f"{pre}{value.upper()}{suf}", "", cast)
|
|
@@ -234,7 +263,7 @@ def run() -> None:
|
|
|
234
263
|
"--expire",
|
|
235
264
|
type=str,
|
|
236
265
|
default=get_default(["expire", "expire_at"]),
|
|
237
|
-
help="Ex: 1d, 2w. See: https://zipline.diced.
|
|
266
|
+
help="Ex: 1d, 2w. See: https://zipline.diced.sh/docs/guides/upload-options#image-expiration",
|
|
238
267
|
)
|
|
239
268
|
parser.add_argument(
|
|
240
269
|
"--embed", action="store_true", default=get_default(["embed"], False, bool), help="Enable Embeds on Uploads."
|
|
@@ -294,8 +323,8 @@ def run() -> None:
|
|
|
294
323
|
if not os.path.isfile(name):
|
|
295
324
|
print(f"Warning: File Not Found: {name}")
|
|
296
325
|
continue
|
|
297
|
-
mode: Literal["r", "rb"] = get_mode(name)
|
|
298
|
-
with open(name,
|
|
326
|
+
# mode: Literal["r", "rb"] = get_mode(name)
|
|
327
|
+
with open(name, "rb") as f:
|
|
299
328
|
# name, ext = os.path.splitext(os.path.basename(filename))
|
|
300
329
|
# ext = f'.{ext}' if ext else ''
|
|
301
330
|
# name = f'{name}-{gen_rand(8)}{ext}'
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: zipline-cli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Python 3 CLI File Uploader for Diced/Zipline v3/v4 Upload Server and Django Files.
|
|
5
5
|
Author: Shane
|
|
6
6
|
License: MIT License
|
|
7
|
-
Project-URL:
|
|
8
|
-
Project-URL: Documentation, https://zipline-cli.cssnr.com/
|
|
9
|
-
Project-URL: Source, https://github.com/cssnr/zipline-cli
|
|
7
|
+
Project-URL: GitHub, https://github.com/cssnr/zipline-cli
|
|
10
8
|
Project-URL: Issues, https://github.com/cssnr/zipline-cli/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/cssnr/zipline-cli/releases
|
|
10
|
+
Project-URL: Documentation, https://zipline-cli.cssnr.com/
|
|
11
|
+
Project-URL: Homepage, https://cssnr.com/
|
|
11
12
|
Project-URL: Funding, https://ko-fi.com/cssnr
|
|
12
|
-
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Classifier: Natural Language :: English
|
|
13
|
+
Project-URL: Discord, https://discord.gg/wXy6m2X8wY
|
|
15
14
|
Classifier: Programming Language :: Python
|
|
16
15
|
Classifier: Programming Language :: Python :: 3
|
|
17
16
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
-
Classifier:
|
|
19
|
-
Classifier:
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Natural Language :: English
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Classifier: Topic :: Communications :: File Sharing
|
|
22
|
+
Classifier: Topic :: Terminals
|
|
20
23
|
Requires-Python: >=3.9
|
|
21
24
|
Description-Content-Type: text/markdown
|
|
22
25
|
License-File: LICENSE
|
|
23
|
-
Requires-Dist: binaryornot
|
|
24
26
|
Requires-Dist: python-decouple
|
|
25
27
|
Requires-Dist: python-dotenv
|
|
26
28
|
Requires-Dist: requests
|
|
@@ -31,6 +33,7 @@ Dynamic: license-file
|
|
|
31
33
|
[](https://github.com/cssnr/zipline-cli?tab=readme-ov-file#readme)
|
|
32
34
|
[](https://pypistats.org/packages/zipline-cli)
|
|
33
35
|
[](https://clickpy.clickhouse.com/dashboard/zipline-cli)
|
|
36
|
+
[](https://app.codacy.com/gh/cssnr/zipline-cli/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
|
34
37
|
[](https://sonarcloud.io/summary/new_code?id=cssnr_zipline-cli)
|
|
35
38
|
[](https://github.com/cssnr/zipline-cli/actions/workflows/test.yaml)
|
|
36
39
|
[](https://github.com/cssnr/zipline-cli/actions/workflows/lint.yaml)
|
|
@@ -54,17 +57,17 @@ Dynamic: license-file
|
|
|
54
57
|
<a title="Zipline CLI" href="https://zipline-cli.cssnr.com/" target="_blank">
|
|
55
58
|
<img alt="Zipline CLI" align="right" width="128" height="auto" src="https://raw.githubusercontent.com/smashedr/repo-images/refs/heads/master/zipline/cli/logo128.png"></a>
|
|
56
59
|
|
|
57
|
-
- [Quick Start](#
|
|
58
|
-
- [Install](#
|
|
59
|
-
- [Usage](#
|
|
60
|
-
- [Environment Variables](#
|
|
61
|
-
- [API Reference](#
|
|
62
|
-
- [Support](#
|
|
63
|
-
- [Contributing](#
|
|
60
|
+
- [Quick Start](#quick-start)
|
|
61
|
+
- [Install](#install)
|
|
62
|
+
- [Usage](#usage)
|
|
63
|
+
- [Environment Variables](#environment-variables)
|
|
64
|
+
- [API Reference](#api-reference)
|
|
65
|
+
- [Support](#support)
|
|
66
|
+
- [Contributing](#contributing)
|
|
64
67
|
|
|
65
68
|
Python 3 CLI File Uploader for [Diced/Zipline](https://github.com/diced/zipline) v3/v4 Upload Server and [Django Files](https://github.com/django-files/django-files).
|
|
66
69
|
|
|
67
|
-
- Zipline: [https://zipline.diced.
|
|
70
|
+
- Zipline: [https://zipline.diced.sh/](https://zipline.diced.sh/)
|
|
68
71
|
- Django Files: [https://django-files.github.io/](https://django-files.github.io/)
|
|
69
72
|
|
|
70
73
|
> [!TIP]
|
|
@@ -72,16 +75,16 @@ Python 3 CLI File Uploader for [Diced/Zipline](https://github.com/diced/zipline)
|
|
|
72
75
|
> You can also [request new features](https://github.com/cssnr/zipline-cli/discussions/new?category=feature-requests)
|
|
73
76
|
> or report any [issues](https://github.com/cssnr/zipline-cli/issues/new).
|
|
74
77
|
|
|
75
|
-
## Quick Start
|
|
78
|
+
## Quick Start<a id="quick-start"></a>
|
|
76
79
|
|
|
77
80
|
```shell
|
|
78
81
|
python -m pip install zipline-cli
|
|
79
82
|
zipline --setup
|
|
80
83
|
```
|
|
81
84
|
|
|
82
|
-
Documentation
|
|
85
|
+
[](https://zipline-cli.cssnr.com/)
|
|
83
86
|
|
|
84
|
-
## Install
|
|
87
|
+
## Install<a id="install"></a>
|
|
85
88
|
|
|
86
89
|
From PyPI: https://pypi.org/p/zipline-cli
|
|
87
90
|
|
|
@@ -108,7 +111,7 @@ Uninstall.
|
|
|
108
111
|
python -m pip uninstall zipline-cli
|
|
109
112
|
```
|
|
110
113
|
|
|
111
|
-
## Usage
|
|
114
|
+
## Usage<a id="usage"></a>
|
|
112
115
|
|
|
113
116
|
> [!TIP]
|
|
114
117
|
> View the [Getting Started](https://zipline-cli.cssnr.com/) guide online.
|
|
@@ -144,19 +147,19 @@ zipline
|
|
|
144
147
|
# Paste or Type contents, followed by a newline, then Ctrl+D (Ctrl+Z on Windows)
|
|
145
148
|
```
|
|
146
149
|
|
|
147
|
-
## Environment Variables
|
|
150
|
+
## Environment Variables<a id="environment-variables"></a>
|
|
148
151
|
|
|
149
152
|
Environment Variables are stored in the `.zipline` file in your home directory.
|
|
150
153
|
|
|
151
154
|
- Location: `~/.zipline` or `$HOME/.zipline`
|
|
152
155
|
|
|
153
|
-
| Variable | Description
|
|
154
|
-
| ---------------- |
|
|
155
|
-
| `ZIPLINE_URL` | URL to your Zipline Instance
|
|
156
|
-
| `ZIPLINE_TOKEN` | Authorization Token from Zipline
|
|
157
|
-
| `ZIPLINE_EMBED` | Set this enable Embed on your uploads
|
|
158
|
-
| `ZIPLINE_FORMAT` | Output Format. Variables: `{filename}`, `{url}` and `{raw_url}`
|
|
159
|
-
| `ZIPLINE_EXPIRE` | Reference: [Zipline](https://zipline.diced.
|
|
156
|
+
| Variable | Description |
|
|
157
|
+
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
158
|
+
| `ZIPLINE_URL` | URL to your Zipline Instance |
|
|
159
|
+
| `ZIPLINE_TOKEN` | Authorization Token from Zipline |
|
|
160
|
+
| `ZIPLINE_EMBED` | Set this enable Embed on your uploads |
|
|
161
|
+
| `ZIPLINE_FORMAT` | Output Format. Variables: `{filename}`, `{url}` and `{raw_url}` |
|
|
162
|
+
| `ZIPLINE_EXPIRE` | Reference: [Zipline](https://zipline.diced.sh/docs/guides/upload-options#image-expiration) / [Django Files](https://github.com/onegreyonewhite/pytimeparse2#pytimeparse2-time-expression-parser) |
|
|
160
163
|
|
|
161
164
|
See [.zipline.example](.zipline.example) for an example `.zipline` file.
|
|
162
165
|
|
|
@@ -167,7 +170,7 @@ or using the corresponding command line arguments.
|
|
|
167
170
|
zipline -h
|
|
168
171
|
```
|
|
169
172
|
|
|
170
|
-
## API Reference
|
|
173
|
+
## API Reference<a id="api-reference"></a>
|
|
171
174
|
|
|
172
175
|
Initialize the class with your Zipline URL.
|
|
173
176
|
Everything else is a header passed as a kwarg.
|
|
@@ -190,7 +193,7 @@ with open('text.txt') as f:
|
|
|
190
193
|
print(url)
|
|
191
194
|
```
|
|
192
195
|
|
|
193
|
-
# Support
|
|
196
|
+
# Support<a id="support"></a>
|
|
194
197
|
|
|
195
198
|
For general help or to request a feature, see:
|
|
196
199
|
|
|
@@ -204,7 +207,7 @@ If you are experiencing an issue/bug or getting unexpected results, you can:
|
|
|
204
207
|
- Provide General Feedback: [https://cssnr.github.io/feedback/](https://cssnr.github.io/feedback/?app=zipline-cli)
|
|
205
208
|
- Chat with us on Discord: https://discord.gg/wXy6m2X8wY
|
|
206
209
|
|
|
207
|
-
# Contributing
|
|
210
|
+
# Contributing<a id="contributing"></a>
|
|
208
211
|
|
|
209
212
|
All contributions are welcome including [bug reports](https://github.com/cssnr/zipline-cli/issues),
|
|
210
213
|
[feature requests](https://github.com/cssnr/zipline-cli/discussions/categories/feature-requests),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|