Compare commits

...
76 Commits
Author SHA1 Message Date
afkarxyz 981bc8d9ec v3.0 2025-07-04 13:37:03 +07:00
afkarxyz c894bfd4d2 . 2025-07-04 13:36:31 +07:00
afkarxyz 61e50b8121 Update README.md 2025-07-04 13:29:21 +07:00
afkarxyz ba69dd7cf4 v2.9 2025-07-04 07:10:01 +07:00
afkarxyz bcc332d0d7 v2.9 2025-07-04 07:01:58 +07:00
afkarxyz 82184aef33 Update README.md 2025-07-04 06:57:57 +07:00
afkarxyz 357ad0f020 v2.8 2025-07-03 20:38:35 +07:00
afkarxyz 43f4d84593 v2.8 2025-07-03 20:30:46 +07:00
afkarxyz 4cecb6b14e Update README.md 2025-07-03 20:17:50 +07:00
afkarxyz eb712d5d8d Update README.md 2025-07-03 19:59:24 +07:00
afkarxyz 46c178fec0 Update README.md 2025-06-29 14:59:54 +07:00
afkarxyz 8ce5f1f833 v2.7 2025-06-24 18:39:50 +07:00
afkarxyz 0a80a3d331 v2.7 2025-06-24 18:39:30 +07:00
afkarxyz f8b27ecb5a v2.7 2025-06-24 18:30:38 +07:00
afkarxyz 70e79af700 v2.6 2025-06-03 05:17:49 +07:00
afkarxyz 4fb60840a0 v2.6 2025-05-31 20:23:57 +07:00
afkarxyz 5613c152f8 v2.6 2025-05-31 20:19:24 +07:00
afkarxyz ad5d7727eb Update README.md 2025-05-31 20:16:53 +07:00
afkarxyz ed1f0fce06 v2.5 2025-05-08 08:03:31 +07:00
afkarxyz ee92174773 v2.4.5 2025-05-08 07:54:31 +07:00
afkarxyz f08ce57feb Update README.md 2025-05-06 15:37:20 +07:00
afkarxyz 4f21321e42 Update README.md 2025-05-04 06:24:24 +07:00
afkarxyz c8b7a5365a v2.4 2025-05-04 06:22:28 +07:00
afkarxyz 1049b544c5 v2.4 2025-05-04 06:19:03 +07:00
afkarxyz e7db97a936 Small fix 2025-04-23 18:32:29 +07:00
afkarxyz af1280b798 Update v2.3 2025-04-23 18:27:12 +07:00
afkarxyz 4f6004a501 Update v2.3 2025-04-23 18:23:34 +07:00
afkarxyz e7141cd8d1 Update v2.2 2025-04-22 22:01:51 +07:00
afkarxyz 4d6f4d904a Update v2.2 2025-04-22 21:57:59 +07:00
afkarxyz 4081e6aacf Update README.md 2025-04-22 21:45:29 +07:00
afkarxyz 2b405a16a7 Update v2.1 2025-04-22 05:35:30 +07:00
afkarxyz 5e658c05d4 Update v2.1 2025-04-22 05:22:34 +07:00
afkarxyz b26dd0b2af Update TwitterXMediaBatchDownloader.py 2025-03-25 19:44:54 +07:00
afkarxyz 28422dcf1d Update v2.0 2025-03-25 18:47:21 +07:00
afkarxyz 46e09532fc Update v2.0 2025-03-25 18:44:06 +07:00
afkarxyz 967d91d370 Update README.md 2025-03-25 18:42:57 +07:00
afkarxyz 2ff0242e32 Update README.md 2025-03-24 04:41:38 +07:00
afkarxyz 1e1d612807 Update README.md 2025-03-23 23:59:41 +07:00
afkarxyz 9821dd8c65 Update README.md 2025-03-23 23:59:07 +07:00
afkarxyz 46bb7d38f7 Update README.md 2025-03-23 23:58:34 +07:00
afkarxyz 112f5992c4 Batch Request 2025-03-23 23:48:06 +07:00
afkarxyz 178b3c490f Update v1.9 2025-03-23 23:35:15 +07:00
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
afkarxyz 1e14fa6934 Update README.md 2025-02-18 10:41:57 +07:00
afkarxyz eac8a0f168 Update v1.5 2025-02-18 10:41:29 +07:00
afkarxyz f3904c276c Create version.json 2025-02-18 10:35:16 +07:00
afkarxyz fe9724fa2f Update README.md 2025-01-30 05:17:14 +07:00
afkarxyz 85e8f3135a Update README.md 2025-01-29 10:00:12 +07:00
afkarxyz 1e2725f900 Update README.md 2025-01-28 23:09:37 +07:00
afkarxyz 8e114a45e0 Update README.md 2025-01-28 23:08:55 +07:00
afkarxyz 92267dbf5e Update v1.4 2025-01-28 16:47:50 +07:00
afkarxyz 37da356f4c Update README.md 2025-01-28 16:47:25 +07:00
afkarxyz eb268f5f9f Update v1.3 2025-01-28 12:45:19 +07:00
afkarxyz e8ac4b8734 Update TwitterXMediaBatchDownloader.py 2025-01-28 12:39:36 +07:00
afkarxyz 99afe59a11 Update README.md 2025-01-28 12:28:27 +07:00
afkarxyz 8e8c0667df Update README.md 2025-01-27 06:27:52 +07:00
afkarxyz 03479326b3 Update README.md 2025-01-27 03:56:41 +07:00
afkarxyz b39f40e9f9 Update README.md 2025-01-24 04:44:54 +07:00
afkarxyz 5ed127f226 Update README.md 2025-01-23 09:36:27 +07:00
afkarxyz 3487edf691 Update README.md 2025-01-23 09:26:32 +07:00
afkarxyz 5b336df1d4 Update README.md 2025-01-23 09:02:23 +07:00
7 changed files with 1737 additions and 879 deletions

No files matched your search

-78
View File
@@ -1,78 +0,0 @@
import json
import re
import os
from datetime import datetime
from gallery_dl.extractor import twitter
def get_metadata(username):
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": ""
}
}.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 = ""
get_metadata(username)
-34
View File
@@ -1,34 +0,0 @@
import json
import re
import os
from gallery_dl.extractor import twitter
def get_metadata(username):
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": ""
}
}.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 = ""
get_metadata(username)
-11
View File
@@ -1,11 +0,0 @@
<?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

+32 -19
View File
@@ -6,35 +6,48 @@
<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
- Download the latest version of [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v1.2/TwitterXMediaBatchDownloader.exe)
- If you're familiar with **userscripts**, please install it [here](https://greasyfork.org/en/scripts/523157-twitter-x-media-batch-downloader)
- Download the latest version of [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v2.9/TwitterXMediaBatchDownloader.exe)
- If you're familiar with **userscripts**, please install it [here](https://greasyfork.org/en/scripts/523157)
## Features
## ✨ Features
- Uses the powerful `gallery-dl` library, similar to `yt-dlp`
- Simple and compact GUI
- Download images and videos in original quality
- Option to choose the media type to download: **media** (image + video) or just **image/video**
- **Batch** download settings, ranging from 10 to 100 files per download
- Filename format customization
- 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
## 🖼️ Screenshots
![image](https://github.com/user-attachments/assets/ccdd8a8d-890f-4d3c-a3b1-56dad3eb82a9)
![image](https://github.com/user-attachments/assets/7295213a-d9ba-4d75-8359-d43907b74aef)
![image](https://github.com/user-attachments/assets/01a80593-59fe-4c2b-a325-7e401fa3048f)
![image](https://github.com/user-attachments/assets/67bb51ef-0051-4470-b89b-66f653093543)
![image](https://github.com/user-attachments/assets/1779659e-3512-4e74-be0a-088419267fe0)
![image](https://github.com/user-attachments/assets/27138746-cd60-41bf-abc1-c4340d72edb5)
## How to Obtain Auth Token
## 🔑 How to Obtain Auth Token
> [!Warning]
> - 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 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**
5. Find and copy the `auth_token` value or use the browser extension [Cookie-Editor](https://cookie-editor.com/)
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
![image](https://github.com/user-attachments/assets/50f819da-7490-4f3c-b130-c5a3ee482e2d)
> X.com Auth Token Grabber
![image](https://github.com/user-attachments/assets/4bf5f787-d34f-4259-837c-07a6432c4360)
> Developer Tools
![image](https://github.com/user-attachments/assets/8e81dd8f-f8be-4254-9cf6-cacfa97743e9)
File diff suppressed because it is too large. Load diff
+186
View File
@@ -0,0 +1,186 @@
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)
try:
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 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
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 = ""
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:
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()
+3
View File
@@ -0,0 +1,3 @@
{
"version": "2.9"
}