mirror of
https://github.com/Alvin-Zilverstand/Twitter-X-Media-Batch-Downloader.git
synced 2026-11-25 07:44:00 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fa277931c | ||
|
|
be080481bf | ||
|
|
8a720e3e2b | ||
|
|
48a672e0bd | ||
|
|
91210f1c82 | ||
|
|
cb2a244e37 | ||
|
|
096425a0e1 | ||
|
|
c01a995b3d | ||
|
|
b28b4ef14c | ||
|
|
1e14fa6934 | ||
|
|
eac8a0f168 | ||
|
|
f3904c276c | ||
|
|
fe9724fa2f | ||
|
|
85e8f3135a | ||
|
|
1e2725f900 | ||
|
|
8e114a45e0 | ||
|
|
92267dbf5e | ||
|
|
37da356f4c | ||
|
|
eb268f5f9f | ||
|
|
e8ac4b8734 | ||
|
|
99afe59a11 | ||
|
|
8e8c0667df | ||
|
|
03479326b3 | ||
|
|
b39f40e9f9 | ||
|
|
5ed127f226 | ||
|
|
3487edf691 | ||
|
|
5b336df1d4 | ||
|
|
dfb536f663 | ||
|
|
2b5e7985d5 | ||
|
|
81bacad4d8 | ||
|
|
aa89fda847 | ||
|
|
e98cd51cf4 | ||
|
|
6bb5348485 | ||
|
|
784bb494fc | ||
|
|
5096e18cb8 | ||
|
|
2237de2b2c | ||
|
|
4656ebc56c | ||
|
|
f5357370b1 | ||
|
|
e216769e57 | ||
|
|
72fb45fc8a | ||
|
|
f6a2986dbf | ||
|
|
20b15191ac | ||
|
|
c616d688ff | ||
|
|
3f35f81fbe | ||
|
|
9109eeca76 | ||
|
|
d70b0c3522 | ||
|
|
e324d7b724 |
No files matched your search
@@ -1,75 +0,0 @@
|
|||||||
import json
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
def get_metadata(username):
|
|
||||||
if sys.platform == 'win32':
|
|
||||||
sys.stdout.reconfigure(encoding='utf-8')
|
|
||||||
|
|
||||||
url = f"https://x.com/{username}/timeline"
|
|
||||||
|
|
||||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
||||||
|
|
||||||
cookies_path = os.path.join(current_dir, 'cookies.json')
|
|
||||||
output_path = os.path.join(current_dir, f'{username}.json')
|
|
||||||
gallery_dl_path = os.path.join(current_dir, 'gallery-dl.exe')
|
|
||||||
|
|
||||||
config = {
|
|
||||||
"extractor": {
|
|
||||||
"twitter": {
|
|
||||||
"cookies": {
|
|
||||||
"auth_token": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
with open(cookies_path, 'w') as f:
|
|
||||||
json.dump(config, f)
|
|
||||||
|
|
||||||
result = subprocess.run([gallery_dl_path, '-j', '--config', cookies_path, url],
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
encoding='utf-8',
|
|
||||||
check=True)
|
|
||||||
|
|
||||||
os.remove(cookies_path)
|
|
||||||
|
|
||||||
data = json.loads(result.stdout)
|
|
||||||
output = {
|
|
||||||
'account_info': {},
|
|
||||||
'timeline': []
|
|
||||||
}
|
|
||||||
|
|
||||||
for item in data:
|
|
||||||
if isinstance(item, list) and len(item) > 2 and isinstance(item[2], dict):
|
|
||||||
if not output['account_info'] and 'user' in item[2]:
|
|
||||||
user = item[2]['user']
|
|
||||||
output['account_info'] = {
|
|
||||||
'date': user.get('date', ''),
|
|
||||||
'followers_count': user.get('followers_count', ''),
|
|
||||||
'friends_count': user.get('friends_count', ''),
|
|
||||||
'name': user.get('name', ''),
|
|
||||||
'nick': user.get('nick', ''),
|
|
||||||
'profile_image': user.get('profile_image', ''),
|
|
||||||
'statuses_count': user.get('statuses_count', '')
|
|
||||||
}
|
|
||||||
if isinstance(item[1], str):
|
|
||||||
url = item[1]
|
|
||||||
if ('pbs.twimg.com' in url and 'format=jpg&name=orig' in url) or 'video.twimg.com' in url:
|
|
||||||
tweet_date = item[2].get('date')
|
|
||||||
if not tweet_date:
|
|
||||||
tweet_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
||||||
|
|
||||||
output['timeline'].append({
|
|
||||||
'url': url,
|
|
||||||
'date': tweet_date
|
|
||||||
})
|
|
||||||
|
|
||||||
with open(output_path, 'w', encoding='utf-8') as f:
|
|
||||||
json.dump(output, f, ensure_ascii=False, indent=2)
|
|
||||||
|
|
||||||
username = ""
|
|
||||||
get_metadata(username)
|
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
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)
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
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)
|
||||||
@@ -1,25 +1,58 @@
|
|||||||
[](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases)
|
[](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases)
|
||||||
|
|
||||||
**Twitter/X Media Batch Downloader** is a GUI tool for downloading all media, including images and videos, from Twitter/X accounts, using `gallery-dl` and requiring `cookies.`
|

|
||||||
|
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
|
||||||
## Download
|
## Download
|
||||||
|
|
||||||
|
- Download the latest version of [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v1.8/TwitterXMediaBatchDownloader.exe)
|
||||||
|
- If you're familiar with **userscripts**, please install it [here](https://greasyfork.org/en/scripts/523157-twitter-x-media-batch-downloader)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Uses the powerful `gallery-dl` library, similar to `yt-dlp`
|
||||||
|
- The ability to download media from **Withheld Account**
|
||||||
|
- Option to choose the media type to download: **All Media** (Image + GIF + Video) or just **Image/GIF/Video**
|
||||||
|
- Download images and videos in original quality
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## How to obtain Auth Token
|
> Downloading from **Withheld Account**
|
||||||
|
|
||||||
1. Go to [X's website](https://www.x.com/)
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 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 will trigger a **rate limit**, and the media retrieval will fail.
|
||||||
|
|
||||||
|
1. Go to [Twitter's website](https://www.x.com/)
|
||||||
2. Log into your account
|
2. Log into your account
|
||||||
3. Open the Developer Tools by pressing `F12`
|
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
|
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
|
6. Do not log out of your account, as a new `auth_token` will be generated by Twitter
|
||||||
7. Close your browser
|
|
||||||
|
|
||||||

|
> X.com Auth Token Grabber
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
> Developer Tools
|
||||||
|
|
||||||
|

|
||||||
+762
-262
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"version": "1.7"
|
||||||
|
}
|
||||||
Reference in new issue
Block a user