@auscera/socialscrape 0.0.0-stage → 2.0.2

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.
Files changed (63) hide show
  1. package/README.md +111 -2
  2. package/bin/socialscrape.mjs +115 -0
  3. package/engine/README.md +245 -0
  4. package/engine/SKILL.md +194 -0
  5. package/engine/agent.py +665 -0
  6. package/engine/batch_manager.py +622 -0
  7. package/engine/cli.py +23 -0
  8. package/engine/handlers.py +1109 -0
  9. package/engine/plugins/__init__.py +77 -0
  10. package/engine/plugins/instagram-scrape/README.md +164 -0
  11. package/engine/plugins/instagram-scrape/SKILL.md +53 -0
  12. package/engine/plugins/instagram-scrape/cli.py +176 -0
  13. package/engine/plugins/instagram-scrape/core.py +408 -0
  14. package/engine/plugins/instagram-scrape/plugin.json +42 -0
  15. package/engine/plugins/linkedin-scrape/README.md +143 -0
  16. package/engine/plugins/linkedin-scrape/SKILL.md +47 -0
  17. package/engine/plugins/linkedin-scrape/cli.py +126 -0
  18. package/engine/plugins/linkedin-scrape/core.py +188 -0
  19. package/engine/plugins/linkedin-scrape/plugin.json +36 -0
  20. package/engine/plugins/meta-ad-library-scraper/README.md +127 -0
  21. package/engine/plugins/meta-ad-library-scraper/SKILL.md +44 -0
  22. package/engine/plugins/meta-ad-library-scraper/cli.py +161 -0
  23. package/engine/plugins/meta-ad-library-scraper/core.py +348 -0
  24. package/engine/plugins/meta-ad-library-scraper/plugin.json +44 -0
  25. package/engine/plugins/pinterest-scraper/README.md +150 -0
  26. package/engine/plugins/pinterest-scraper/SKILL.md +45 -0
  27. package/engine/plugins/pinterest-scraper/cli.py +193 -0
  28. package/engine/plugins/pinterest-scraper/core.py +420 -0
  29. package/engine/plugins/pinterest-scraper/plugin.json +40 -0
  30. package/engine/plugins/reddit-discussion-scraper/README.md +162 -0
  31. package/engine/plugins/reddit-discussion-scraper/SKILL.md +52 -0
  32. package/engine/plugins/reddit-discussion-scraper/cli.py +218 -0
  33. package/engine/plugins/reddit-discussion-scraper/core.py +546 -0
  34. package/engine/plugins/reddit-discussion-scraper/plugin.json +46 -0
  35. package/engine/plugins/shared/__init__.py +15 -0
  36. package/engine/plugins/shared/paths.py +90 -0
  37. package/engine/plugins/shared/process_runner.py +169 -0
  38. package/engine/plugins/shared/session_manager.py +287 -0
  39. package/engine/plugins/threads-scraper/README.md +139 -0
  40. package/engine/plugins/threads-scraper/SKILL.md +43 -0
  41. package/engine/plugins/threads-scraper/cli.py +178 -0
  42. package/engine/plugins/threads-scraper/core.py +460 -0
  43. package/engine/plugins/threads-scraper/plugin.json +40 -0
  44. package/engine/plugins/tiktok-scrape/README.md +158 -0
  45. package/engine/plugins/tiktok-scrape/SKILL.md +51 -0
  46. package/engine/plugins/tiktok-scrape/cli.py +163 -0
  47. package/engine/plugins/tiktok-scrape/core.py +313 -0
  48. package/engine/plugins/tiktok-scrape/plugin.json +40 -0
  49. package/engine/plugins/twitter-scrape/README.md +158 -0
  50. package/engine/plugins/twitter-scrape/SKILL.md +50 -0
  51. package/engine/plugins/twitter-scrape/cli.py +153 -0
  52. package/engine/plugins/twitter-scrape/core.py +254 -0
  53. package/engine/plugins/twitter-scrape/plugin.json +40 -0
  54. package/engine/plugins/youtube-scrape/README.md +199 -0
  55. package/engine/plugins/youtube-scrape/SKILL.md +115 -0
  56. package/engine/plugins/youtube-scrape/cli.py +340 -0
  57. package/engine/plugins/youtube-scrape/core.py +829 -0
  58. package/engine/plugins/youtube-scrape/plugin.json +48 -0
  59. package/engine/requirements.txt +8 -0
  60. package/engine/socialscrape_cli.py +500 -0
  61. package/engine/storage.py +570 -0
  62. package/engine/ui.py +690 -0
  63. package/package.json +27 -3
@@ -0,0 +1,313 @@
1
+ """
2
+ TikTok Scraper Pure SDK (`core.py`)
3
+ Pure zero-side-effect Python SDK for TikTok video downloading, transcripts, and metadata.
4
+ """
5
+
6
+ import os
7
+ import sys
8
+ import json
9
+ import re
10
+ from pathlib import Path
11
+ from typing import Dict, List, Any, Optional, Union
12
+
13
+ try:
14
+ import requests
15
+ HAS_REQUESTS = True
16
+ except ImportError:
17
+ HAS_REQUESTS = False
18
+
19
+ try:
20
+ import yt_dlp
21
+ HAS_YT_DLP = True
22
+ except ImportError:
23
+ HAS_YT_DLP = False
24
+
25
+ # Import shared SessionManager & Path Helpers
26
+ try:
27
+ from plugins.shared.session_manager import SessionManager, RateLimiter
28
+ from plugins.shared.paths import get_plugin_outputs_dir
29
+ HAS_SESSION_MANAGER = True
30
+ except ImportError:
31
+ _shared_parent = str(Path(__file__).parent.parent.resolve())
32
+ if _shared_parent not in sys.path:
33
+ sys.path.insert(0, _shared_parent)
34
+ from shared.paths import get_plugin_outputs_dir
35
+ try:
36
+ from shared.session_manager import SessionManager, RateLimiter
37
+ HAS_SESSION_MANAGER = True
38
+ except ImportError:
39
+ HAS_SESSION_MANAGER = False
40
+
41
+ PLUGIN_DIR = Path(__file__).parent.resolve()
42
+ DEFAULT_OUTPUTS_DIR = get_plugin_outputs_dir(PLUGIN_DIR)
43
+
44
+
45
+ def _outputs_dir() -> Path:
46
+ return get_plugin_outputs_dir(PLUGIN_DIR)
47
+
48
+
49
+ def extract_tiktok_id_or_user(url_or_target: str) -> Dict[str, str]:
50
+ """Extracts video ID or username from a TikTok URL."""
51
+ target = url_or_target.strip()
52
+ if "/video/" in target:
53
+ match = re.search(r"/video/(\d+)", target)
54
+ return {"type": "video", "id": match.group(1) if match else target}
55
+ elif target.startswith("@"):
56
+ return {"type": "user", "id": target.lstrip("@")}
57
+ elif "tiktok.com/@" in target:
58
+ match = re.search(r"tiktok\.com/@([^/?#&]+)", target)
59
+ return {"type": "user", "id": match.group(1) if match else target}
60
+ return {"type": "video", "id": target}
61
+
62
+
63
+ def download_tiktok_media(
64
+ url_or_id: str,
65
+ output_dir: Optional[Union[Path, str]] = None,
66
+ download_video: bool = True,
67
+ download_audio: bool = False,
68
+ download_thumbnail: bool = True,
69
+ quality: str = "best",
70
+ ) -> Dict[str, Any]:
71
+ """
72
+ Downloads watermark-free TikTok video, audio track, and cover thumbnail using yt-dlp.
73
+ Saves outputs into standardized Outputs/ hierarchy.
74
+ """
75
+ if not HAS_YT_DLP:
76
+ return {
77
+ "status": "error",
78
+ "error": "yt-dlp is required for TikTok media downloads.",
79
+ "video_path": None,
80
+ "audio_path": None,
81
+ "thumbnail_path": None
82
+ }
83
+
84
+ parsed = extract_tiktok_id_or_user(url_or_id)
85
+ video_id = parsed["id"]
86
+
87
+ url = url_or_id
88
+ if not url.startswith("http"):
89
+ url = f"https://www.tiktok.com/@user/video/{video_id}"
90
+
91
+ base_out = Path(output_dir) if output_dir else (_outputs_dir() / "videos" / video_id)
92
+ base_out.mkdir(parents=True, exist_ok=True)
93
+ thumb_out = _outputs_dir() / "thumbnails" / video_id
94
+ thumb_out.mkdir(parents=True, exist_ok=True)
95
+
96
+ result: Dict[str, Any] = {
97
+ "status": "success",
98
+ "video_id": video_id,
99
+ "video_path": None,
100
+ "audio_path": None,
101
+ "thumbnail_path": None,
102
+ "title": None,
103
+ "error": None
104
+ }
105
+
106
+ try:
107
+ # Download Thumbnail
108
+ if download_thumbnail:
109
+ thumb_opts = {
110
+ "skip_download": True,
111
+ "writethumbnail": True,
112
+ "outtmpl": str(thumb_out / "thumbnail.%(ext)s"),
113
+ "quiet": True,
114
+ "no_warnings": True,
115
+ }
116
+ try:
117
+ with yt_dlp.YoutubeDL(thumb_opts) as ydl:
118
+ ydl.download([url])
119
+ for ext in ["jpg", "webp", "png", "jpeg"]:
120
+ tp = thumb_out / f"thumbnail.{ext}"
121
+ if tp.exists():
122
+ result["thumbnail_path"] = str(tp)
123
+ break
124
+ except Exception:
125
+ pass
126
+
127
+ # Download Audio Track
128
+ if download_audio:
129
+ audio_opts = {
130
+ "format": "bestaudio/best",
131
+ "outtmpl": str(base_out / "audio.%(ext)s"),
132
+ "quiet": True,
133
+ "no_warnings": True,
134
+ }
135
+ try:
136
+ with yt_dlp.YoutubeDL(audio_opts) as ydl:
137
+ ydl.download([url])
138
+ for ext in ["mp3", "m4a", "aac"]:
139
+ ap = base_out / f"audio.{ext}"
140
+ if ap.exists():
141
+ result["audio_path"] = str(ap)
142
+ break
143
+ except Exception:
144
+ pass
145
+
146
+ # Download Watermark-Free Video
147
+ if download_video:
148
+ video_opts = {
149
+ "format": "bestvideo+bestaudio/best",
150
+ "outtmpl": str(base_out / "video.%(ext)s"),
151
+ "quiet": True,
152
+ "no_warnings": True,
153
+ }
154
+ with yt_dlp.YoutubeDL(video_opts) as ydl:
155
+ info = ydl.extract_info(url, download=True)
156
+ result["title"] = info.get("title", "")
157
+ for ext in ["mp4", "webm", "mkv"]:
158
+ vp = base_out / f"video.{ext}"
159
+ if vp.exists():
160
+ result["video_path"] = str(vp)
161
+ break
162
+
163
+ return result
164
+ except Exception as e:
165
+ result["status"] = "error"
166
+ result["error"] = str(e)
167
+ return result
168
+
169
+
170
+ def get_tiktok_video_metadata(url_or_id: str) -> Dict[str, Any]:
171
+ """Extracts video metadata including title, author, views, likes, and music."""
172
+ parsed = extract_tiktok_id_or_user(url_or_id)
173
+ video_id = parsed["id"]
174
+
175
+ url = url_or_id
176
+ if not url.startswith("http"):
177
+ url = f"https://www.tiktok.com/@user/video/{video_id}"
178
+
179
+ if HAS_YT_DLP:
180
+ try:
181
+ with yt_dlp.YoutubeDL({"quiet": True, "no_warnings": True, "skip_download": True}) as ydl:
182
+ info = ydl.extract_info(url, download=False)
183
+ return {
184
+ "status": "success",
185
+ "video_id": video_id,
186
+ "title": info.get("title", ""),
187
+ "description": info.get("description", ""),
188
+ "author": info.get("uploader", "") or info.get("channel", ""),
189
+ "author_id": info.get("uploader_id", ""),
190
+ "view_count": info.get("view_count", 0),
191
+ "like_count": info.get("like_count", 0),
192
+ "comment_count": info.get("comment_count", 0),
193
+ "duration": info.get("duration", 0),
194
+ "music": info.get("track", "") or info.get("music", ""),
195
+ "thumbnail": info.get("thumbnail", ""),
196
+ "upload_date": info.get("upload_date", ""),
197
+ }
198
+ except Exception as e:
199
+ return {"status": "error", "video_id": video_id, "error": str(e)}
200
+
201
+ return {
202
+ "status": "success",
203
+ "video_id": video_id,
204
+ "description": "",
205
+ "author": "",
206
+ "view_count": 0,
207
+ "like_count": 0,
208
+ }
209
+
210
+
211
+ def get_tiktok_transcript(url_or_id: str) -> Dict[str, Any]:
212
+ """
213
+ Extracts captions and spoken transcripts from a TikTok video.
214
+ Saves clean text to Outputs/text_posts/ and returns timestamped segments.
215
+ """
216
+ parsed = extract_tiktok_id_or_user(url_or_id)
217
+ video_id = parsed["id"]
218
+
219
+ url = url_or_id
220
+ if not url.startswith("http"):
221
+ url = f"https://www.tiktok.com/@user/video/{video_id}"
222
+
223
+ if HAS_YT_DLP:
224
+ ydl_opts = {
225
+ "skip_download": True,
226
+ "writesubtitles": True,
227
+ "writeautomaticsub": True,
228
+ "subtitleslangs": ["en", "all"],
229
+ "quiet": True,
230
+ "no_warnings": True,
231
+ }
232
+ try:
233
+ with yt_dlp.YoutubeDL(ydl_opts) as ydl:
234
+ info = ydl.extract_info(url, download=False)
235
+ subs = info.get("subtitles", {}) or info.get("automatic_captions", {})
236
+ full_text = ""
237
+ segments = []
238
+
239
+ if subs:
240
+ # Parse subtitle formats if available
241
+ for lang, sub_formats in subs.items():
242
+ for sf in sub_formats:
243
+ if "url" in sf:
244
+ try:
245
+ r = requests.get(sf["url"], timeout=8)
246
+ if r.status_code == 200:
247
+ full_text = r.text
248
+ break
249
+ except Exception:
250
+ pass
251
+ if full_text:
252
+ break
253
+
254
+ if not full_text:
255
+ full_text = info.get("description", "")
256
+
257
+ # Save transcript text
258
+ text_out = _outputs_dir() / "text_posts"
259
+ text_out.mkdir(parents=True, exist_ok=True)
260
+ txt_file = text_out / f"{video_id}_transcript.txt"
261
+ with open(txt_file, "w", encoding="utf-8") as f:
262
+ f.write(full_text)
263
+
264
+ return {
265
+ "status": "success",
266
+ "video_id": video_id,
267
+ "title": info.get("title", ""),
268
+ "text": full_text,
269
+ "segments": segments,
270
+ "saved_text_path": str(txt_file),
271
+ }
272
+ except Exception as e:
273
+ return {"status": "error", "video_id": video_id, "error": str(e), "text": ""}
274
+
275
+ return {"status": "error", "video_id": video_id, "error": "yt-dlp required", "text": ""}
276
+
277
+
278
+ def get_tiktok_user_feed(username: str, limit: int = 10) -> Dict[str, Any]:
279
+ """Scrapes creator profile info and recent video feed."""
280
+ clean_user = username.lstrip("@").strip()
281
+ url = f"https://www.tiktok.com/@{clean_user}"
282
+
283
+ if HAS_YT_DLP:
284
+ try:
285
+ ydl_opts = {
286
+ "extract_flat": True,
287
+ "playlistend": limit,
288
+ "quiet": True,
289
+ "no_warnings": True,
290
+ }
291
+ with yt_dlp.YoutubeDL(ydl_opts) as ydl:
292
+ info = ydl.extract_info(url, download=False)
293
+ entries = info.get("entries", []) or []
294
+ clean_videos = []
295
+ for e in entries[:limit]:
296
+ clean_videos.append({
297
+ "id": e.get("id", ""),
298
+ "url": e.get("url", ""),
299
+ "title": e.get("title", ""),
300
+ "duration": e.get("duration", 0),
301
+ "view_count": e.get("view_count", 0),
302
+ })
303
+
304
+ return {
305
+ "status": "success",
306
+ "username": clean_user,
307
+ "total_found": len(clean_videos),
308
+ "videos": clean_videos,
309
+ }
310
+ except Exception as e:
311
+ return {"status": "error", "username": clean_user, "error": str(e), "videos": []}
312
+
313
+ return {"status": "success", "username": clean_user, "videos": []}
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "tiktok-scrape",
3
+ "version": "1.0.0",
4
+ "description": "Zero-cost, watermark-free TikTok scraper & downloader for video feeds, transcripts, comments, and user profiles.",
5
+ "author": "SocialScrape",
6
+ "main": "cli.py",
7
+ "display_name": "TikTok Scraper",
8
+ "command": "/tiktok",
9
+ "command_description": "watermark-free MP4, captions & creator feeds",
10
+ "aliases": ["/tiktok"],
11
+ "cli_aliases": ["tiktok"],
12
+ "url_patterns": ["tiktok.com"],
13
+ "tool_schema": {
14
+ "name": "tiktok_scrape",
15
+ "description": "Scrapes watermark-free TikTok videos, audio tracks, spoken transcripts/captions, and creator feeds.",
16
+ "parameters": {
17
+ "type": "object",
18
+ "properties": {
19
+ "target": {"type": "string", "description": "TikTok video URL, ID, or creator @username."},
20
+ "input_file": {"type": "string", "description": "Path to .txt or .csv file for bulk TikTok extraction."},
21
+ "transcript": {"type": "boolean", "description": "Extract video captions/transcript."},
22
+ "feed": {"type": "boolean", "description": "Scrape creator recent video feed."},
23
+ "download_video": {"type": "boolean", "description": "Download watermark-free MP4 video."},
24
+ "download_audio": {"type": "boolean", "description": "Extract background audio track only."},
25
+ "extract_all": {"type": "boolean"}
26
+ }
27
+ }
28
+ },
29
+ "flag_mapping": {
30
+ "positional": ["target"],
31
+ "flags": {
32
+ "input_file": "--input-file",
33
+ "transcript": "--transcript",
34
+ "feed": "--feed",
35
+ "download_video": "--download-video",
36
+ "download_audio": "--download-audio",
37
+ "extract_all": "-a"
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,158 @@
1
+ # Twitter / X Universal Scraper & Downloader Plugin 🐦
2
+
3
+ > **A self-contained, high-speed, zero-cookie Python SDK and CLI engine for Twitter / X tweets, thread replies, media downloads, and user timelines.**
4
+
5
+ This plugin extracts structured tweet text and downloads media from **single tweets**, **reply threads**, **user timelines**, and **attached MP4 videos/GIFs** using the zero-cookie Syndication API and `yt-dlp`.
6
+
7
+ ---
8
+
9
+ ## 🌟 Comprehensive Feature Breakdown & Capabilities
10
+
11
+ ### 1. 📝 Zero-Cookie Tweet Text & Engagement Scraping
12
+ - **How it works**: Queries Twitter's public CDN Syndication API (`cdn.syndication.twimg.com/tweet-result`), which serves complete tweet payloads with zero authentication, zero login barriers, and zero cookies.
13
+ - **Capabilities**:
14
+ - Extracts full tweet `text`, `created_at`, `likes` (favorite count), `retweets`, and `reply_count`.
15
+ - Scrapes author metadata: `author` (@handle), `author_name` (display name), `avatar_url`.
16
+ - Automatically exports tweet text to `Outputs/text_posts/{tweet_id}_tweet.txt` and `Outputs/text_posts/{tweet_id}_tweet.json`.
17
+
18
+ ### 2. 🎬 Video & Animated GIF Downloader
19
+ - **How it works**: Extracts direct MP4 video streams and animated GIFs attached to tweets via `yt-dlp`.
20
+ - **Download Modes**:
21
+ - **Video (`--download-video`)**: Downloads attached MP4 video or animated GIF directly into `Outputs/videos/{tweet_id}/video.mp4`.
22
+ - **Quality Selector (`-q / --quality`)**: Select from `best` (1080p), `720p`, or `480p`.
23
+ - **Attached Photos & Thumbnails (`--download-thumb`)**: Downloads full-resolution attached photos into `Outputs/thumbnails/{tweet_id}/`.
24
+
25
+ ### 3. 💬 Reply Threads & Conversation Scraping
26
+ - **How it works**: Scrapes conversation reply chains and discussion threads for sentiment analysis.
27
+ - **Data Extracted**:
28
+ - `id`: Unique reply tweet identifier.
29
+ - `author`: Handle of reply author.
30
+ - `text`: Reply comment text.
31
+ - Saved as structured JSON in `Outputs/comments/{tweet_id}_replies.json`.
32
+
33
+ ### 4. 📺 User Timeline Scraping
34
+ - **How it works**: Scrapes recent tweets and media links from creator timelines using `@handle` or profile links.
35
+ - **Data Extracted**:
36
+ - List of recent tweet IDs, text snippets, and timestamps.
37
+ - Saved as structured JSON in `Outputs/text_posts/{username}_timeline.json`.
38
+
39
+ ### 5. 📦 Complete Extraction Bundle (`--all`)
40
+ - **How it works**: Extracts tweet text, thread replies, attached thumbnail/photo, and downloads video in a single unified command.
41
+
42
+ ---
43
+
44
+ ## 📁 Standardized `Outputs/` Hierarchy
45
+
46
+ Every extracted asset is organized cleanly into dedicated folders:
47
+
48
+ ```text
49
+ plugins/twitter-scrape/
50
+ ├── core.py # ⚡ Pure Python SDK (Zero prints, returns dicts)
51
+ ├── cli.py # 🧙 Interactive CLI & Terminal Runner
52
+ ├── plugin.json # 📋 Universal plugin manifest
53
+ ├── SKILL.md # 🧠 AI Agent parameter discovery protocol
54
+ ├── README.md # 📖 Master documentation (This file)
55
+ ├── requirements.txt # 📦 Isolated dependencies (yt-dlp, requests)
56
+ └── Outputs/ # 💾 Standardized Categorized Storage
57
+ ├── videos/<tweet_id>/
58
+ │ └── video.mp4 # Downloaded MP4 video or animated GIF
59
+ ├── thumbnails/<tweet_id>/
60
+ │ └── thumbnail.jpg # High-res attached photo or video cover
61
+ ├── comments/
62
+ │ └── <tweet_id>_replies.json # Extracted reply thread comments
63
+ └── text_posts/
64
+ ├── <tweet_id>_tweet.json # Structured tweet metadata
65
+ ├── <tweet_id>_tweet.txt # Clean tweet body text
66
+ └── <username>_timeline.json # Recent user timeline tweets
67
+ ```
68
+
69
+ ---
70
+
71
+ ## 💡 AI Agent Usage: In-Memory / Zero-Disk Execution
72
+
73
+ When an AI agent (Claude Code, Cursor, Codex, Antigravity) executes this plugin, **it does NOT need to write heavy media files to disk**.
74
+
75
+ ### Zero-Disk Execution Modes for AI Agents:
76
+
77
+ 1. **In-Memory CLI Pipe (`--stdout`)**:
78
+ ```bash
79
+ python plugins/twitter-scrape/cli.py "https://twitter.com/elonmusk/status/1785023849204859032" --stdout
80
+ ```
81
+ *The structured JSON streams directly into the AI's standard input in RAM.*
82
+
83
+ 2. **Direct Python SDK Import**:
84
+ ```python
85
+ import sys
86
+ from pathlib import Path
87
+ sys.path.insert(0, str(Path("plugins/twitter-scrape").resolve()))
88
+ import core
89
+
90
+ # Returns pure Python dictionary in RAM with zero disk writes!
91
+ tweet = core.get_tweet("1785023849204859032")
92
+ timeline = core.get_user_timeline("elonmusk")
93
+ ```
94
+
95
+ ---
96
+
97
+ ## 🚀 CLI Commands & Usage Examples
98
+
99
+ ### 1. Interactive Wizard (Easiest for Humans)
100
+ ```bash
101
+ python plugins/twitter-scrape/cli.py -i
102
+ ```
103
+
104
+ ### 2. Single Tweet Text & Metrics
105
+ ```bash
106
+ # Scrape tweet text and save to Outputs/text_posts/
107
+ python plugins/twitter-scrape/cli.py "https://twitter.com/elonmusk/status/1785023849204859032"
108
+ ```
109
+
110
+ ### 3. Video / GIF Downloads
111
+ ```bash
112
+ # Download attached MP4 video or animated GIF
113
+ python plugins/twitter-scrape/cli.py "https://x.com/user/status/123456789" --download-video
114
+
115
+ # Download attached high-res photo
116
+ python plugins/twitter-scrape/cli.py "https://x.com/user/status/123456789" --download-thumb
117
+ ```
118
+
119
+ ### 4. User Timeline Scraping
120
+ ```bash
121
+ # Scrape recent tweets from creator
122
+ python plugins/twitter-scrape/cli.py "@elonmusk" --timeline
123
+ ```
124
+
125
+ ### 5. Full Extraction Suite
126
+ ```bash
127
+ # Extract tweet text, replies, photos, and video all in one run
128
+ python plugins/twitter-scrape/cli.py "https://x.com/user/status/123456789" --all
129
+ ```
130
+
131
+ ---
132
+
133
+ ## ⚙️ CLI Flag Reference Table
134
+
135
+ | Flag | Shorthand | Type | Default | Description |
136
+ | :--- | :--- | :--- | :--- | :--- |
137
+ | `target` | - | `string` | `None` | Tweet URL, status ID, or creator `@username`. |
138
+ | `--interactive` | `-i` | `flag` | `False` | Launch step-by-step interactive wizard. |
139
+ | `--stdout` | - | `flag` | `False` | Stream structured JSON directly to console. |
140
+ | `--download-video` | - | `flag` | `False` | Download attached `.mp4` video or GIF. |
141
+ | `--download-thumb` | - | `flag` | `False` | Download attached photo or video cover image. |
142
+ | `-q` / `--quality` | - | `string` | `best` | Video quality: `best`, `1080p`, `720p`, `480p`. |
143
+ | `--comments` | - | `flag` | `False` | Extract reply thread comments. |
144
+ | `--timeline` | - | `flag` | `False` | Scrape recent user timeline tweets. |
145
+ | `--all` | `-a` | `flag` | `False` | Extract EVERYTHING (Tweet + Replies + Media + Video). |
146
+
147
+ ---
148
+
149
+ ## 🔒 Security & Defensive Engineering
150
+
151
+ 1. **Zero-Cookie Bypass**: Uses public Syndication CDN endpoints without risking user credentials.
152
+ 2. **Path Traversal Protection**: Output paths are validated against allowed project boundaries.
153
+ 3. **Pacing & Rate Limiting**: Built-in delay pacing prevents IP rate-limiting.
154
+
155
+ ---
156
+
157
+ ## 📄 License
158
+ MIT License. Part of the [SocialScrape](../../README.md) toolkit.
@@ -0,0 +1,50 @@
1
+ ---
2
+ name: twitter-scrape
3
+ description: "Self-contained plugin and skill for scraping Twitter / X tweets, reply threads, video/media attachments, and user timelines."
4
+ triggers:
5
+ - twitter.com
6
+ - x.com
7
+ - tweet
8
+ - twitter video
9
+ - twitter thread
10
+ - download twitter
11
+ - twitter comments
12
+ ---
13
+
14
+ # Twitter / X Scrape Plugin & Skill
15
+
16
+ ## Overview
17
+ This plugin executes zero-cost extraction and media downloads for Twitter / X:
18
+ - **Tweets & Threads**: Raw text, replies, quote tweets, retweet counts, and timestamps.
19
+ - **Media Downloads**: Direct MP4 video download from tweets via `yt-dlp`.
20
+ - **Attached Images**: Photo and thumbnail downloads.
21
+ - **Timelines**: User profile tweets and timeline pagination.
22
+
23
+ All disk outputs are organized into structured directories inside `plugins/twitter-scrape/Outputs/`:
24
+ - `Outputs/videos/`
25
+ - `Outputs/thumbnails/`
26
+ - `Outputs/comments/`
27
+ - `Outputs/text_posts/`
28
+
29
+ ---
30
+
31
+ ## ⚡ Execution Modes & Commands
32
+
33
+ ### 1. In-Memory / Zero-Disk Execution
34
+ ```bash
35
+ python plugins/twitter-scrape/cli.py "<TWEET_OR_PROFILE_URL>" --stdout
36
+ ```
37
+
38
+ ### 2. Extraction Saved to `Outputs/`
39
+ ```bash
40
+ # Full extraction suite
41
+ python plugins/twitter-scrape/cli.py "<TWEET_URL>" --all
42
+
43
+ # Download video only
44
+ python plugins/twitter-scrape/cli.py "<TWEET_URL>" --download-video
45
+ ```
46
+
47
+ ### 3. Interactive Wizard Mode
48
+ ```bash
49
+ python plugins/twitter-scrape/cli.py -i
50
+ ```