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 | |
|---|---|---|---|
|
|
4f6004a501 | ||
|
|
e7141cd8d1 | ||
|
|
4d6f4d904a | ||
|
|
4081e6aacf | ||
|
|
2b405a16a7 | ||
|
|
5e658c05d4 | ||
|
|
b26dd0b2af | ||
|
|
28422dcf1d |
No files matched your search
@@ -3,18 +3,17 @@
|
|||||||

|

|
||||||
|
|
||||||
<div align="center">
|
<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>
|
</div>
|
||||||
|
|
||||||
## 📥 Download
|
## 📥 Download
|
||||||
|
|
||||||
- Download the latest version of [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v1.9/TwitterXMediaBatchDownloader.exe)
|
- Download the latest version of [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v2.2/TwitterXMediaBatchDownloader.exe)
|
||||||
- If you're familiar with **userscripts**, please install it [here](https://greasyfork.org/en/scripts/523157-twitter-x-media-batch-downloader)
|
- If you're familiar with **userscripts**, please install it [here](https://greasyfork.org/en/scripts/523157)
|
||||||
|
|
||||||
## ✨ Features
|
## ✨ Features
|
||||||
|
|
||||||
- Powered by `gallery-dl`, similar to `yt-dlp`
|
- 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)
|
- **Choose media type**: All (Image + GIF + Video) or specific (Image/GIF/Video)
|
||||||
- Downloads in original quality
|
- Downloads in original quality
|
||||||
|
|
||||||
@@ -24,13 +23,10 @@
|
|||||||
|
|
||||||

|

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

|

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

|
|
||||||
|
|
||||||
> [!Important]
|
> [!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.
|
> Use **Batch** if the items to be downloaded are in the thousands.
|
||||||
> - Use **Batch** if the items to be downloaded are in the thousands.
|
|
||||||
|
|
||||||
## 🔑 How to Obtain Auth Token
|
## 🔑 How to Obtain Auth Token
|
||||||
|
|
||||||
@@ -38,7 +34,7 @@
|
|||||||
> - I suggest not using the **main account** to obtain the token.
|
> - I suggest not using the **main account** to obtain the token.
|
||||||
> - You can use https://temp-mail.io to register a Twitter account.
|
> - 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.**
|
> - 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.
|
||||||
|
|
||||||
1. Go to [Twitter's website](https://www.x.com/)
|
1. Go to [Twitter's website](https://www.x.com/)
|
||||||
2. Log into your account
|
2. Log into your account
|
||||||
|
|||||||
@@ -38,13 +38,12 @@ class MetadataFetcher(QThread):
|
|||||||
finished = pyqtSignal(dict)
|
finished = pyqtSignal(dict)
|
||||||
error = pyqtSignal(str)
|
error = pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, username, timeline_type='media', media_type='all', use_api=False, batch_mode=False, batch_size=100, page=0):
|
def __init__(self, username, timeline_type='media', media_type='all', batch_mode=False, batch_size=100, page=0):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.username = username
|
self.username = username
|
||||||
self.auth_token = None
|
self.auth_token = None
|
||||||
self.timeline_type = timeline_type
|
self.timeline_type = timeline_type
|
||||||
self.media_type = media_type
|
self.media_type = media_type
|
||||||
self.use_api = use_api
|
|
||||||
self.batch_mode = batch_mode
|
self.batch_mode = batch_mode
|
||||||
self.batch_size = batch_size
|
self.batch_size = batch_size
|
||||||
self.page = page
|
self.page = page
|
||||||
@@ -64,35 +63,10 @@ class MetadataFetcher(QThread):
|
|||||||
username = username.strip()
|
username = username.strip()
|
||||||
return username
|
return username
|
||||||
|
|
||||||
async def fetch_from_api(self, username, auth_token):
|
|
||||||
try:
|
|
||||||
async with aiohttp.ClientSession() as session:
|
|
||||||
if self.batch_mode:
|
|
||||||
url = f"https://gallerydl.vercel.app/metadata/{self.timeline_type}/{self.batch_size}/{self.page}/{self.media_type}/{username}/{auth_token}"
|
|
||||||
else:
|
|
||||||
url = f"https://gallerydl.vercel.app/metadata/{self.timeline_type}/{self.media_type}/{username}/{auth_token}"
|
|
||||||
|
|
||||||
async with session.get(url) as response:
|
|
||||||
if response.status == 200:
|
|
||||||
data = await response.json()
|
|
||||||
return data
|
|
||||||
else:
|
|
||||||
raise ValueError(f"API request failed with status {response.status}")
|
|
||||||
except Exception as e:
|
|
||||||
raise ValueError(f"API request failed: {str(e)}")
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
normalized = self.normalize_url(self.username)
|
normalized = self.normalize_url(self.username)
|
||||||
|
|
||||||
if self.use_api:
|
|
||||||
try:
|
|
||||||
data = asyncio.run(self.fetch_from_api(normalized, self.auth_token))
|
|
||||||
self.finished.emit(data)
|
|
||||||
return
|
|
||||||
except Exception as api_error:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
batch_size = self.batch_size if self.batch_mode else 0
|
batch_size = self.batch_size if self.batch_mode else 0
|
||||||
data = get_metadata(
|
data = get_metadata(
|
||||||
@@ -109,10 +83,7 @@ class MetadataFetcher(QThread):
|
|||||||
if not error_message or error_message == "None":
|
if not error_message or error_message == "None":
|
||||||
error_message = "Local gallery-dl error: None"
|
error_message = "Local gallery-dl error: None"
|
||||||
|
|
||||||
if self.use_api:
|
raise ValueError(f"Local gallery-dl error: {error_message}")
|
||||||
raise ValueError(f"Both API and local methods failed.\nAPI error: {str(api_error)}\nLocal error: {error_message}")
|
|
||||||
else:
|
|
||||||
raise ValueError(f"Local gallery-dl error: {error_message}")
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.error.emit(str(e))
|
self.error.emit(str(e))
|
||||||
@@ -302,7 +273,7 @@ class UpdateDialog(QDialog):
|
|||||||
class TwitterMediaDownloaderGUI(QMainWindow):
|
class TwitterMediaDownloaderGUI(QMainWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.current_version = "2.0"
|
self.current_version = "2.3"
|
||||||
self.setWindowTitle("Twitter/X Media Batch Downloader")
|
self.setWindowTitle("Twitter/X Media Batch Downloader")
|
||||||
|
|
||||||
self.settings = QSettings('TwitterMediaDownloader', 'Settings')
|
self.settings = QSettings('TwitterMediaDownloader', 'Settings')
|
||||||
@@ -430,11 +401,6 @@ class TwitterMediaDownloaderGUI(QMainWindow):
|
|||||||
first_row_layout = QHBoxLayout()
|
first_row_layout = QHBoxLayout()
|
||||||
first_row_layout.setSpacing(5)
|
first_row_layout.setSpacing(5)
|
||||||
|
|
||||||
self.use_api_checkbox = QCheckBox("Use API")
|
|
||||||
self.use_api_checkbox.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
|
|
||||||
self.use_api_checkbox.setToolTip("Use API instead of local gallery-dl")
|
|
||||||
first_row_layout.addWidget(self.use_api_checkbox)
|
|
||||||
|
|
||||||
self.batch_checkbox = QCheckBox("Batch")
|
self.batch_checkbox = QCheckBox("Batch")
|
||||||
self.batch_checkbox.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
|
self.batch_checkbox.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
|
||||||
self.batch_checkbox.setToolTip("Enable for accounts with thousands of media")
|
self.batch_checkbox.setToolTip("Enable for accounts with thousands of media")
|
||||||
@@ -688,14 +654,12 @@ class TwitterMediaDownloaderGUI(QMainWindow):
|
|||||||
|
|
||||||
timeline_type = self.timeline_type_combo.currentData()
|
timeline_type = self.timeline_type_combo.currentData()
|
||||||
media_type = self.media_type_combo.currentData()
|
media_type = self.media_type_combo.currentData()
|
||||||
use_api = self.use_api_checkbox.isChecked()
|
|
||||||
batch_size = int(self.batch_size_combo.currentText())
|
batch_size = int(self.batch_size_combo.currentText())
|
||||||
|
|
||||||
self.fetcher = MetadataFetcher(
|
self.fetcher = MetadataFetcher(
|
||||||
username,
|
username,
|
||||||
timeline_type,
|
timeline_type,
|
||||||
media_type,
|
media_type,
|
||||||
use_api,
|
|
||||||
True,
|
True,
|
||||||
batch_size,
|
batch_size,
|
||||||
self.current_page
|
self.current_page
|
||||||
@@ -764,7 +728,6 @@ class TwitterMediaDownloaderGUI(QMainWindow):
|
|||||||
self.format_username.toggled.connect(self.auto_save_settings)
|
self.format_username.toggled.connect(self.auto_save_settings)
|
||||||
self.media_type_combo.currentTextChanged.connect(self.auto_save_settings)
|
self.media_type_combo.currentTextChanged.connect(self.auto_save_settings)
|
||||||
self.timeline_type_combo.currentTextChanged.connect(self.auto_save_settings)
|
self.timeline_type_combo.currentTextChanged.connect(self.auto_save_settings)
|
||||||
self.use_api_checkbox.stateChanged.connect(self.auto_save_settings)
|
|
||||||
self.batch_checkbox.stateChanged.connect(self.auto_save_settings)
|
self.batch_checkbox.stateChanged.connect(self.auto_save_settings)
|
||||||
self.download_batch_combo.currentTextChanged.connect(self.auto_save_settings)
|
self.download_batch_combo.currentTextChanged.connect(self.auto_save_settings)
|
||||||
self.batch_size_combo.currentTextChanged.connect(self.auto_save_settings)
|
self.batch_size_combo.currentTextChanged.connect(self.auto_save_settings)
|
||||||
@@ -778,7 +741,6 @@ class TwitterMediaDownloaderGUI(QMainWindow):
|
|||||||
'username_date' if self.format_username.isChecked() else 'date_username')
|
'username_date' if self.format_username.isChecked() else 'date_username')
|
||||||
self.settings.setValue('media_type', self.media_type_combo.currentData())
|
self.settings.setValue('media_type', self.media_type_combo.currentData())
|
||||||
self.settings.setValue('timeline_type', self.timeline_type_combo.currentData())
|
self.settings.setValue('timeline_type', self.timeline_type_combo.currentData())
|
||||||
self.settings.setValue('use_api', self.use_api_checkbox.isChecked())
|
|
||||||
|
|
||||||
batch_mode = self.batch_checkbox.isChecked()
|
batch_mode = self.batch_checkbox.isChecked()
|
||||||
self.settings.setValue('batch_mode', batch_mode)
|
self.settings.setValue('batch_mode', batch_mode)
|
||||||
@@ -811,9 +773,6 @@ class TwitterMediaDownloaderGUI(QMainWindow):
|
|||||||
self.timeline_type_combo.setCurrentIndex(i)
|
self.timeline_type_combo.setCurrentIndex(i)
|
||||||
break
|
break
|
||||||
|
|
||||||
use_api = self.settings.value('use_api', False, type=bool)
|
|
||||||
self.use_api_checkbox.setChecked(use_api)
|
|
||||||
|
|
||||||
batch_mode = self.settings.value('batch_mode', False, type=bool)
|
batch_mode = self.settings.value('batch_mode', False, type=bool)
|
||||||
|
|
||||||
self.batch_checkbox.blockSignals(True)
|
self.batch_checkbox.blockSignals(True)
|
||||||
@@ -871,7 +830,6 @@ class TwitterMediaDownloaderGUI(QMainWindow):
|
|||||||
|
|
||||||
timeline_type = self.timeline_type_combo.currentData()
|
timeline_type = self.timeline_type_combo.currentData()
|
||||||
media_type = self.media_type_combo.currentData()
|
media_type = self.media_type_combo.currentData()
|
||||||
use_api = self.use_api_checkbox.isChecked()
|
|
||||||
batch_mode = self.batch_checkbox.isChecked()
|
batch_mode = self.batch_checkbox.isChecked()
|
||||||
batch_size = int(self.batch_size_combo.currentText()) if batch_mode else 100
|
batch_size = int(self.batch_size_combo.currentText()) if batch_mode else 100
|
||||||
|
|
||||||
@@ -879,7 +837,6 @@ class TwitterMediaDownloaderGUI(QMainWindow):
|
|||||||
username,
|
username,
|
||||||
timeline_type,
|
timeline_type,
|
||||||
media_type,
|
media_type,
|
||||||
use_api,
|
|
||||||
batch_mode,
|
batch_mode,
|
||||||
batch_size,
|
batch_size,
|
||||||
self.current_page
|
self.current_page
|
||||||
@@ -907,14 +864,12 @@ class TwitterMediaDownloaderGUI(QMainWindow):
|
|||||||
|
|
||||||
timeline_type = self.timeline_type_combo.currentData()
|
timeline_type = self.timeline_type_combo.currentData()
|
||||||
media_type = self.media_type_combo.currentData()
|
media_type = self.media_type_combo.currentData()
|
||||||
use_api = self.use_api_checkbox.isChecked()
|
|
||||||
batch_size = int(self.batch_size_combo.currentText())
|
batch_size = int(self.batch_size_combo.currentText())
|
||||||
|
|
||||||
self.fetcher = MetadataFetcher(
|
self.fetcher = MetadataFetcher(
|
||||||
username,
|
username,
|
||||||
timeline_type,
|
timeline_type,
|
||||||
media_type,
|
media_type,
|
||||||
use_api,
|
|
||||||
True,
|
True,
|
||||||
batch_size,
|
batch_size,
|
||||||
self.current_page
|
self.current_page
|
||||||
@@ -964,9 +919,9 @@ class TwitterMediaDownloaderGUI(QMainWindow):
|
|||||||
if 'error' in info:
|
if 'error' in info:
|
||||||
error_type = info['error']
|
error_type = info['error']
|
||||||
if error_type == "withheld":
|
if error_type == "withheld":
|
||||||
self.status_label.setText("Please enable the 'Use API' option.")
|
self.status_label.setText("Please use the Userscript version for withheld accounts.")
|
||||||
else:
|
else:
|
||||||
self.status_label.setText("Please check the 'Auth Token' value. Your account may be suspended.")
|
self.status_label.setText("Please check the 'Auth Token' value. Your account may be logged out, locked, or suspended.")
|
||||||
self.fetch_button.setEnabled(True)
|
self.fetch_button.setEnabled(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1118,7 +1073,7 @@ class TwitterMediaDownloaderGUI(QMainWindow):
|
|||||||
error_str = str(error)
|
error_str = str(error)
|
||||||
|
|
||||||
if '"error": "withheld"' in error_str or "withheld" in error_str:
|
if '"error": "withheld"' in error_str or "withheld" in error_str:
|
||||||
self.status_label.setText("Please enable the 'Use API' option.")
|
self.status_label.setText("please use userscripe version")
|
||||||
else:
|
else:
|
||||||
self.status_label.setText("Please check the 'Auth Token'.")
|
self.status_label.setText("Please check the 'Auth Token'.")
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"version": "1.9"
|
"version": "2.2"
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user