qivaryn-engine 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.
@@ -0,0 +1,95 @@
1
+ QIVARYN ATTRIBUTION LICENSE
2
+ Version 1.0, 2026-10-17
3
+
4
+ Copyright (c) 2026 Usama Nadeem (@usamanadim)
5
+
6
+ IMPORTANT: This is a project-specific source-available license, not a standard
7
+ open-source license. It permits commercial use, but requires attribution as
8
+ described below. By exercising any of the rights granted by this license, you
9
+ agree to its terms.
10
+
11
+ 1. DEFINITIONS
12
+
13
+ "Work" means the Qivaryn software, including its source code and documentation,
14
+ made available by the copyright holder under this license.
15
+
16
+ "You" means the person or legal entity exercising rights under this license.
17
+
18
+ "Derivative Work" means a work based on or incorporating all or a substantial
19
+ portion of the Work, including modifications, adaptations, and applications
20
+ that bundle or incorporate the Work.
21
+
22
+ 2. GRANT OF RIGHTS
23
+
24
+ Subject to the conditions in this license, the copyright holder grants You a
25
+ worldwide, non-exclusive, royalty-free, perpetual, and irrevocable license to
26
+ use, reproduce, modify, create Derivative Works from, publicly display,
27
+ distribute, sublicense, and commercially exploit the Work and Derivative Works.
28
+
29
+ Commercial use is expressly permitted. No separate fee or permission is
30
+ required if You comply with this license.
31
+
32
+ 3. ATTRIBUTION CONDITION
33
+
34
+ Whenever You exercise the rights in section 2 to use, reproduce, modify, or
35
+ create a Derivative Work, You must preserve this license and the attribution
36
+ record with the Work and any modified source copy. If You incorporate or use
37
+ the Work in an application, or distribute the Work or a Derivative Work, You
38
+ must also give clear and reasonably prominent credit to both Qivaryn and its
39
+ original author, Usama Nadeem (@usamanadim), and include a link to the
40
+ original project repository:
41
+
42
+ Qivaryn by Usama Nadeem (@usamanadim)
43
+ https://github.com/usamanadim/qivaryn-engine
44
+
45
+ For an application, place this credit in an About, credits, acknowledgments,
46
+ or third-party notices screen or document. If the application has no such
47
+ screen or documentation, include it in a third-party notices file distributed
48
+ with the application. For source or binary redistribution, retain this license
49
+ and the attribution record, and preserve existing copyright and license
50
+ notices. You may add your own notices, but may not imply that the original
51
+ author endorses Your work.
52
+
53
+ These conditions also apply to modifications and Derivative Works. They do
54
+ not require You to publish your source code or license Your own independent
55
+ contributions under this license.
56
+
57
+ 4. AI-ASSISTED DEVELOPMENT
58
+
59
+ If an AI coding agent uses or incorporates the Work to develop another
60
+ application or Derivative Work, the person or organization distributing or
61
+ using that application remains responsible for complying with this license.
62
+ The agent must preserve and communicate the attribution requirement and should
63
+ add the credit above to the application's appropriate documentation, license
64
+ notices, About/credits screen, or third-party acknowledgments. AI-generated
65
+ changes do not remove these obligations.
66
+
67
+ 5. NO TRADEMARK OR ENDORSEMENT RIGHTS
68
+
69
+ This license does not grant rights to use the Qivaryn name, logos, or other
70
+ trademarks except as reasonably needed to provide the required attribution.
71
+ Attribution does not imply endorsement.
72
+
73
+ 6. DISCLAIMER AND LIMITATION OF LIABILITY
74
+
75
+ THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
76
+ IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS
77
+ FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. TO THE MAXIMUM EXTENT
78
+ PERMITTED BY APPLICABLE LAW, THE COPYRIGHT HOLDER SHALL NOT BE LIABLE FOR ANY
79
+ CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT,
80
+ OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE WORK OR THE USE
81
+ OR OTHER DEALINGS IN THE WORK.
82
+
83
+ 7. TERMINATION
84
+
85
+ If You fail to comply with the attribution condition, the rights granted to
86
+ You terminate. They will be reinstated if You cure the violation within 30
87
+ days after becoming aware of it, and will not otherwise be permanently
88
+ terminated for that cured violation. All other termination rights available
89
+ under applicable law remain unaffected.
90
+
91
+ 8. GOVERNING LAW
92
+
93
+ This license is governed by the laws applicable to the copyright holder,
94
+ without regard to conflict-of-law rules. If any provision is unenforceable,
95
+ the remaining provisions continue in effect.
@@ -0,0 +1,381 @@
1
+ Metadata-Version: 2.4
2
+ Name: qivaryn-engine
3
+ Version: 0.1.0
4
+ Summary: A media download engine designed for multiple platforms, currently supporting Instagram.
5
+ Author: Usama Nadeem (@usamanadim)
6
+ License: QIVARYN ATTRIBUTION LICENSE
7
+ Version 1.0, 2026-10-17
8
+
9
+ Copyright (c) 2026 Usama Nadeem (@usamanadim)
10
+
11
+ IMPORTANT: This is a project-specific source-available license, not a standard
12
+ open-source license. It permits commercial use, but requires attribution as
13
+ described below. By exercising any of the rights granted by this license, you
14
+ agree to its terms.
15
+
16
+ 1. DEFINITIONS
17
+
18
+ "Work" means the Qivaryn software, including its source code and documentation,
19
+ made available by the copyright holder under this license.
20
+
21
+ "You" means the person or legal entity exercising rights under this license.
22
+
23
+ "Derivative Work" means a work based on or incorporating all or a substantial
24
+ portion of the Work, including modifications, adaptations, and applications
25
+ that bundle or incorporate the Work.
26
+
27
+ 2. GRANT OF RIGHTS
28
+
29
+ Subject to the conditions in this license, the copyright holder grants You a
30
+ worldwide, non-exclusive, royalty-free, perpetual, and irrevocable license to
31
+ use, reproduce, modify, create Derivative Works from, publicly display,
32
+ distribute, sublicense, and commercially exploit the Work and Derivative Works.
33
+
34
+ Commercial use is expressly permitted. No separate fee or permission is
35
+ required if You comply with this license.
36
+
37
+ 3. ATTRIBUTION CONDITION
38
+
39
+ Whenever You exercise the rights in section 2 to use, reproduce, modify, or
40
+ create a Derivative Work, You must preserve this license and the attribution
41
+ record with the Work and any modified source copy. If You incorporate or use
42
+ the Work in an application, or distribute the Work or a Derivative Work, You
43
+ must also give clear and reasonably prominent credit to both Qivaryn and its
44
+ original author, Usama Nadeem (@usamanadim), and include a link to the
45
+ original project repository:
46
+
47
+ Qivaryn by Usama Nadeem (@usamanadim)
48
+ https://github.com/usamanadim/qivaryn-engine
49
+
50
+ For an application, place this credit in an About, credits, acknowledgments,
51
+ or third-party notices screen or document. If the application has no such
52
+ screen or documentation, include it in a third-party notices file distributed
53
+ with the application. For source or binary redistribution, retain this license
54
+ and the attribution record, and preserve existing copyright and license
55
+ notices. You may add your own notices, but may not imply that the original
56
+ author endorses Your work.
57
+
58
+ These conditions also apply to modifications and Derivative Works. They do
59
+ not require You to publish your source code or license Your own independent
60
+ contributions under this license.
61
+
62
+ 4. AI-ASSISTED DEVELOPMENT
63
+
64
+ If an AI coding agent uses or incorporates the Work to develop another
65
+ application or Derivative Work, the person or organization distributing or
66
+ using that application remains responsible for complying with this license.
67
+ The agent must preserve and communicate the attribution requirement and should
68
+ add the credit above to the application's appropriate documentation, license
69
+ notices, About/credits screen, or third-party acknowledgments. AI-generated
70
+ changes do not remove these obligations.
71
+
72
+ 5. NO TRADEMARK OR ENDORSEMENT RIGHTS
73
+
74
+ This license does not grant rights to use the Qivaryn name, logos, or other
75
+ trademarks except as reasonably needed to provide the required attribution.
76
+ Attribution does not imply endorsement.
77
+
78
+ 6. DISCLAIMER AND LIMITATION OF LIABILITY
79
+
80
+ THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
81
+ IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS
82
+ FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. TO THE MAXIMUM EXTENT
83
+ PERMITTED BY APPLICABLE LAW, THE COPYRIGHT HOLDER SHALL NOT BE LIABLE FOR ANY
84
+ CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT,
85
+ OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE WORK OR THE USE
86
+ OR OTHER DEALINGS IN THE WORK.
87
+
88
+ 7. TERMINATION
89
+
90
+ If You fail to comply with the attribution condition, the rights granted to
91
+ You terminate. They will be reinstated if You cure the violation within 30
92
+ days after becoming aware of it, and will not otherwise be permanently
93
+ terminated for that cured violation. All other termination rights available
94
+ under applicable law remain unaffected.
95
+
96
+ 8. GOVERNING LAW
97
+
98
+ This license is governed by the laws applicable to the copyright holder,
99
+ without regard to conflict-of-law rules. If any provision is unenforceable,
100
+ the remaining provisions continue in effect.
101
+
102
+ Project-URL: Homepage, https://github.com/usamanadim/qivaryn-engine
103
+ Project-URL: Repository, https://github.com/usamanadim/qivaryn-engine
104
+ Project-URL: Issues, https://github.com/usamanadim/qivaryn-engine/issues
105
+ Requires-Python: >=3.8
106
+ Description-Content-Type: text/markdown
107
+ License-File: LICENSE
108
+ Requires-Dist: requests>=2.28.0
109
+ Requires-Dist: click>=8.0.0
110
+ Requires-Dist: tqdm>=4.64.0
111
+ Dynamic: license-file
112
+
113
+ # Qivaryn
114
+
115
+ Qivaryn is a high-performance, multi-platform media downloader with a shared command-line interface and Python API. Its platform integrations handle the details that differ between services, while common download options and history management work the same way wherever supported. Instagram is the first supported platform; support for additional platforms is planned.
116
+
117
+ ---
118
+
119
+ ## Features
120
+
121
+ - **Multi-platform design**: A shared downloader interface is built to support multiple media platforms through platform-specific integrations.
122
+ - **Automatic URL Detection**: Pass a URL from a supported platform and Qivaryn routes it to the appropriate downloader.
123
+ - **High-quality downloads**: The current Instagram integration selects available progressive or DASH video streams (up to 1080p) and downloads carousel slides in original resolution.
124
+ - **Media Filtering**: Filter account downloads by media type where the platform supports it. Available types can vary by platform.
125
+ - **DASH Audio & Video Merging**: On platforms that provide split DASH streams, Qivaryn uses FFmpeg to merge audio and video.
126
+ - **Batch Limits (`--count`)**: Specify the exact number of **new** items to save. Previously downloaded content is automatically skipped without counting toward the quota.
127
+ - **Download Resumption**: Tracks downloaded item identifiers in a local SQLite database (`qivaryn_state.db`), allowing previously saved items to be skipped. The current Instagram integration tracks post shortcodes.
128
+ - **Dual Interface**: Offers both a command-line interface (CLI) and a Python library API.
129
+
130
+ ### Supported platforms
131
+
132
+ - **Instagram** — currently supported.
133
+ - **Additional platforms** — planned; not supported yet.
134
+
135
+ Commands and common options are intended to remain consistent across platforms. URL formats, authentication methods, media filters, and other service-specific options may differ.
136
+
137
+ ---
138
+
139
+ ## Requirements
140
+
141
+ - **Python 3.8** or newer
142
+ - **FFmpeg** available on your system `PATH` when downloading from a platform that requires it to merge DASH audio and video.
143
+ - Authentication is platform-specific. For Instagram, an optional session (`--cookies cookies.txt` or `--sessionid`) may be needed for private content, deeper pagination, or higher rate limits.
144
+
145
+ ---
146
+
147
+ ## Installation
148
+
149
+ ### Install from local checkout (Recommended for development)
150
+
151
+ ```console
152
+ git clone https://github.com/usamanadim/qivaryn-engine.git
153
+ cd qivaryn-engine
154
+ python -m pip install -e .
155
+ ```
156
+
157
+ ### Install latest development version from GitHub
158
+
159
+ ```bash
160
+ python -m pip install --upgrade "git+https://github.com/usamanadim/qivaryn-engine.git@main"
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Quick Start (Cheatsheet)
166
+
167
+ Download content from a supported platform with one command. This example uses Instagram, the platform currently supported:
168
+
169
+ ```bash
170
+ qivaryn "https://www.instagram.com/USERNAME/"
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Command-Line Usage
176
+
177
+ ### 1. Automatic URL Command
178
+
179
+ Pass a URL from a supported platform directly to the CLI. Qivaryn detects the platform and content type from the URL:
180
+
181
+ ```console
182
+ qivaryn "<SUPPORTED_URL>" [OPTIONS]
183
+ ```
184
+
185
+ For the currently supported Instagram URLs, Qivaryn routes automatically:
186
+
187
+ - **Single Post / Reel URL** (`/p/SHORTCODE/` or `/reel/SHORTCODE/`):
188
+ Downloads that specific item. If it is a carousel, all slides (images and videos) are downloaded.
189
+ - **Reels Tab URL** (`/<username>/reels/`):
190
+ Scans the dedicated Reels tab and downloads Reels chronologically.
191
+ - **Account Profile URL** (`/<username>/`):
192
+ - When `--type` is omitted or `all`: downloads grid posts (photos and carousels) and continues into the dedicated Reels tab.
193
+ - When `--type posts`: downloads photos and carousels from the profile grid.
194
+ - When `--type carousels`: downloads only multi-slide carousel albums.
195
+ - When `--type reels`: downloads videos from the Reels tab.
196
+
197
+ #### Available Options
198
+
199
+ | Option | Shorthand | Description | Default |
200
+ | --- | --- | --- | --- |
201
+ | `--type TYPE` | | Filter media where supported. Instagram types include `all`, `posts`, `reels`, `videos`, or `carousels`. | `all` |
202
+ | `--count N` | `-n N`, `--limit N` | Maximum number of **new** items to save before stopping. | Unlimited |
203
+ | `--cookies PATH` | `--cookies-file` | Instagram: path to a Netscape-format `cookies.txt` file. Authentication options may vary by platform. | None |
204
+ | `--sessionid STR` | | Instagram-specific `sessionid` cookie value. | None |
205
+ | `--output DIR` | `-o DIR` | Directory to save downloaded media files. | `./downloads` |
206
+ | `--db PATH` | | Path to SQLite state database for download tracking. | `qivaryn_state.db` |
207
+ | `--max-pages N` | | Maximum feed pagination pages to scan. | Unlimited |
208
+ | `--force` | `-f` | Re-download and overwrite even if already saved. | `False` |
209
+
210
+ The explicit `single`, `download`, and `clear-db` subcommands also accept `--platform`. At present, the available platform choice is `instagram`.
211
+
212
+ ---
213
+
214
+ ### 2. Explicit Subcommands
215
+
216
+ If you prefer explicit subcommands instead of automatic URL detection:
217
+
218
+ #### `qivaryn single`
219
+
220
+ Downloads a single item by URL or identifier. The accepted identifier depends on the selected platform. For Instagram:
221
+
222
+ ```console
223
+ qivaryn single "https://www.instagram.com/p/SHORTCODE/"
224
+ qivaryn single "https://www.instagram.com/p/SHORTCODE/" --output ./my_media
225
+ qivaryn single SHORTCODE --cookies ./cookies.txt
226
+ ```
227
+
228
+ #### `qivaryn download`
229
+
230
+ Downloads account content using a platform-specific account name or identifier. For Instagram:
231
+
232
+ ```console
233
+ # Download up to 25 new Reels from an account
234
+ qivaryn download natgeo --type reels --count 25
235
+
236
+ # Download up to 10 image / carousel posts
237
+ qivaryn download natgeo --type posts --count 10
238
+
239
+ # Download only multi-item carousel albums
240
+ qivaryn download natgeo --type carousels --count 5
241
+
242
+ # Download with an explicit early-exit threshold (halt after 5 consecutive known items)
243
+ qivaryn download natgeo --threshold 5
244
+ ```
245
+
246
+ ---
247
+
248
+ ## Media Filtering Guide (`--type`)
249
+
250
+ Media type names are platform-specific. The following values describe the current Instagram integration; available content and filters may differ for other platform integrations in the future.
251
+
252
+ | Value | What It Downloads | Excludes |
253
+ | --- | --- | --- |
254
+ | `all` *(default)* | All posts, photos, carousels, and Reels. | None |
255
+ | `posts` | Profile grid image posts and multi-item carousels. | Standalone video Reels |
256
+ | `carousels` | Multi-slide carousel albums only (multi-image / multi-video). | Single-photo posts and Reels |
257
+ | `reels` (or `videos`) | Video Reels from the dedicated Reels tab or feed. | Static image posts |
258
+
259
+ ---
260
+
261
+ ## Instagram Authentication (`cookies.txt` and `--sessionid`)
262
+
263
+ Authentication requirements depend on the platform. For Instagram, public accounts and Reels can often be downloaded without logging in. An authenticated session may be needed for:
264
+
265
+ - Private accounts you follow.
266
+ - Deep pagination of account post grids.
267
+ - Avoiding Instagram rate limits (HTTP 429).
268
+
269
+ ### How to Export `cookies.txt` from Your Browser
270
+
271
+ 1. In Google Chrome, Microsoft Edge, or Firefox, install a cookie export extension:
272
+ - **Get cookies.txt LOCALLY** (recommended, open source)
273
+ - **Cookie-Editor** (select *Export* → *Netscape*)
274
+ 2. Navigate to [instagram.com](https://www.instagram.com) and ensure you are logged into your account.
275
+ 3. Click the extension icon and export the cookies in **Netscape format**.
276
+ 4. Save the file as `cookies.txt` in your project folder (or pass its absolute path):
277
+ ```console
278
+ qivaryn "https://www.instagram.com/USERNAME/" --cookies cookies.txt
279
+ ```
280
+
281
+ ### Using `--sessionid` Directly
282
+
283
+ Alternatively, copy your `sessionid` cookie value directly from your browser:
284
+
285
+ 1. Open [instagram.com](https://www.instagram.com) in your browser.
286
+ 2. Press `F12` to open Developer Tools.
287
+ 3. Go to **Application** (or **Storage** in Firefox) → **Cookies** → `https://www.instagram.com`.
288
+ 4. Copy the value of the `sessionid` cookie and pass it:
289
+ ```console
290
+ qivaryn "https://www.instagram.com/USERNAME/" --sessionid "YOUR_SESSION_ID"
291
+ ```
292
+
293
+ > [!IMPORTANT]
294
+ > Treat `cookies.txt` and session IDs like passwords. Do not commit them to Git. Qivaryn's `.gitignore` automatically ignores `cookies.txt`.
295
+
296
+ ---
297
+
298
+ ## Managing Download History (`clear-db`)
299
+
300
+ Qivaryn records downloaded item identifiers in `qivaryn_state.db` so you can skip previously saved files. For Instagram, these identifiers are post shortcodes. The `clear-db` command manages download history without deleting media files from disk:
301
+
302
+ ```console
303
+ # Remove a single post from the database so it can be re-downloaded
304
+ qivaryn clear-db SHORTCODE
305
+ qivaryn clear-db --item "https://www.instagram.com/p/SHORTCODE/"
306
+
307
+ # Prune database records for media files that were deleted from disk
308
+ qivaryn clear-db --missing
309
+
310
+ # Clear the entire download history (prompts for confirmation)
311
+ qivaryn clear-db
312
+
313
+ # Clear the entire history without a confirmation prompt
314
+ qivaryn clear-db --yes
315
+ ```
316
+
317
+ ---
318
+
319
+ ## Python Library API
320
+
321
+ You can embed Qivaryn into your own Python applications, automation scripts, and background workers. The example below uses the current Instagram integration; available methods and options may vary by platform:
322
+
323
+ ```python
324
+ from qivaryn import QivarynEngine
325
+
326
+ # Initialize the engine
327
+ engine = QivarynEngine(
328
+ output_dir="./downloads",
329
+ db_path="./qivaryn_state.db",
330
+ cookies_file="./cookies.txt", # Optional: omit for public content
331
+ # sessionid="YOUR_SESSION_ID", # Alternative to cookies_file
332
+ consecutive_threshold=3, # Stop after N consecutive known items
333
+ )
334
+
335
+ # 1. Download automatically based on URL with count limit and media type filter
336
+ engine.download_url(
337
+ "https://www.instagram.com/natgeo/",
338
+ count=20,
339
+ media_type="posts", # 'all', 'posts', 'reels', 'videos', or 'carousels'
340
+ )
341
+
342
+ # 2. Download from an account by username
343
+ engine.download_account(
344
+ username="natgeo",
345
+ count=10,
346
+ media_type_filter="carousels",
347
+ )
348
+
349
+ # 3. Download a single post or Reel
350
+ engine.download_single(
351
+ "https://www.instagram.com/reel/C7xYabcdefG/",
352
+ force=False,
353
+ )
354
+ ```
355
+
356
+ See [`qivaryn/examples/library_usage.py`](qivaryn/examples/library_usage.py) for a complete runnable script.
357
+
358
+ ---
359
+
360
+ ## Development & Testing
361
+
362
+ Activate your virtual environment and install test dependencies:
363
+
364
+ ```console
365
+ # Run all unit tests
366
+ python -m unittest discover -s tests -v
367
+
368
+ # Build wheels and source distribution
369
+ python -m pip install build
370
+ python -m build
371
+ ```
372
+
373
+ ---
374
+
375
+ ## License and Required Attribution
376
+
377
+ Qivaryn is licensed under the **Qivaryn Attribution License 1.0** in [`LICENSE`](LICENSE). Commercial use is permitted. Anyone using, modifying, incorporating, or distributing Qivaryn must credit the original author:
378
+
379
+ > **Qivaryn by Usama Nadeem (@usamanadim)** — https://github.com/usamanadim/qivaryn-engine
380
+
381
+ Machine-readable attribution metadata is available in [`qivaryn/ATTRIBUTION.json`](qivaryn/ATTRIBUTION.json).