pinchana-threads 26.11.15__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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pinchana
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.
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.4
2
+ Name: pinchana-threads
3
+ Version: 26.11.15
4
+ Summary: Threads (Meta) scraper plugin for Pinchana
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Dist: pinchana-core
8
+ Requires-Dist: cloakbrowser==0.6.5
9
+ Requires-Dist: curl-cffi>=0.17.0
10
+ Requires-Dist: fastapi>=0.162.2
11
+ Requires-Dist: httpx>=0.28.1
12
+ Requires-Dist: pydantic>=2.14.3
13
+ Requires-Dist: python-dotenv>=1.2.4
14
+ Requires-Dist: tenacity>=9.2.1
15
+ Requires-Dist: uvicorn>=0.54.0
16
+ Requires-Python: >=3.13
17
+ Project-URL: Repository, https://github.com/Pinchana/pinchana-api
18
+ Project-URL: Issues, https://github.com/Pinchana/pinchana-api/issues
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Pinchana Threads
22
+
23
+ This FastAPI module extracts public Threads posts from both `threads.net` and `threads.com`. It uses an HTTP-first strategy and a pooled browser fallback when the server-rendered response is gated or incomplete.
24
+
25
+ The fallback uses CloakBrowser 0.6.5 and the free, keyless Chromium 146 build.
26
+ Leave `CLOAKBROWSER_LICENSE_KEY` unset. On first use, the wrapper downloads and
27
+ verifies the binary directly from CloakBrowser's distribution channels.
28
+
29
+ ## Processing flow
30
+
31
+ 1. Normalize the post URL and resolve its shortcode.
32
+ 2. Fetch the canonical page through a shared `curl-cffi` session.
33
+ 3. Parse the server-rendered `data-sjs` payload for the requested post.
34
+ 4. Use an isolated page in the shared browser process only when the HTTP response is gated or incomplete.
35
+ 5. Download images, videos, covers, and supported music-preview assets into the shared cache.
36
+
37
+ The result can contain one image, one video, an ordered carousel, text-only metadata, or a Threads music preview. The gateway v1 contract represents music previews as a 30-second `soundtrack` asset with title and artist metadata plus a separate `cover` asset. Engagement fields are optional and must not be treated as guaranteed.
38
+
39
+ ## API
40
+
41
+ - `POST /scrape` accepts `{"url":"https://www.threads.com/@account/post/SHORTCODE"}` and equivalent `threads.net` URLs.
42
+ - `GET /health` reports service, VPN, HTTP-session, and browser readiness.
43
+
44
+ External clients, including Pinchana Bot, must use the gateway's authenticated `POST /v1/scrape` route. They must not call this module directly or depend on its legacy flat response.
45
+
46
+ ## Configuration
47
+
48
+ | Variable | Default | Purpose |
49
+ | --- | --- | --- |
50
+ | `CACHE_PATH` | `./cache` | Base media cache path |
51
+ | `CACHE_MAX_SIZE_GB` | `10.0` | Maximum cache size before eviction |
52
+ | `GLUETUN_CONTROL_URL` | `http://localhost:8000` | Private Gluetun control endpoint |
53
+ | `THREADS_HTTP_CONCURRENCY` | `20` | Maximum concurrent HTTP operations |
54
+ | `THREADS_BROWSER_CONCURRENCY` | `2` | Maximum simultaneous fallback pages |
55
+
56
+ ## Development and diagnostics
57
+
58
+ ```sh
59
+ uv sync --frozen
60
+ uv run uvicorn pinchana_threads.main:app --host 0.0.0.0 --port 8088 --reload
61
+ ```
62
+
63
+ When the gateway rejects a valid Threads URL, correlate its `request_id` across `scrape_request`, `scrape_route_selected`, `scrape_forward`, and `scrape_rejected`. Confirm that both the gateway route patterns and this module accept the submitted hostname before changing the client.
64
+
65
+ ```sh
66
+ # Run from the repository root.
67
+ docker build --file scrapers/pinchana-threads/Dockerfile --tag pinchana-threads:local .
68
+ ```
@@ -0,0 +1,48 @@
1
+ # Pinchana Threads
2
+
3
+ This FastAPI module extracts public Threads posts from both `threads.net` and `threads.com`. It uses an HTTP-first strategy and a pooled browser fallback when the server-rendered response is gated or incomplete.
4
+
5
+ The fallback uses CloakBrowser 0.6.5 and the free, keyless Chromium 146 build.
6
+ Leave `CLOAKBROWSER_LICENSE_KEY` unset. On first use, the wrapper downloads and
7
+ verifies the binary directly from CloakBrowser's distribution channels.
8
+
9
+ ## Processing flow
10
+
11
+ 1. Normalize the post URL and resolve its shortcode.
12
+ 2. Fetch the canonical page through a shared `curl-cffi` session.
13
+ 3. Parse the server-rendered `data-sjs` payload for the requested post.
14
+ 4. Use an isolated page in the shared browser process only when the HTTP response is gated or incomplete.
15
+ 5. Download images, videos, covers, and supported music-preview assets into the shared cache.
16
+
17
+ The result can contain one image, one video, an ordered carousel, text-only metadata, or a Threads music preview. The gateway v1 contract represents music previews as a 30-second `soundtrack` asset with title and artist metadata plus a separate `cover` asset. Engagement fields are optional and must not be treated as guaranteed.
18
+
19
+ ## API
20
+
21
+ - `POST /scrape` accepts `{"url":"https://www.threads.com/@account/post/SHORTCODE"}` and equivalent `threads.net` URLs.
22
+ - `GET /health` reports service, VPN, HTTP-session, and browser readiness.
23
+
24
+ External clients, including Pinchana Bot, must use the gateway's authenticated `POST /v1/scrape` route. They must not call this module directly or depend on its legacy flat response.
25
+
26
+ ## Configuration
27
+
28
+ | Variable | Default | Purpose |
29
+ | --- | --- | --- |
30
+ | `CACHE_PATH` | `./cache` | Base media cache path |
31
+ | `CACHE_MAX_SIZE_GB` | `10.0` | Maximum cache size before eviction |
32
+ | `GLUETUN_CONTROL_URL` | `http://localhost:8000` | Private Gluetun control endpoint |
33
+ | `THREADS_HTTP_CONCURRENCY` | `20` | Maximum concurrent HTTP operations |
34
+ | `THREADS_BROWSER_CONCURRENCY` | `2` | Maximum simultaneous fallback pages |
35
+
36
+ ## Development and diagnostics
37
+
38
+ ```sh
39
+ uv sync --frozen
40
+ uv run uvicorn pinchana_threads.main:app --host 0.0.0.0 --port 8088 --reload
41
+ ```
42
+
43
+ When the gateway rejects a valid Threads URL, correlate its `request_id` across `scrape_request`, `scrape_route_selected`, `scrape_forward`, and `scrape_rejected`. Confirm that both the gateway route patterns and this module accept the submitted hostname before changing the client.
44
+
45
+ ```sh
46
+ # Run from the repository root.
47
+ docker build --file scrapers/pinchana-threads/Dockerfile --tag pinchana-threads:local .
48
+ ```
@@ -0,0 +1,33 @@
1
+ [project]
2
+ name = "pinchana-threads"
3
+ version = "26.11.15"
4
+ description = "Threads (Meta) scraper plugin for Pinchana"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ dependencies = [
10
+ "pinchana-core",
11
+ "cloakbrowser==0.6.5",
12
+ "curl-cffi>=0.17.0",
13
+ "fastapi>=0.162.2",
14
+ "httpx>=0.28.1",
15
+ "pydantic>=2.14.3",
16
+ "python-dotenv>=1.2.4",
17
+ "tenacity>=9.2.1",
18
+ "uvicorn>=0.54.0",
19
+ ]
20
+
21
+ [project.urls]
22
+ Repository = "https://github.com/Pinchana/pinchana-api"
23
+ Issues = "https://github.com/Pinchana/pinchana-api/issues"
24
+
25
+ [dependency-groups]
26
+ dev = [
27
+ "pytest>=9.2.0",
28
+ "pytest-asyncio>=1.4.1.post1",
29
+ ]
30
+
31
+ [build-system]
32
+ requires = ["uv_build>=0.13.7,<0.14.0"]
33
+ build-backend = "uv_build"
@@ -0,0 +1,34 @@
1
+ [project]
2
+ name = "pinchana-threads"
3
+ version = "26.11.15"
4
+ description = "Threads (Meta) scraper plugin for Pinchana"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ dependencies = [
10
+ "pinchana-core",
11
+ # 0.6.5 is the last wrapper with upstream support for keyless Chromium.
12
+ "cloakbrowser==0.6.5",
13
+ "curl-cffi>=0.17.0",
14
+ "fastapi>=0.162.2",
15
+ "httpx>=0.28.1",
16
+ "pydantic>=2.14.3",
17
+ "python-dotenv>=1.2.4",
18
+ "tenacity>=9.2.1",
19
+ "uvicorn>=0.54.0",
20
+ ]
21
+
22
+ [dependency-groups]
23
+ dev = [
24
+ "pytest>=9.2.0",
25
+ "pytest-asyncio>=1.4.1.post1",
26
+ ]
27
+
28
+ [build-system]
29
+ requires = ["uv_build>=0.13.7,<0.14.0"]
30
+ build-backend = "uv_build"
31
+
32
+ [project.urls]
33
+ Repository = "https://github.com/Pinchana/pinchana-api"
34
+ Issues = "https://github.com/Pinchana/pinchana-api/issues"
@@ -0,0 +1,8 @@
1
+ """Threads (Meta) scraper plugin for Pinchana."""
2
+
3
+ from .main import plugin, router
4
+
5
+ scrape = plugin.scrape
6
+ inspect = plugin.inspect
7
+
8
+ __all__ = ["scrape", "inspect", "router"]