mirror of
https://github.com/Alvin-Zilverstand/Twitter-X-Media-Batch-Downloader.git
synced 2026-11-24 07:13:11 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddf6439893 | ||
|
|
fed2bf7b0c | ||
|
|
241884de89 | ||
|
|
77b443ace0 | ||
|
|
cd48b6f9bc | ||
|
|
6f45b48047 | ||
|
|
7083c56c8b | ||
|
|
60cb3cbabd | ||
|
|
b38bff238a | ||
|
|
d4d216ed6b | ||
|
|
129c007f6f | ||
|
|
d78ad32c09 | ||
|
|
3975e5dd0e | ||
|
|
37f1d910cb | ||
|
|
74ed38cc31 | ||
|
|
2e326c39a0 | ||
|
|
39c37d4776 | ||
|
|
5709d76ceb | ||
|
|
75b3549653 | ||
|
|
ebe739e612 | ||
|
|
d423f20bad | ||
|
|
fba8a8ac45 | ||
|
|
a36c7613d2 | ||
|
|
c7615ed2f6 | ||
|
|
0c17f1b419 | ||
|
|
dd38880366 | ||
|
|
306d2c3c95 | ||
|
|
1caa59bbcf | ||
|
|
4d0021092c | ||
|
|
981bc8d9ec | ||
|
|
c894bfd4d2 | ||
|
|
61e50b8121 | ||
|
|
ba69dd7cf4 | ||
|
|
bcc332d0d7 | ||
|
|
82184aef33 | ||
|
|
357ad0f020 | ||
|
|
43f4d84593 | ||
|
|
4cecb6b14e | ||
|
|
eb712d5d8d | ||
|
|
46c178fec0 | ||
|
|
8ce5f1f833 | ||
|
|
0a80a3d331 | ||
|
|
f8b27ecb5a | ||
|
|
70e79af700 | ||
|
|
4fb60840a0 | ||
|
|
5613c152f8 | ||
|
|
ad5d7727eb | ||
|
|
ed1f0fce06 | ||
|
|
ee92174773 | ||
|
|
f08ce57feb | ||
|
|
4f21321e42 | ||
|
|
c8b7a5365a | ||
|
|
1049b544c5 | ||
|
|
e7db97a936 | ||
|
|
af1280b798 | ||
|
|
4f6004a501 | ||
|
|
e7141cd8d1 | ||
|
|
4d6f4d904a | ||
|
|
4081e6aacf | ||
|
|
2b405a16a7 | ||
|
|
5e658c05d4 | ||
|
|
b26dd0b2af | ||
|
|
28422dcf1d | ||
|
|
46e09532fc | ||
|
|
967d91d370 | ||
|
|
2ff0242e32 | ||
|
|
1e1d612807 | ||
|
|
9821dd8c65 | ||
|
|
46bb7d38f7 | ||
|
|
112f5992c4 | ||
|
|
178b3c490f |
No files matched your search
@@ -0,0 +1,4 @@
|
||||
dist/
|
||||
build/
|
||||
*.spec
|
||||
.venv/
|
||||
@@ -1,79 +0,0 @@
|
||||
import json
|
||||
import re
|
||||
import os
|
||||
from datetime import datetime
|
||||
from gallery_dl.extractor import twitter
|
||||
|
||||
def get_metadata(username, auth_token):
|
||||
url = f"https://x.com/{username}/timeline"
|
||||
|
||||
match = re.match(twitter.TwitterTimelineExtractor.pattern, url)
|
||||
if not match:
|
||||
raise ValueError(f"Invalid URL: {url}")
|
||||
|
||||
extractor = twitter.TwitterTimelineExtractor(match)
|
||||
|
||||
extractor.config = lambda key, default=None: {
|
||||
"cookies": {
|
||||
"auth_token": auth_token
|
||||
}
|
||||
}.get(key, default)
|
||||
|
||||
extractor.initialize()
|
||||
|
||||
output = {
|
||||
'account_info': {},
|
||||
'total_urls': 0,
|
||||
'timeline': []
|
||||
}
|
||||
|
||||
for item in extractor:
|
||||
if isinstance(item, tuple) and len(item) >= 3:
|
||||
media_url = item[1]
|
||||
tweet_data = item[2]
|
||||
|
||||
if not output['account_info']:
|
||||
if 'user' in tweet_data:
|
||||
user = tweet_data['user']
|
||||
user_date = user.get('date', '')
|
||||
if isinstance(user_date, datetime):
|
||||
user_date = user_date.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
output['account_info'] = {
|
||||
'name': user.get('name', ''),
|
||||
'nick': user.get('nick', ''),
|
||||
'date': user_date,
|
||||
'followers_count': user.get('followers_count', 0),
|
||||
'friends_count': user.get('friends_count', 0),
|
||||
'profile_image': user.get('profile_image', ''),
|
||||
'statuses_count': user.get('statuses_count', 0)
|
||||
}
|
||||
|
||||
if 'pbs.twimg.com' in media_url or 'video.twimg.com' in media_url:
|
||||
tweet_date = tweet_data.get('date', datetime.now())
|
||||
if isinstance(tweet_date, datetime):
|
||||
tweet_date = tweet_date.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
timeline_entry = {
|
||||
'url': media_url,
|
||||
'date': tweet_date,
|
||||
'tweet_id': tweet_data.get('tweet_id', 0),
|
||||
}
|
||||
|
||||
if 'type' in tweet_data:
|
||||
timeline_entry['type'] = tweet_data['type']
|
||||
|
||||
output['timeline'].append(timeline_entry)
|
||||
output['total_urls'] += 1
|
||||
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
output_file = os.path.join(current_dir, f"{username}.json")
|
||||
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(output, f, ensure_ascii=False, indent=2)
|
||||
|
||||
return output
|
||||
|
||||
username = ""
|
||||
auth_token = ""
|
||||
get_metadata(username, auth_token)
|
||||
@@ -1,35 +0,0 @@
|
||||
import json
|
||||
import re
|
||||
import os
|
||||
from gallery_dl.extractor import twitter
|
||||
|
||||
def get_metadata(username, auth_token):
|
||||
url = f"https://x.com/{username}/timeline"
|
||||
|
||||
match = re.match(twitter.TwitterTimelineExtractor.pattern, url)
|
||||
if not match:
|
||||
raise ValueError(f"Invalid URL: {url}")
|
||||
|
||||
extractor = twitter.TwitterTimelineExtractor(match)
|
||||
|
||||
extractor.config = lambda key, default=None: {
|
||||
"cookies": {
|
||||
"auth_token": auth_token
|
||||
}
|
||||
}.get(key, default)
|
||||
|
||||
extractor.initialize()
|
||||
|
||||
all_items = []
|
||||
for item in extractor:
|
||||
all_items.append(item)
|
||||
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
output_file = os.path.join(current_dir, f"{username}.json")
|
||||
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(all_items, f, indent=2, default=str)
|
||||
|
||||
username = ""
|
||||
auth_token = ""
|
||||
get_metadata(username, auth_token)
|
||||
Binary file not shown.
+11
-11
@@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" ?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
|
||||
id="Layer_1" width="512px" height="512px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;"
|
||||
xml:space="preserve">
|
||||
<g fill="#1da0f1">
|
||||
<polygon
|
||||
points="12.153992,10.729553 8.088684,5.041199 5.92041,5.041199 10.956299,12.087097 11.59021,12.97345 15.900635,19.009583 18.068909,19.009583 12.785217,11.615906 " />
|
||||
<path
|
||||
d="M21.15979,1H2.84021C1.823853,1,1,1.823853,1,2.84021v18.31958C1,22.176147,1.823853,23,2.84021,23h18.31958 C22.176147,23,23,22.176147,23,21.15979V2.84021C23,1.823853,22.176147,1,21.15979,1z M15.235352,20l-4.362549-6.213013 L5.411438,20H4l6.246887-7.104675L4,4h4.764648l4.130127,5.881958L18.06958,4h1.411377l-5.95697,6.775635L20,20H15.235352z" />
|
||||
</g>
|
||||
</svg>
|
||||
<?xml version="1.0" ?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
|
||||
id="Layer_1" width="512px" height="512px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;"
|
||||
xml:space="preserve">
|
||||
<g fill="#1da0f1">
|
||||
<polygon
|
||||
points="12.153992,10.729553 8.088684,5.041199 5.92041,5.041199 10.956299,12.087097 11.59021,12.97345 15.900635,19.009583 18.068909,19.009583 12.785217,11.615906 " />
|
||||
<path
|
||||
d="M21.15979,1H2.84021C1.823853,1,1,1.823853,1,2.84021v18.31958C1,22.176147,1.823853,23,2.84021,23h18.31958 C22.176147,23,23,22.176147,23,21.15979V2.84021C23,1.823853,22.176147,1,21.15979,1z M15.235352,20l-4.362549-6.213013 L5.411438,20H4l6.246887-7.104675L4,4h4.764648l4.130127,5.881958L18.06958,4h1.411377l-5.95697,6.775635L20,20H15.235352z" />
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 876 B After Width: | Height: | Size: 865 B |
@@ -3,35 +3,128 @@
|
||||

|
||||
|
||||
<div align="center">
|
||||
<b>Twitter/X Media Batch Downloader</b> is a GUI tool that allows users to download all media, including images and videos, in their original quality from Twitter/X accounts, even withheld account, using <code>gallery-dl</code>
|
||||
<b>Twitter/X Media Batch Downloader</b> is a GUI tool that allows users to download all media, including images and videos, in their original quality from Twitter/X accounts using <code>gallery-dl</code>
|
||||
</div>
|
||||
|
||||
## 📥 Download
|
||||
|
||||
- Download the latest version of [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v1.9/TwitterXMediaBatchDownloader.exe)
|
||||
- If you're familiar with **userscripts**, please install it [here](https://greasyfork.org/en/scripts/523157-twitter-x-media-batch-downloader)
|
||||
- **Windows**: [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.1/TwitterXMediaBatchDownloader.exe)
|
||||
- **Linux**: [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.1/TwitterXMediaBatchDownloader)
|
||||
- **Mac**: [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.1/TwitterXMediaBatchDownloader.app.zip)
|
||||
- If you're familiar with **userscripts**, please install it [here](https://greasyfork.org/en/scripts/523157)
|
||||
|
||||
### The downloaded application won't run❓
|
||||
|
||||
🐧 **Solution (Ubuntu/Linux)**: Open your terminal and run:
|
||||
|
||||
```bash
|
||||
chmod +x TwitterXMediaBatchDownloader
|
||||
```
|
||||
|
||||
https://github.com/user-attachments/assets/41231de2-e665-4d61-a4f4-62f424973af3
|
||||
|
||||
🍎 **Solution (macOS)**: Open your terminal and run:
|
||||
|
||||
```bash
|
||||
xattr -rd com.apple.quarantine ~/Downloads/TwitterXMediaBatchDownloader.app
|
||||
```
|
||||
|
||||
https://github.com/user-attachments/assets/56a89c03-29ab-45f1-979f-4317f45191f7
|
||||
|
||||
## ✨ Features
|
||||
|
||||
- Powered by `gallery-dl`, similar to `yt-dlp`
|
||||
- Supports downloading from **Withheld Accounts**
|
||||
- **Choose media type**: All (Image + GIF + Video) or specific (Image/GIF/Video)
|
||||
- Downloads in original quality
|
||||
- Powered by `gallery-dl`, similar to `yt-dlp`
|
||||
- **Bulk download**: Download multiple items at once
|
||||
- Media-type selection: All (Images + GIFs + Videos) or specific (Images / GIFs / Videos)
|
||||
- **MP4 → GIF conversion:** Convert downloaded MP4 videos into GIF format
|
||||
- Downloads at original quality
|
||||
|
||||
## 🖼️ Screenshots
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||
## 🐧 Build Yourself (Ubuntu/Linux)
|
||||
|
||||
> [!Important]
|
||||
> It is highly recommended to use the local `gallery-dl` **(by unchecking "Use API").** Use the API only for withheld accounts, as it has a 60-second timeout limit.
|
||||
### 1. Install Required Packages
|
||||
|
||||

|
||||
```bash
|
||||
sudo apt install git python3-pip python3-venv
|
||||
```
|
||||
|
||||

|
||||
### 2. Clone the Repository
|
||||
|
||||
```bash
|
||||
git clone https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader.git
|
||||
cd Twitter-X-Media-Batch-Downloader
|
||||
```
|
||||
|
||||
### 3. Create and Activate a Virtual Environment
|
||||
|
||||
```bash
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
### 4. Install Python Dependencies
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
pip install pyinstaller
|
||||
```
|
||||
|
||||
### 5. Build the Application
|
||||
|
||||
```bash
|
||||
pyinstaller --onefile --windowed TwitterXMediaBatchDownloader.py
|
||||
```
|
||||
|
||||
The compiled binary will be located in the `dist/` folder.
|
||||
|
||||
## 🍎 Build Yourself (macOS)
|
||||
|
||||
### 1. Install Homebrew (if not already installed)
|
||||
|
||||
```bash
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
```
|
||||
|
||||
### 2. Install Git and Python
|
||||
|
||||
```bash
|
||||
brew install git python
|
||||
```
|
||||
|
||||
### 3. Go to Downloads and Clone the Repository
|
||||
|
||||
```bash
|
||||
cd ~/Downloads
|
||||
git clone https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader.git
|
||||
cd Twitter-X-Media-Batch-Downloader
|
||||
```
|
||||
|
||||
### 4. Create and Activate a Virtual Environment
|
||||
|
||||
```bash
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
### 5. Install Python Dependencies
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
pip install pyinstaller
|
||||
```
|
||||
|
||||
### 6. Build the Application
|
||||
|
||||
```bash
|
||||
pyinstaller --onefile --windowed --icon=Archived/icon.icns TwitterXMediaBatchDownloader.py
|
||||
```
|
||||
|
||||
The `.app` bundle will be generated inside the `dist/` folder.
|
||||
|
||||
## 🔑 How to Obtain Auth Token
|
||||
|
||||
@@ -39,12 +132,14 @@
|
||||
> - I suggest not using the **main account** to obtain the token.
|
||||
> - You can use https://temp-mail.io to register a Twitter account.
|
||||
> - Using an auth token or cookies has the potential to get the **account suspended.**
|
||||
> - If too many media files are fetched, it will trigger a **rate limit**, and the media retrieval will fail.
|
||||
> - If too many media files are fetched, it may trigger a **rate limit**, and the media retrieval will fail, try enabling Batch mode.
|
||||
|
||||
### [Video Tutorial](https://www.patreon.com/posts/how-to-obtain-127206894)
|
||||
|
||||
1. Go to [Twitter's website](https://www.x.com/)
|
||||
2. Log into your account
|
||||
3. Open the Developer Tools by pressing `F12`
|
||||
4. Navigate to the **Application** tab, then select **Storage** > **Cookies**
|
||||
4. Navigate to the **Application** tab, then select **Storage → Cookies**
|
||||
5. Find and copy the `auth_token` value or use the browser extension [X.com Auth Token Grabber](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v1.0/X.com.Auth.Token.Grabber.zip)
|
||||
6. Do not log out of your account, as a new `auth_token` will be generated by Twitter
|
||||
|
||||
|
||||
+1865
-1214
File diff suppressed because it is too large.
Load diff
+123
-91
@@ -32,102 +32,130 @@ def get_metadata(username, auth_token, timeline_type="timeline", batch_size=0, p
|
||||
|
||||
extractor.config = lambda key, default=None: config_dict.get(key, default)
|
||||
|
||||
extractor.initialize()
|
||||
|
||||
structured_output = {
|
||||
'account_info': {},
|
||||
'total_urls': 0,
|
||||
'timeline': []
|
||||
}
|
||||
|
||||
iterator = iter(extractor)
|
||||
|
||||
if batch_size > 0 and page > 0:
|
||||
items_to_skip = page * batch_size
|
||||
|
||||
if hasattr(extractor, '_cursor') and extractor._cursor:
|
||||
pass
|
||||
else:
|
||||
skipped = 0
|
||||
try:
|
||||
for _ in range(items_to_skip):
|
||||
next(iterator)
|
||||
skipped += 1
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
new_timeline_entries = []
|
||||
|
||||
items_to_fetch = batch_size if batch_size > 0 else float('inf')
|
||||
items_fetched = 0
|
||||
|
||||
try:
|
||||
while items_fetched < items_to_fetch:
|
||||
item = next(iterator)
|
||||
items_fetched += 1
|
||||
extractor.initialize()
|
||||
|
||||
api = twitter.TwitterAPI(extractor)
|
||||
try:
|
||||
if username.startswith("id:"):
|
||||
user = api.user_by_rest_id(username[3:])
|
||||
else:
|
||||
user = api.user_by_screen_name(username)
|
||||
|
||||
if "legacy" in user and user["legacy"].get("withheld_scope"):
|
||||
raise ValueError("withheld")
|
||||
|
||||
except Exception as e:
|
||||
error_msg = str(e).lower()
|
||||
if "withheld" in error_msg or (hasattr(e, "response") and "withheld" in str(e.response.text).lower()):
|
||||
raise ValueError("withheld")
|
||||
raise
|
||||
|
||||
structured_output = {
|
||||
'account_info': {},
|
||||
'total_urls': 0,
|
||||
'timeline': []
|
||||
}
|
||||
|
||||
iterator = iter(extractor)
|
||||
|
||||
if batch_size > 0 and page > 0:
|
||||
items_to_skip = page * batch_size
|
||||
|
||||
if isinstance(item, tuple) and len(item) >= 3:
|
||||
media_url = item[1]
|
||||
tweet_data = item[2]
|
||||
if hasattr(extractor, '_cursor') and extractor._cursor:
|
||||
pass
|
||||
else:
|
||||
skipped = 0
|
||||
try:
|
||||
for _ in range(items_to_skip):
|
||||
next(iterator)
|
||||
skipped += 1
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
new_timeline_entries = []
|
||||
|
||||
items_to_fetch = batch_size if batch_size > 0 else float('inf')
|
||||
items_fetched = 0
|
||||
|
||||
try:
|
||||
while items_fetched < items_to_fetch:
|
||||
item = next(iterator)
|
||||
items_fetched += 1
|
||||
|
||||
if not structured_output['account_info'] and 'user' in tweet_data:
|
||||
user = tweet_data['user']
|
||||
user_date = user.get('date', '')
|
||||
if isinstance(user_date, datetime):
|
||||
user_date = user_date.strftime("%Y-%m-%d %H:%M:%S")
|
||||
if isinstance(item, tuple) and len(item) >= 3:
|
||||
media_url = item[1]
|
||||
tweet_data = item[2]
|
||||
|
||||
structured_output['account_info'] = {
|
||||
'name': user.get('name', ''),
|
||||
'nick': user.get('nick', ''),
|
||||
'date': user_date,
|
||||
'followers_count': user.get('followers_count', 0),
|
||||
'friends_count': user.get('friends_count', 0),
|
||||
'profile_image': user.get('profile_image', ''),
|
||||
'statuses_count': user.get('statuses_count', 0)
|
||||
}
|
||||
|
||||
if 'pbs.twimg.com' in media_url or 'video.twimg.com' in media_url:
|
||||
tweet_date = tweet_data.get('date', datetime.now())
|
||||
if isinstance(tweet_date, datetime):
|
||||
tweet_date = tweet_date.strftime("%Y-%m-%d %H:%M:%S")
|
||||
if not structured_output['account_info'] and 'user' in tweet_data:
|
||||
user = tweet_data['user']
|
||||
user_date = user.get('date', '')
|
||||
if isinstance(user_date, datetime):
|
||||
user_date = user_date.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
structured_output['account_info'] = {
|
||||
'name': user.get('name', ''),
|
||||
'nick': user.get('nick', ''),
|
||||
'date': user_date,
|
||||
'followers_count': user.get('followers_count', 0),
|
||||
'friends_count': user.get('friends_count', 0),
|
||||
'profile_image': user.get('profile_image', ''),
|
||||
'statuses_count': user.get('statuses_count', 0)
|
||||
}
|
||||
|
||||
timeline_entry = {
|
||||
'url': media_url,
|
||||
'date': tweet_date,
|
||||
'tweet_id': tweet_data.get('tweet_id', 0),
|
||||
}
|
||||
|
||||
if 'type' in tweet_data:
|
||||
timeline_entry['type'] = tweet_data['type']
|
||||
|
||||
if media_type == 'all' or (
|
||||
(media_type == 'image' and 'pbs.twimg.com' in media_url and tweet_data.get('type') == 'photo') or
|
||||
(media_type == 'video' and 'video.twimg.com' in media_url and tweet_data.get('type') == 'video') or
|
||||
(media_type == 'gif' and 'video.twimg.com' in media_url and tweet_data.get('type') == 'animated_gif')
|
||||
):
|
||||
new_timeline_entries.append(timeline_entry)
|
||||
structured_output['total_urls'] += 1
|
||||
except StopIteration:
|
||||
pass
|
||||
if 'pbs.twimg.com' in media_url or 'video.twimg.com' in media_url:
|
||||
tweet_date = tweet_data.get('date', datetime.now())
|
||||
if isinstance(tweet_date, datetime):
|
||||
tweet_date = tweet_date.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
timeline_entry = {
|
||||
'url': media_url,
|
||||
'date': tweet_date,
|
||||
'tweet_id': tweet_data.get('tweet_id', 0),
|
||||
}
|
||||
|
||||
if 'type' in tweet_data:
|
||||
timeline_entry['type'] = tweet_data['type']
|
||||
|
||||
if media_type == 'all' or (
|
||||
(media_type == 'image' and 'pbs.twimg.com' in media_url and tweet_data.get('type') == 'photo') or
|
||||
(media_type == 'video' and 'video.twimg.com' in media_url and tweet_data.get('type') == 'video') or
|
||||
(media_type == 'gif' and 'video.twimg.com' in media_url and tweet_data.get('type') == 'animated_gif')
|
||||
):
|
||||
new_timeline_entries.append(timeline_entry)
|
||||
structured_output['total_urls'] += 1
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
structured_output['timeline'].extend(new_timeline_entries)
|
||||
|
||||
cursor_info = None
|
||||
if hasattr(extractor, '_cursor') and extractor._cursor:
|
||||
cursor_info = extractor._cursor
|
||||
|
||||
structured_output['metadata'] = {
|
||||
"new_entries": len(new_timeline_entries),
|
||||
"page": page,
|
||||
"batch_size": batch_size,
|
||||
"has_more": batch_size > 0 and items_fetched == batch_size,
|
||||
"cursor": cursor_info
|
||||
}
|
||||
|
||||
if not structured_output['account_info']:
|
||||
raise ValueError("Failed to fetch account information. Please check the username and auth token.")
|
||||
|
||||
return structured_output
|
||||
|
||||
structured_output['timeline'].extend(new_timeline_entries)
|
||||
|
||||
cursor_info = None
|
||||
if hasattr(extractor, '_cursor') and extractor._cursor:
|
||||
cursor_info = extractor._cursor
|
||||
|
||||
structured_output['metadata'] = {
|
||||
"new_entries": len(new_timeline_entries),
|
||||
"page": page,
|
||||
"batch_size": batch_size,
|
||||
"has_more": batch_size > 0 and items_fetched == batch_size,
|
||||
"cursor": cursor_info
|
||||
}
|
||||
|
||||
if not structured_output['account_info']:
|
||||
raise ValueError("Failed to fetch account information. Please check the username and auth token.")
|
||||
|
||||
return structured_output
|
||||
except Exception as e:
|
||||
error_msg = str(e).lower()
|
||||
if "withheld" in error_msg or e.__class__.__name__ == "ValueError" and str(e) == "withheld":
|
||||
return {"error": "To download withheld accounts, use this userscript version: https://www.patreon.com/exyezed"}
|
||||
else:
|
||||
error_str = str(e)
|
||||
if error_str == "None":
|
||||
return {"error": "Failed to authenticate. Please verify your auth token is valid and not expired."}
|
||||
else:
|
||||
return {"error": error_str}
|
||||
|
||||
def main():
|
||||
username = ""
|
||||
@@ -148,7 +176,11 @@ def main():
|
||||
)
|
||||
print(json.dumps(data, ensure_ascii=False, indent=2))
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}, ensure_ascii=False))
|
||||
error_str = str(e)
|
||||
if error_str == "None":
|
||||
print(json.dumps({"error": "Failed to authenticate. Please verify your auth token is valid and not expired."}, ensure_ascii=False))
|
||||
else:
|
||||
print(json.dumps({"error": error_str}, ensure_ascii=False))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"version": "3.2"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
PyQt6
|
||||
requests
|
||||
aiohttp
|
||||
imageio-ffmpeg
|
||||
packaging
|
||||
gallery-dl
|
||||
pyqtdarktheme
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"version": "1.8"
|
||||
"version": "3.1"
|
||||
}
|
||||
Reference in new issue
Block a user