slike 0.1.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.
- slike-0.1.0/.gitignore +139 -0
- slike-0.1.0/LICENSE +22 -0
- slike-0.1.0/PKG-INFO +292 -0
- slike-0.1.0/README.md +263 -0
- slike-0.1.0/config.example.toml +15 -0
- slike-0.1.0/js/README.md +282 -0
- slike-0.1.0/pyproject.toml +55 -0
- slike-0.1.0/slike.py +606 -0
- slike-0.1.0/slikeupload.py +295 -0
slike-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
pip-wheel-metadata/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
*.manifest
|
|
32
|
+
*.spec
|
|
33
|
+
|
|
34
|
+
# Installer logs
|
|
35
|
+
pip-log.txt
|
|
36
|
+
pip-delete-this-directory.txt
|
|
37
|
+
|
|
38
|
+
# Unit test / coverage reports
|
|
39
|
+
htmlcov/
|
|
40
|
+
.tox/
|
|
41
|
+
.nox/
|
|
42
|
+
.coverage
|
|
43
|
+
.coverage.*
|
|
44
|
+
.cache
|
|
45
|
+
nosetests.xml
|
|
46
|
+
coverage.xml
|
|
47
|
+
*.cover
|
|
48
|
+
*.py,cover
|
|
49
|
+
.hypothesis/
|
|
50
|
+
.pytest_cache/
|
|
51
|
+
|
|
52
|
+
# Translations
|
|
53
|
+
*.mo
|
|
54
|
+
*.pot
|
|
55
|
+
|
|
56
|
+
# Django stuff:
|
|
57
|
+
*.log
|
|
58
|
+
local_settings.py
|
|
59
|
+
db.sqlite3
|
|
60
|
+
db.sqlite3-journal
|
|
61
|
+
|
|
62
|
+
# Flask stuff:
|
|
63
|
+
instance/
|
|
64
|
+
.webassets-cache
|
|
65
|
+
|
|
66
|
+
# Scrapy stuff:
|
|
67
|
+
.scrapy
|
|
68
|
+
|
|
69
|
+
# Sphinx documentation
|
|
70
|
+
docs/_build/
|
|
71
|
+
|
|
72
|
+
# PyBuilder
|
|
73
|
+
target/
|
|
74
|
+
|
|
75
|
+
# Jupyter Notebook
|
|
76
|
+
.ipynb_checkpoints
|
|
77
|
+
|
|
78
|
+
# IPython
|
|
79
|
+
profile_default/
|
|
80
|
+
ipython_config.py
|
|
81
|
+
|
|
82
|
+
# pyenv
|
|
83
|
+
.python-version
|
|
84
|
+
|
|
85
|
+
# pipenv
|
|
86
|
+
Pipfile.lock
|
|
87
|
+
|
|
88
|
+
# PEP 582
|
|
89
|
+
__pypackages__/
|
|
90
|
+
|
|
91
|
+
# Celery stuff
|
|
92
|
+
celerybeat-schedule
|
|
93
|
+
celerybeat.pid
|
|
94
|
+
|
|
95
|
+
# SageMath parsed files
|
|
96
|
+
*.sage.py
|
|
97
|
+
|
|
98
|
+
# Environments
|
|
99
|
+
.env
|
|
100
|
+
.venv
|
|
101
|
+
env/
|
|
102
|
+
venv/
|
|
103
|
+
ENV/
|
|
104
|
+
env.bak/
|
|
105
|
+
venv.bak/
|
|
106
|
+
|
|
107
|
+
# Spyder project settings
|
|
108
|
+
.spyderproject
|
|
109
|
+
.spyproject
|
|
110
|
+
|
|
111
|
+
# Rope project settings
|
|
112
|
+
.ropeproject
|
|
113
|
+
|
|
114
|
+
# mkdocs documentation
|
|
115
|
+
/site
|
|
116
|
+
|
|
117
|
+
# mypy
|
|
118
|
+
.mypy_cache/
|
|
119
|
+
.dmypy.json
|
|
120
|
+
dmypy.json
|
|
121
|
+
|
|
122
|
+
# Pyre type checker
|
|
123
|
+
.pyre/
|
|
124
|
+
|
|
125
|
+
# IDEs
|
|
126
|
+
.vscode/
|
|
127
|
+
.idea/
|
|
128
|
+
*.swp
|
|
129
|
+
*.swo
|
|
130
|
+
*~
|
|
131
|
+
.DS_Store
|
|
132
|
+
|
|
133
|
+
# Hatch
|
|
134
|
+
.hatch/
|
|
135
|
+
|
|
136
|
+
# Local config — contains tokens, never commit
|
|
137
|
+
config.toml
|
|
138
|
+
|
|
139
|
+
js/node_modules
|
slike-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Arpit Kumar
|
|
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
|
+
|
slike-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: slike
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for publishing media on Slike platform
|
|
5
|
+
Project-URL: Homepage, https://code.sli.ke/python/slike-media-package
|
|
6
|
+
Project-URL: Documentation, https://code.sli.ke/python/slike-media-package#readme
|
|
7
|
+
Project-URL: Repository, https://code.sli.ke/python/slike-media-package
|
|
8
|
+
Project-URL: Issues, https://code.sli.ke/python/slike-media-package/issues
|
|
9
|
+
Author: Arpit Kumar
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: api,media,publishing,sdk,slike
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Requires-Python: >=3.7
|
|
26
|
+
Requires-Dist: requests>=2.25.0
|
|
27
|
+
Requires-Dist: tomli>=1.2; python_version < '3.11'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# slike
|
|
31
|
+
|
|
32
|
+
Python SDK and CLI for the [Slike](https://sli.ke) platform.
|
|
33
|
+
|
|
34
|
+
Supports **chunked file upload** (4 MiB chunks), **editor-video registration**, **publish-by-URL** (Google Drive, YouTube, direct links), and two auth flows: **direct Slike token** or **Denmark JWT** (exchanged at `/login`).
|
|
35
|
+
|
|
36
|
+
Requires Python 3.7+.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip3 install slike
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Python SDK
|
|
49
|
+
|
|
50
|
+
The SDK is a client class. Construct with credentials, call `initialize()` once to validate them, then call methods.
|
|
51
|
+
|
|
52
|
+
### Quick start (direct Slike token)
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from slike import SlikeMedia
|
|
56
|
+
|
|
57
|
+
client = SlikeMedia(token="your-slike-token", environment="prod")
|
|
58
|
+
client.initialize() # validates the token via user.me; raises SlikeAPIError on failure
|
|
59
|
+
|
|
60
|
+
# Upload a local file
|
|
61
|
+
result = client.register_media(
|
|
62
|
+
file_path="/path/to/video.mp4",
|
|
63
|
+
title="My Video",
|
|
64
|
+
description="Description",
|
|
65
|
+
on_progress=lambda done, total: print(f"{done}/{total} chunks"),
|
|
66
|
+
)
|
|
67
|
+
print(result["id"])
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Quick start (Denmark JWT)
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from slike import SlikeMedia
|
|
74
|
+
|
|
75
|
+
client = SlikeMedia(
|
|
76
|
+
denmark_token="<jwt>", # exchanged for a Slike session token at /login
|
|
77
|
+
service="slike", # optional, default: "slike"
|
|
78
|
+
environment="prod",
|
|
79
|
+
)
|
|
80
|
+
client.initialize() # exchanges the JWT; raises SlikeAPIError on failure
|
|
81
|
+
|
|
82
|
+
print(client.token) # the resolved Slike session token
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
You must provide exactly one of `token` or `denmark_token`.
|
|
86
|
+
|
|
87
|
+
### Methods
|
|
88
|
+
|
|
89
|
+
#### `register_media`
|
|
90
|
+
|
|
91
|
+
Register media on Slike. Provide exactly one of `file_path` (chunked file upload) or `editor_settings` (editor-generated video — no bytes uploaded; the asset server renders from the spec).
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
# File mode
|
|
95
|
+
client.register_media(
|
|
96
|
+
file_path="/path/to/video.mp4",
|
|
97
|
+
title="My Video",
|
|
98
|
+
description="Description",
|
|
99
|
+
asset_type="video", # optional, default: "video"
|
|
100
|
+
tags=["news", "sports"], # optional
|
|
101
|
+
preset_config={"meta": "", "social": ""}, # optional
|
|
102
|
+
on_progress=lambda done, total: print(f"{done}/{total} chunks"),
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Editor mode
|
|
106
|
+
client.register_media(
|
|
107
|
+
title="My Editor Video",
|
|
108
|
+
description="Description",
|
|
109
|
+
editor_settings={
|
|
110
|
+
"clips": [...],
|
|
111
|
+
"background_music": {...},
|
|
112
|
+
"source_width": 1080,
|
|
113
|
+
"source_height": 1920,
|
|
114
|
+
},
|
|
115
|
+
)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### `publish_media`
|
|
119
|
+
|
|
120
|
+
Publish media by URL (Google Drive, YouTube, direct link).
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
client.publish_media(
|
|
124
|
+
url="https://drive.google.com/file/d/FILE_ID/view",
|
|
125
|
+
title="My Video",
|
|
126
|
+
description="Description",
|
|
127
|
+
type="gdrive", # gdrive | youtube | url
|
|
128
|
+
asset_type="video", # optional
|
|
129
|
+
tags=["news", "sports"], # optional
|
|
130
|
+
auto_publish=True, # optional, default: True
|
|
131
|
+
)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Error handling
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from slike import SlikeMedia, SlikeAPIError
|
|
138
|
+
|
|
139
|
+
try:
|
|
140
|
+
client = SlikeMedia(token="...", environment="prod")
|
|
141
|
+
client.initialize()
|
|
142
|
+
result = client.register_media(file_path="video.mp4", title="T", description="D")
|
|
143
|
+
except ValueError as e:
|
|
144
|
+
print(f"Bad input: {e}")
|
|
145
|
+
except SlikeAPIError as e:
|
|
146
|
+
print(f"API / auth error: {e}")
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Configuration (CLI only)
|
|
152
|
+
|
|
153
|
+
The CLI accepts the token + environment inline, falls back to env vars and a config file. The Python SDK takes them as constructor arguments — no file reads.
|
|
154
|
+
|
|
155
|
+
### Priority (highest wins)
|
|
156
|
+
|
|
157
|
+
1. CLI flags (`--token`, `--denmark-token`, `--env`, `--config`)
|
|
158
|
+
2. Environment variables (`SLIKE_TOKEN`, `SLIKE_ENVIRONMENT`, `SLIKE_CONFIG`)
|
|
159
|
+
3. `./config.toml` (current directory), then `~/.slike/config.toml`
|
|
160
|
+
|
|
161
|
+
### Config file format
|
|
162
|
+
|
|
163
|
+
```toml
|
|
164
|
+
token = "your-token-here"
|
|
165
|
+
environment = "prod" # "dev" or "prod"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Environment variables
|
|
169
|
+
|
|
170
|
+
| Variable | Description |
|
|
171
|
+
|---------------------|-----------------------------------------|
|
|
172
|
+
| `SLIKE_TOKEN` | Slike auth token |
|
|
173
|
+
| `SLIKE_ENVIRONMENT` | `dev` or `prod` |
|
|
174
|
+
| `SLIKE_CONFIG` | Path to a specific config file |
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## CLI
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Upload a local file
|
|
182
|
+
slike-upload video.mp4 --title "My Video" --desc "Description"
|
|
183
|
+
|
|
184
|
+
# Publish by URL (Google Drive)
|
|
185
|
+
slike-upload --url https://drive.google.com/file/d/FILE_ID/view \
|
|
186
|
+
--type gdrive --title "My Video" --desc "Description"
|
|
187
|
+
|
|
188
|
+
# Use a Denmark JWT instead of a Slike token
|
|
189
|
+
slike-upload video.mp4 --title "T" --desc "D" --denmark-token <jwt>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Publish by URL
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
slike-upload --url <URL> --type <gdrive|youtube|url>
|
|
196
|
+
--title "Title" --desc "Description"
|
|
197
|
+
[--asset-type video|shorts]
|
|
198
|
+
[--tags tag1,tag2]
|
|
199
|
+
[--no-publish]
|
|
200
|
+
[--token <token> | --denmark-token <jwt> [--service <name>]]
|
|
201
|
+
[--env dev|prod] [--config <path>]
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
| Flag | Required | Description |
|
|
205
|
+
|-------------------|----------|----------------------------------------------------------|
|
|
206
|
+
| `--url` | yes | Media URL to ingest |
|
|
207
|
+
| `--type` | no | `gdrive`, `youtube`, or `url` (default: `url`) |
|
|
208
|
+
| `--title` | yes | Media title |
|
|
209
|
+
| `--desc` | yes | Media description |
|
|
210
|
+
| `--asset-type` | no | Asset type, e.g. `video`, `shorts` (default: `video`) |
|
|
211
|
+
| `--tags` | no | Comma-separated tags |
|
|
212
|
+
| `--no-publish` | no | Save as draft, skip auto-publish |
|
|
213
|
+
| `--token` | no | Slike auth token |
|
|
214
|
+
| `--denmark-token` | no | Denmark JWT (exchanged for a Slike session token) |
|
|
215
|
+
| `--service` | no | Service name for Denmark auth (default: `slike`) |
|
|
216
|
+
| `--env` | no | `dev` or `prod` (overrides config) |
|
|
217
|
+
| `--config` | no | Path to config file |
|
|
218
|
+
|
|
219
|
+
### Upload a local file
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
slike-upload <file>
|
|
223
|
+
--title "Title" --desc "Description"
|
|
224
|
+
[--asset-type video|shorts]
|
|
225
|
+
[--tags tag1,tag2]
|
|
226
|
+
[--payload '<JSON>']
|
|
227
|
+
[--token <token> | --denmark-token <jwt>]
|
|
228
|
+
[--env dev|prod] [--config <path>]
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### Using `--payload` JSON
|
|
232
|
+
|
|
233
|
+
Pass all metadata as a single JSON string instead of individual flags. CLI flags take precedence when both are given.
|
|
234
|
+
|
|
235
|
+
| Field | Type | Default | Notes |
|
|
236
|
+
|-----------------|--------------|---------------|------------------------------------|
|
|
237
|
+
| `title` | string | required | |
|
|
238
|
+
| `desc` | string | required | |
|
|
239
|
+
| `asset_type` | string | `"video"` | e.g. `"video"`, `"shorts"` |
|
|
240
|
+
| `tags` | list[string] | `null` | e.g. `["news", "sports"]` |
|
|
241
|
+
| `preset_config` | object | `null` | `{"meta": "...", "social": "..."}` |
|
|
242
|
+
| `downloads` | object | `null` | `{"url": "https://..."}` |
|
|
243
|
+
| `islive` | int | `0` | `0` or `1` |
|
|
244
|
+
| `type` | int | `0` | Media type integer |
|
|
245
|
+
| `source` | string | `"uploadsdk"` | Upload source identifier |
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Environments
|
|
250
|
+
|
|
251
|
+
| Environment | RPC endpoint | Upload endpoint | Auth endpoint |
|
|
252
|
+
|-------------|------------------------------|-----------------------------------|-------------------------------------|
|
|
253
|
+
| `prod` | `https://b2b.sli.ke/rpc` | `https://asset.sli.ke/upload` | `https://accounts.sli.ke/login` |
|
|
254
|
+
| `dev` | `https://app-dev.sli.ke/rpc` | `https://asset-dev.sli.ke/upload` | `https://accounts-dev.sli.ke/login` |
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## How it works
|
|
259
|
+
|
|
260
|
+
**Auth (`initialize()`)**:
|
|
261
|
+
- With `token`: calls `user.me` RPC to verify the token is valid.
|
|
262
|
+
- With `denmark_token`: POSTs `{type: 4, jwt: <jwt>, service}` to `/login` and reads `data.token` from the response.
|
|
263
|
+
|
|
264
|
+
**Chunked file upload (`register_media(file_path=...)`)**:
|
|
265
|
+
1. `media.register` RPC → returns `media_id` + short-lived upload JWT
|
|
266
|
+
2. File is split into **4 MiB chunks**, each POSTed as `multipart/form-data` with the JWT in the `token` header
|
|
267
|
+
3. The asset server assembles and processes the file. Failed chunks retry up to **3 times** with exponential backoff.
|
|
268
|
+
|
|
269
|
+
**Editor video (`register_media(editor_settings=...)`)**:
|
|
270
|
+
- `media.register` RPC with `type: "videoeditor"` and the editor spec. No bytes are uploaded — the asset server renders from the spec.
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Development
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
git clone <repo>
|
|
278
|
+
cd slike-media-package
|
|
279
|
+
python3 -m pip install -e .
|
|
280
|
+
|
|
281
|
+
# Run tests
|
|
282
|
+
python3 -m unittest test_slike -v
|
|
283
|
+
|
|
284
|
+
# Build wheel
|
|
285
|
+
pip install hatch && hatch build
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## License
|
|
291
|
+
|
|
292
|
+
MIT
|