Compare commits

..
16 Commits
Author SHA1 Message Date
afkarxyz bb1c0dccae Merge branch 'main' of https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader 2025-03-23 23:31:55 +07:00
afkarxyz 0cf5316745 Update v1.9 2025-03-23 23:31:44 +07:00
afkarxyz c3493944e8 Update README.md 2025-03-23 23:30:54 +07:00
afkarxyz c656459171 Update README.md 2025-03-23 21:11:17 +07:00
afkarxyz 0e14f92244 Update README.md 2025-03-23 18:40:24 +07:00
afkarxyz fad4434753 Update README.md 2025-03-23 18:34:41 +07:00
afkarxyz 77a9c83f4d Update v1.8 2025-03-23 18:30:14 +07:00
afkarxyz 7fa277931c Update v1.8 2025-03-23 18:26:37 +07:00
afkarxyz be080481bf Update README.md 2025-03-23 18:24:45 +07:00
afkarxyz 8a720e3e2b Update README.md 2025-03-04 09:16:57 +07:00
afkarxyz 48a672e0bd Update README.md 2025-03-04 09:10:50 +07:00
afkarxyz 91210f1c82 Update v1.7 2025-03-04 08:54:07 +07:00
afkarxyz cb2a244e37 Update README.md 2025-02-19 09:52:41 +07:00
afkarxyz 096425a0e1 Update version.json 2025-02-19 09:52:31 +07:00
afkarxyz c01a995b3d Update v1.6 2025-02-19 09:52:22 +07:00
afkarxyz b28b4ef14c Update README.md 2025-02-18 12:16:32 +07:00
6 changed files with 658 additions and 289 deletions

No files matched your search

+4 -3
View File
@@ -4,7 +4,7 @@ import os
from datetime import datetime
from gallery_dl.extractor import twitter
def get_metadata(username):
def get_metadata(username, auth_token):
url = f"https://x.com/{username}/timeline"
match = re.match(twitter.TwitterTimelineExtractor.pattern, url)
@@ -15,7 +15,7 @@ def get_metadata(username):
extractor.config = lambda key, default=None: {
"cookies": {
"auth_token": ""
"auth_token": auth_token
}
}.get(key, default)
@@ -75,4 +75,5 @@ def get_metadata(username):
return output
username = ""
get_metadata(username)
auth_token = ""
get_metadata(username, auth_token)
+4 -3
View File
@@ -3,7 +3,7 @@ import re
import os
from gallery_dl.extractor import twitter
def get_metadata(username):
def get_metadata(username, auth_token):
url = f"https://x.com/{username}/timeline"
match = re.match(twitter.TwitterTimelineExtractor.pattern, url)
@@ -14,7 +14,7 @@ def get_metadata(username):
extractor.config = lambda key, default=None: {
"cookies": {
"auth_token": ""
"auth_token": auth_token
}
}.get(key, default)
@@ -31,4 +31,5 @@ def get_metadata(username):
json.dump(all_items, f, indent=2, default=str)
username = ""
get_metadata(username)
auth_token = ""
get_metadata(username, auth_token)
+19 -20
View File
@@ -3,38 +3,37 @@
![TwitterXMediaBatchDownloader](https://github.com/user-attachments/assets/354d7470-c01c-4aa6-9da1-ea6c42d27330)
<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 accounts, 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, even withheld account, using <code>gallery-dl</code>
</div>
## Download
## 📥 Download
- Download the latest version of [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v1.5/TwitterXMediaBatchDownloader.exe)
- 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)
## Features
## ✨ Features
- Uses the powerful `gallery-dl` library, similar to `yt-dlp`
- The ability to download media from **Withheld Accounts** _(requires unchecking the **Local** option)_
- Option to choose the media type to download: **media** (image + GIF + video) or just **image/GIF/video**
- Download images and videos in original quality
- 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
## Screenshots
## 🖼️ Screenshots
![image](https://github.com/user-attachments/assets/085cdcee-5272-41bb-8612-06737c0ebe32)
![image](https://github.com/user-attachments/assets/7c5ebdda-c558-49ed-9f16-a6060b52f6f8)
![image](https://github.com/user-attachments/assets/3e71f14b-c4f0-4e86-87d5-9217d88cb0c2)
![python_7NZpAQ8RQi](https://github.com/user-attachments/assets/9982e4f5-a4b2-4d1b-9481-7bf7db700663)
![image](https://github.com/user-attachments/assets/c4e086c2-d4d5-4eee-8bab-dba8e5fdd90d)
![image](https://github.com/user-attachments/assets/cbaa514c-7734-45ac-a142-18829b4d1838)
> Downloading from **Withheld Accounts**
> [!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.
![image](https://github.com/user-attachments/assets/f5e301cf-9700-4986-a87d-8424be40db5c)
![image](https://github.com/user-attachments/assets/ba986e15-ffec-4cd4-900e-98bba0e513d6)
![image](https://github.com/user-attachments/assets/92f814b1-069f-4605-b31f-8a5ff8dc0f17)
![image](https://github.com/user-attachments/assets/1ef4ec73-c77b-433a-ac79-f0df5be36bd1)
![image](https://github.com/user-attachments/assets/c6e7dc0d-659d-456e-b30c-6cca66fe9359)
## How to Obtain Auth Token
## 🔑 How to Obtain Auth Token
> [!Warning]
> - I suggest not using the **main account** to obtain the token.
@@ -51,8 +50,8 @@
> X.com Auth Token Grabber
![image](https://github.com/user-attachments/assets/1213305b-95eb-4a8f-80f3-2655ca70f6e6)
![image](https://github.com/user-attachments/assets/4bf5f787-d34f-4259-837c-07a6432c4360)
> Developer Tools
![image](https://github.com/user-attachments/assets/50f819da-7490-4f3c-b130-c5a3ee482e2d)
![image](https://github.com/user-attachments/assets/8e81dd8f-f8be-4254-9cf6-cacfa97743e9)
File diff suppressed because it is too large. Load diff
+154
View File
@@ -0,0 +1,154 @@
import re
import json
from datetime import datetime
from gallery_dl.extractor import twitter
def get_metadata(username, auth_token, timeline_type="timeline", batch_size=0, page=0, media_type="all"):
url = f"https://x.com/{username}/{timeline_type}"
if timeline_type == "media":
extractor_class = twitter.TwitterMediaExtractor
elif timeline_type == "tweets":
extractor_class = twitter.TwitterTweetsExtractor
elif timeline_type == "with_replies":
extractor_class = twitter.TwitterRepliesExtractor
else:
extractor_class = twitter.TwitterTimelineExtractor
match = re.match(extractor_class.pattern, url)
if not match:
raise ValueError(f"Invalid URL for {timeline_type}: {url}")
extractor = extractor_class(match)
config_dict = {
"cookies": {
"auth_token": auth_token
}
}
if batch_size > 0:
config_dict["count"] = batch_size
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
if isinstance(item, tuple) and len(item) >= 3:
media_url = item[1]
tweet_data = item[2]
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)
}
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
def main():
username = ""
auth_token = ""
timeline_type = "media"
batch_size = 100
page = 0
media_type = "all"
try:
data = get_metadata(
username=username,
auth_token=auth_token,
timeline_type=timeline_type,
batch_size=batch_size,
page=page,
media_type=media_type
)
print(json.dumps(data, ensure_ascii=False, indent=2))
except Exception as e:
print(json.dumps({"error": str(e)}, ensure_ascii=False))
if __name__ == '__main__':
main()
+1 -1
View File
@@ -1,3 +1,3 @@
{
"version": "1.5"
"version": "1.8"
}