Compare commits

...
18 Commits
Author SHA1 Message Date
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
3 changed files with 99 additions and 109 deletions

No files matched your search

+9 -11
View File
@@ -3,34 +3,32 @@
![TwitterXMediaBatchDownloader](https://github.com/user-attachments/assets/354d7470-c01c-4aa6-9da1-ea6c42d27330) ![TwitterXMediaBatchDownloader](https://github.com/user-attachments/assets/354d7470-c01c-4aa6-9da1-ea6c42d27330)
<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.5/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
## 🖼️ Screenshots ## 🖼️ Screenshots
![image](https://github.com/user-attachments/assets/7c5ebdda-c558-49ed-9f16-a6060b52f6f8) ![image](https://github.com/user-attachments/assets/ca8b6019-505e-4fb0-b1c5-52b7bcc892b4)
![python_7NZpAQ8RQi](https://github.com/user-attachments/assets/9982e4f5-a4b2-4d1b-9481-7bf7db700663) ![image](https://github.com/user-attachments/assets/8297f150-d581-4bb0-b80e-98d44aec18b5)
![image](https://github.com/user-attachments/assets/1ef4ec73-c77b-433a-ac79-f0df5be36bd1) ![image](https://github.com/user-attachments/assets/1f310499-0b03-4daf-ad83-e38cee22ce0c)
![image](https://github.com/user-attachments/assets/bbc28a59-c734-4103-a7b8-05b3793f9da8) ![image](https://github.com/user-attachments/assets/e30f4c74-988c-4cd2-a1b2-2b72add1ac6e)
> [!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 +36,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, try enabling Batch mode.
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
+89 -97
View File
@@ -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.5"
self.setWindowTitle("Twitter/X Media Batch Downloader") self.setWindowTitle("Twitter/X Media Batch Downloader")
self.settings = QSettings('TwitterMediaDownloader', 'Settings') self.settings = QSettings('TwitterMediaDownloader', 'Settings')
@@ -370,8 +341,7 @@ class TwitterMediaDownloaderGUI(QMainWindow):
self.tab_widget.addTab(self.main_tab, "Main") self.tab_widget.addTab(self.main_tab, "Main")
self.tab_widget.addTab(self.settings_tab, "Settings") self.tab_widget.addTab(self.settings_tab, "Settings")
self.main_layout.addWidget(self.tab_widget) self.main_layout.addWidget(self.tab_widget)
self.input_widget = QWidget() self.input_widget = QWidget()
input_layout = QVBoxLayout(self.input_widget) input_layout = QVBoxLayout(self.input_widget)
input_layout.setSpacing(10) input_layout.setSpacing(10)
@@ -430,19 +400,14 @@ 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")
self.batch_checkbox.stateChanged.connect(self.handle_batch_checkbox) self.batch_checkbox.stateChanged.connect(self.handle_batch_checkbox)
first_row_layout.addWidget(self.batch_checkbox) first_row_layout.addWidget(self.batch_checkbox)
size_label = QLabel("Size:") self.size_label = QLabel("Size:")
first_row_layout.addWidget(size_label) first_row_layout.addWidget(self.size_label)
self.batch_size_combo = QComboBox() self.batch_size_combo = QComboBox()
self.batch_size_combo.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) self.batch_size_combo.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
@@ -452,6 +417,9 @@ class TwitterMediaDownloaderGUI(QMainWindow):
self.batch_size_combo.setCurrentIndex(1) self.batch_size_combo.setCurrentIndex(1)
first_row_layout.addWidget(self.batch_size_combo) first_row_layout.addWidget(self.batch_size_combo)
self.size_label.hide()
self.batch_size_combo.hide()
first_row_layout.addSpacing(5) first_row_layout.addSpacing(5)
timeline_label = QLabel("Timeline Type:") timeline_label = QLabel("Timeline Type:")
@@ -493,7 +461,7 @@ class TwitterMediaDownloaderGUI(QMainWindow):
self.settings_tab_layout.addWidget(download_settings_label) self.settings_tab_layout.addWidget(download_settings_label)
batch_download_item_layout = QHBoxLayout() batch_download_item_layout = QHBoxLayout()
batch_download_label = QLabel("Batch Download Items:") batch_download_label = QLabel("Batch Size:")
self.download_batch_combo = QComboBox() self.download_batch_combo = QComboBox()
self.download_batch_combo.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) self.download_batch_combo.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
self.download_batch_combo.setFixedWidth(80) self.download_batch_combo.setFixedWidth(80)
@@ -509,8 +477,8 @@ class TwitterMediaDownloaderGUI(QMainWindow):
filename_layout = QHBoxLayout() filename_layout = QHBoxLayout()
filename_label = QLabel("Filename Format:") filename_label = QLabel("Filename Format:")
self.format_username = QRadioButton("Username - Post Date") self.format_username = QRadioButton("Username - Date")
self.format_date = QRadioButton("Post Date - Username") self.format_date = QRadioButton("Date - Username")
self.format_username.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) self.format_username.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
self.format_date.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) self.format_date.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
filename_layout.addWidget(filename_label) filename_layout.addWidget(filename_label)
@@ -625,8 +593,18 @@ class TwitterMediaDownloaderGUI(QMainWindow):
bottom_layout = QHBoxLayout() bottom_layout = QHBoxLayout()
status_container = QWidget()
status_layout = QHBoxLayout(status_container)
status_layout.setContentsMargins(0, 0, 0, 0)
status_layout.setSpacing(5)
self.version_label = QLabel("v2.6 (gallery-dl v1.29.7)")
status_layout.addWidget(self.version_label)
self.status_label = QLabel("") self.status_label = QLabel("")
bottom_layout.addWidget(self.status_label, stretch=1) status_layout.addWidget(self.status_label, stretch=1)
bottom_layout.addWidget(status_container, stretch=1)
self.update_button = QPushButton() self.update_button = QPushButton()
icon_path = os.path.join(os.path.dirname(__file__), "update.svg") icon_path = os.path.join(os.path.dirname(__file__), "update.svg")
@@ -664,38 +642,36 @@ class TwitterMediaDownloaderGUI(QMainWindow):
self.auto_batch_button.clicked.disconnect(self.stop_auto_batch) self.auto_batch_button.clicked.disconnect(self.stop_auto_batch)
self.auto_batch_button.clicked.connect(self.start_auto_batch) self.auto_batch_button.clicked.connect(self.start_auto_batch)
self.next_batch_button.setEnabled(True) self.next_batch_button.setEnabled(True)
self.status_label.setText(f"Auto batch stopped. Total: {len(self.media_info['timeline']):,} media items") self.set_status_text(f"Auto batch stopped. Total: {len(self.media_info['timeline']):,} media items")
def fetch_next_batch_auto(self): def fetch_next_batch_auto(self):
if not self.auto_batch_running: if not self.auto_batch_running:
return return
if not self.media_info: if not self.media_info:
self.status_label.setText("No profile information available") self.set_status_text("No profile information available")
self.stop_auto_batch() self.stop_auto_batch()
return return
username = self.url_input.text().strip() username = self.url_input.text().strip()
auth_token = self.auth_input.text().strip() auth_token = self.auth_input.text().strip()
if not username or not auth_token: if not username or not auth_token:
self.status_label.setText("Username or auth token missing") self.set_status_text("Username or auth token missing")
self.stop_auto_batch() self.stop_auto_batch()
return return
self.current_page += 1 self.current_page += 1
self.status_label.setText(f"Auto fetching batch {self.current_page + 1}...") self.set_status_text(f"Auto fetching batch {self.current_page + 1}...")
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
@@ -712,7 +688,7 @@ class TwitterMediaDownloaderGUI(QMainWindow):
timeline = info.get('timeline', []) timeline = info.get('timeline', [])
if not timeline: if not timeline:
self.status_label.setText("No more media items found") self.set_status_text("No more media items found")
self.stop_auto_batch() self.stop_auto_batch()
self.next_batch_button.hide() self.next_batch_button.hide()
return return
@@ -725,28 +701,34 @@ class TwitterMediaDownloaderGUI(QMainWindow):
media_count = len(self.media_info['timeline']) media_count = len(self.media_info['timeline'])
new_items = len(timeline) new_items = len(timeline)
self.status_label.setText(f"Auto batch: Added {new_items:,} items. Total: {media_count:,} media items") self.set_status_text(f"Auto batch: Added {new_items:,} items. Total: {media_count:,} media items")
has_more = info.get('metadata', {}).get('has_more', False) has_more = info.get('metadata', {}).get('has_more', False)
if not has_more: if not has_more:
self.stop_auto_batch() self.stop_auto_batch()
self.next_batch_button.hide() self.next_batch_button.hide()
self.status_label.setText(f"Auto batch complete! All {media_count:,} media items fetched. No more items available.") self.set_status_text(f"Auto batch complete! All {media_count:,} media items fetched. No more items available.")
return return
QTimer.singleShot(500, self.fetch_next_batch_auto) QTimer.singleShot(500, self.fetch_next_batch_auto)
except Exception as e: except Exception as e:
self.status_label.setText(f"Error processing auto batch: {str(e)}") self.set_status_text(f"Error processing auto batch: {str(e)}")
self.stop_auto_batch() self.stop_auto_batch()
def handle_auto_batch_error(self, error): def handle_auto_batch_error(self, error):
self.status_label.setText(f"Auto batch error: {error}") self.set_status_text(f"Auto batch error: {error}")
self.stop_auto_batch() self.stop_auto_batch()
def handle_batch_checkbox(self, state): def handle_batch_checkbox(self, state):
if self.batch_checkbox.isChecked():
self.size_label.show()
self.batch_size_combo.show()
else:
self.size_label.hide()
self.batch_size_combo.hide()
if hasattr(self, 'media_info') and self.media_info: if hasattr(self, 'media_info') and self.media_info:
if state == Qt.CheckState.Checked and self.media_info.get('metadata', {}).get('has_more', False): if self.batch_checkbox.isChecked() and self.media_info.get('metadata', {}).get('has_more', False):
self.next_batch_button.show() self.next_batch_button.show()
self.auto_batch_button.show() self.auto_batch_button.show()
else: else:
@@ -764,7 +746,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 +759,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,20 +791,29 @@ 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)
self.batch_checkbox.setChecked(batch_mode) self.batch_checkbox.setChecked(batch_mode)
self.batch_checkbox.blockSignals(False) self.batch_checkbox.blockSignals(False)
# Set visibility of batch size elements based on saved batch mode
if batch_mode:
self.size_label.show()
self.batch_size_combo.show()
self.download_size_label.show()
self.download_batch_combo.show()
else:
self.size_label.hide()
self.batch_size_combo.hide()
self.download_size_label.hide()
self.download_batch_combo.hide()
fetch_batch_size = str(self.settings.value('fetch_batch_size', '100')) fetch_batch_size = str(self.settings.value('fetch_batch_size', '100'))
index = self.batch_size_combo.findText(fetch_batch_size) index = self.batch_size_combo.findText(fetch_batch_size)
if index >= 0: if index >= 0:
self.batch_size_combo.setCurrentIndex(index) self.batch_size_combo.setCurrentIndex(index)
download_batch_size = str(self.settings.value('download_batch_size', '25')) download_batch_size = str(self.settings.value('download_batch_size', '25'))
index = self.download_batch_combo.findText(download_batch_size) index = self.download_batch_combo.findText(download_batch_size)
if index >= 0: if index >= 0:
@@ -854,24 +843,30 @@ class TwitterMediaDownloaderGUI(QMainWindow):
else: else:
subprocess.run(['xdg-open', output_dir]) subprocess.run(['xdg-open', output_dir])
def set_status_text(self, text):
self.status_label.setText(text)
if text:
self.version_label.hide()
else:
self.version_label.show()
def fetch_metadata(self): def fetch_metadata(self):
self.current_page = 0 self.current_page = 0
username = self.url_input.text().strip() username = self.url_input.text().strip()
if not username: if not username:
self.status_label.setText("Please enter a username or URL") self.set_status_text("Please enter a username or URL")
return return
auth_token = self.auth_input.text().strip() auth_token = self.auth_input.text().strip()
if not auth_token: if not auth_token:
self.status_label.setText("Please enter your auth token") self.set_status_text("Please enter your auth token")
return return
self.fetch_button.setEnabled(False) self.fetch_button.setEnabled(False)
self.status_label.setText("Fetching profile information...") self.set_status_text("Fetching profile information...")
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 +874,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
@@ -891,30 +885,28 @@ class TwitterMediaDownloaderGUI(QMainWindow):
def fetch_next_batch(self): def fetch_next_batch(self):
if not self.media_info: if not self.media_info:
self.status_label.setText("No profile information available") self.set_status_text("No profile information available")
return return
username = self.url_input.text().strip() username = self.url_input.text().strip()
auth_token = self.auth_input.text().strip() auth_token = self.auth_input.text().strip()
if not username or not auth_token: if not username or not auth_token:
self.status_label.setText("Username or auth token missing") self.set_status_text("Username or auth token missing")
return return
self.current_page += 1 self.current_page += 1
self.next_batch_button.setEnabled(False) self.next_batch_button.setEnabled(False)
self.status_label.setText(f"Fetching batch {self.current_page + 1}...") self.set_status_text(f"Fetching batch {self.current_page + 1}...")
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
@@ -931,7 +923,7 @@ class TwitterMediaDownloaderGUI(QMainWindow):
timeline = info.get('timeline', []) timeline = info.get('timeline', [])
if not timeline: if not timeline:
self.status_label.setText("No more media items found") self.set_status_text("No more media items found")
self.next_batch_button.setEnabled(True) self.next_batch_button.setEnabled(True)
return return
@@ -943,17 +935,17 @@ class TwitterMediaDownloaderGUI(QMainWindow):
media_count = len(self.media_info['timeline']) media_count = len(self.media_info['timeline'])
new_items = len(timeline) new_items = len(timeline)
self.status_label.setText(f"Added {new_items:,} items. Total: {media_count:,} media items") self.set_status_text(f"Added {new_items:,} items. Total: {media_count:,} media items")
self.next_batch_button.setEnabled(True) self.next_batch_button.setEnabled(True)
has_more = info.get('metadata', {}).get('has_more', False) has_more = info.get('metadata', {}).get('has_more', False)
if not has_more: if not has_more:
self.next_batch_button.hide() self.next_batch_button.hide()
self.auto_batch_button.hide() self.auto_batch_button.hide()
self.status_label.setText(f"All {media_count:,} media items fetched. No more items available.") self.set_status_text(f"All {media_count:,} media items fetched. No more items available.")
except Exception as e: except Exception as e:
self.status_label.setText(f"Error processing batch: {str(e)}") self.set_status_text(f"Error processing batch: {str(e)}")
self.next_batch_button.setEnabled(True) self.next_batch_button.setEnabled(True)
def handle_profile_info(self, info): def handle_profile_info(self, info):
@@ -964,15 +956,15 @@ 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.set_status_text("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.set_status_text("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
account_info = info.get('account_info', {}) account_info = info.get('account_info', {})
if not account_info: if not account_info:
self.status_label.setText("Failed to fetch profile information") self.set_status_text("Failed to fetch profile information")
self.fetch_button.setEnabled(True) self.fetch_button.setEnabled(True)
return return
@@ -1013,9 +1005,9 @@ class TwitterMediaDownloaderGUI(QMainWindow):
elif media_type == "gif": elif media_type == "gif":
media_type_str = "GIF" media_type_str = "GIF"
self.status_label.setText(f"Successfully fetched {media_count:,} {media_type_str} items") self.set_status_text(f"Successfully fetched {media_count:,} {media_type_str} items")
except Exception as ui_error: except Exception as ui_error:
self.status_label.setText(f"Error updating UI: {str(ui_error)}") self.set_status_text(f"Error updating UI: {str(ui_error)}")
return return
if is_withheld: if is_withheld:
@@ -1081,11 +1073,11 @@ class TwitterMediaDownloaderGUI(QMainWindow):
self.user_output_dir = os.path.join(output_base, self.clean_username) self.user_output_dir = os.path.join(output_base, self.clean_username)
os.makedirs(self.user_output_dir, exist_ok=True) os.makedirs(self.user_output_dir, exist_ok=True)
except Exception as dir_error: except Exception as dir_error:
self.status_label.setText(f"Error creating output directory: {str(dir_error)}") self.set_status_text(f"Error creating output directory: {str(dir_error)}")
return return
except Exception as e: except Exception as e:
self.status_label.setText(f"Error processing profile info: {str(e)}") self.set_status_text(f"Error processing profile info: {str(e)}")
self.fetch_button.setEnabled(True) self.fetch_button.setEnabled(True)
def update_profile_image(self, image_data): def update_profile_image(self, image_data):
@@ -1118,18 +1110,18 @@ 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.set_status_text("Please use the Userscript version for withheld accounts.")
else: else:
self.status_label.setText("Please check the 'Auth Token'.") self.set_status_text("Please check the 'Auth Token'.")
def start_download(self): def start_download(self):
if not self.media_info: if not self.media_info:
self.status_label.setText("Please fetch profile information first") self.set_status_text("Please fetch profile information first")
return return
auth_token = self.auth_input.text().strip() auth_token = self.auth_input.text().strip()
if not auth_token: if not auth_token:
self.status_label.setText("Please enter your auth token") self.set_status_text("Please enter your auth token")
return return
self.download_button.hide() self.download_button.hide()
@@ -1138,7 +1130,7 @@ class TwitterMediaDownloaderGUI(QMainWindow):
self.cancel_button.show() self.cancel_button.show()
self.progress_bar.show() self.progress_bar.show()
self.progress_bar.setValue(0) self.progress_bar.setValue(0)
self.status_label.setText("Starting download...") self.set_status_text("Starting download...")
filename_format = "username_date" if self.format_username.isChecked() else "date_username" filename_format = "username_date" if self.format_username.isChecked() else "date_username"
batch_size = int(self.download_batch_combo.currentText()) batch_size = int(self.download_batch_combo.currentText())
@@ -1155,7 +1147,7 @@ class TwitterMediaDownloaderGUI(QMainWindow):
self.worker.progress.connect(self.update_progress) self.worker.progress.connect(self.update_progress)
self.worker.finished.connect(self.download_finished) self.worker.finished.connect(self.download_finished)
self.worker.error.connect(self.download_error) self.worker.error.connect(self.download_error)
self.worker.status_update.connect(self.status_label.setText) self.worker.status_update.connect(self.set_status_text)
self.worker.start() self.worker.start()
def update_progress(self, value): def update_progress(self, value):
@@ -1163,7 +1155,7 @@ class TwitterMediaDownloaderGUI(QMainWindow):
def download_finished(self, message): def download_finished(self, message):
self.progress_bar.hide() self.progress_bar.hide()
self.status_label.setText(message) self.set_status_text(message)
self.open_button.show() self.open_button.show()
if self.batch_checkbox.isChecked() and self.media_info and self.media_info.get('metadata', {}).get('has_more', False): if self.batch_checkbox.isChecked() and self.media_info and self.media_info.get('metadata', {}).get('has_more', False):
@@ -1179,7 +1171,7 @@ class TwitterMediaDownloaderGUI(QMainWindow):
def download_error(self, error_message): def download_error(self, error_message):
self.progress_bar.hide() self.progress_bar.hide()
self.status_label.setText(f"Download error: {error_message}") self.set_status_text(f"Download error: {error_message}")
self.download_button.setText("Retry") self.download_button.setText("Retry")
self.download_button.show() self.download_button.show()
self.cancel_button.show() self.cancel_button.show()
@@ -1191,7 +1183,7 @@ class TwitterMediaDownloaderGUI(QMainWindow):
def cancel_clicked(self): def cancel_clicked(self):
if hasattr(self, 'worker') and self.worker.isRunning(): if hasattr(self, 'worker') and self.worker.isRunning():
self.worker.cancel() self.worker.cancel()
self.status_label.setText("Cancelling download...") self.set_status_text("Cancelling download...")
return return
self.profile_widget.hide() self.profile_widget.hide()
@@ -1203,7 +1195,7 @@ class TwitterMediaDownloaderGUI(QMainWindow):
self.cancel_button.hide() self.cancel_button.hide()
self.progress_bar.hide() self.progress_bar.hide()
self.progress_bar.setValue(0) self.progress_bar.setValue(0)
self.status_label.clear() self.set_status_text("")
self.media_info = None self.media_info = None
self.current_page = 0 self.current_page = 0
self.update_button.show() self.update_button.show()
+1 -1
View File
@@ -1,3 +1,3 @@
{ {
"version": "1.9" "version": "2.5"
} }