Compare commits

..
22 Commits
Author SHA1 Message Date
afkarxyz befe838e79 v3.4 2025-08-08 15:20:30 +07:00
afkarxyz b534bc278e Update README.md 2025-08-08 15:17:31 +07:00
afkarxyz 2e882635eb v3.3 2025-07-31 12:08:25 +07:00
afkarxyz 5d5b778c8e v3.3 2025-07-30 05:26:56 +07:00
afkarxyz 7cf134f681 v3.3 2025-07-30 05:24:47 +07:00
afkarxyz 7d90eb7cb2 v3.3 2025-07-26 21:27:45 +07:00
afkarxyz 3d1fd7d1fb v3.3 2025-07-26 21:11:53 +07:00
afkarxyz c0885b1812 v3.2 2025-07-26 12:34:42 +07:00
afkarxyz 1ca5c613ae Update latest.json 2025-07-26 12:34:32 +07:00
afkarxyz 596ba9bb3c v3.2 2025-07-26 12:33:59 +07:00
afkarxyz a1cbb04402 v3.2 2025-07-26 12:33:58 +07:00
afkarxyz ddf6439893 v3.2 2025-07-26 12:27:48 +07:00
afkarxyz fed2bf7b0c Create latest.json 2025-07-26 12:24:54 +07:00
afkarxyz 241884de89 v3.2 2025-07-26 12:20:20 +07:00
afkarxyz 77b443ace0 v3.2 2025-07-26 11:55:30 +07:00
afkarxyz cd48b6f9bc Update README.md 2025-07-26 11:44:31 +07:00
afkarxyz 6f45b48047 v3.1 2025-07-19 05:45:26 +07:00
afkarxyz 7083c56c8b v3.1 2025-07-19 05:40:26 +07:00
afkarxyz 60cb3cbabd v3.1 2025-07-19 01:06:36 +07:00
afkarxyz b38bff238a . 2025-07-19 01:06:15 +07:00
afkarxyz d4d216ed6b v3.1 2025-07-19 01:04:35 +07:00
afkarxyz 129c007f6f v3.1 2025-07-18 23:42:12 +07:00
5 changed files with 4128 additions and 118 deletions

No files matched your search

+14 -23
View File
@@ -8,45 +8,42 @@
## 📥 Download
- **Windows**: [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.0/TwitterXMediaBatchDownloader.exe)
- **Linux**: [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.0/TwitterXMediaBatchDownloader)
- **Mac**: [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.0/TwitterXMediaBatchDownloader.app.zip)
- If you're familiar with **userscripts**, please install it [here](https://greasyfork.org/en/scripts/523157)
- [**Windows**](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.3/TwitterXMediaBatchDownloader_Windows.exe)
- [**Linux**](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.3/TwitterXMediaBatchDownloader_Linux)
- [**Mac**](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.3/TwitterXMediaBatchDownloader_Mac.app.zip)
- If you're familiar with **userscripts**, please install it [**here**](https://greasyfork.org/en/scripts/523157)
### The downloaded application won't run❓
🐧 **Solution (Ubuntu/Linux)**: Open your terminal and run:
```bash
chmod +x TwitterXMediaBatchDownloader
./TwitterXMediaBatchDownloader
chmod +x TwitterXMediaBatchDownloader_Linux
```
https://github.com/user-attachments/assets/2048555f-393e-469d-a8bd-4275e33a81bd
https://github.com/user-attachments/assets/ab65e53f-2986-4386-9e09-e4c8e33ec90b
🍎 **Solution (macOS)**: Open your terminal and run:
```bash
xattr -rd com.apple.quarantine ~/Downloads/TwitterXMediaBatchDownloader.app
xattr -rd com.apple.quarantine ~/Downloads/TwitterXMediaBatchDownloader_Mac.app
```
https://github.com/user-attachments/assets/f0fcd2ba-e1dd-4205-bda7-2b4154b982ee
https://github.com/user-attachments/assets/5f9a1cf6-a7a8-4943-ad71-d2831b406137
## ✨ Features
- Powered by `gallery-dl`, similar to `yt-dlp`
- **Bulk download**: Download multiple items at once
- **Bulk download**: Download multiple accounts 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
![image](https://github.com/user-attachments/assets/7295213a-d9ba-4d75-8359-d43907b74aef)
![image](https://github.com/user-attachments/assets/bae739f3-c6be-415f-8e9b-18cceae659f6)
![image](https://github.com/user-attachments/assets/67bb51ef-0051-4470-b89b-66f653093543)
![image](https://github.com/user-attachments/assets/9ccc945c-7318-4232-8ba3-9fbb636fa065)
![image](https://github.com/user-attachments/assets/cfb57b60-661d-4d82-a1f3-1e859a33e8c4)
## 🐧 Build Yourself (Ubuntu/Linux)
@@ -80,16 +77,10 @@ pip install pyinstaller
### 5. Build the Application
```bash
pyinstaller --onefile --windowed TwitterXMediaBatchDownloader.py
pyinstaller --onefile --windowed TwitterXMediaBatchDownloader_Linux.py
```
### 6. Run the Application
The compiled binary will be located in the `dist/` folder:
```bash
./dist/TwitterXMediaBatchDownloader
```
The compiled binary will be located in the `dist/` folder.
## 🍎 Build Yourself (macOS)
@@ -130,7 +121,7 @@ pip install pyinstaller
### 6. Build the Application
```bash
pyinstaller --onefile --windowed --icon=Archived/icon.icns TwitterXMediaBatchDownloader.py
pyinstaller --onefile --windowed --icon=Archived/icon.icns TwitterXMediaBatchDownloader_Mac.py
```
The `.app` bundle will be generated inside the `dist/` folder.
@@ -13,7 +13,7 @@ from packaging import version
from dataclasses import dataclass
from PyQt6.QtWidgets import (
QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit,
QLabel, QFileDialog, QListWidget, QTextEdit, QTabWidget, QAbstractItemView, QSpacerItem, QSizePolicy, QProgressBar, QCheckBox, QDialog,
QLabel, QFileDialog, QListWidget, QTextEdit, QTabWidget, QAbstractItemView, QProgressBar, QCheckBox, QDialog,
QDialogButtonBox, QComboBox, QListWidgetItem
)
from PyQt6.QtCore import Qt, QThread, pyqtSignal, QUrl, QTimer, QTime, QSettings, QSize
@@ -31,6 +31,8 @@ class Account:
media_type: str
profile_image: str = None
media_list: list = None
fetch_mode: str = 'all'
fetch_timestamp: str = None
class MetadataFetchWorker(QThread):
finished = pyqtSignal(dict)
@@ -313,26 +315,20 @@ class DownloadWorker(QThread):
class UpdateDialog(QDialog):
def __init__(self, current_version, new_version, parent=None):
super().__init__(parent)
self.setWindowTitle("Update Available")
self.setWindowTitle("Update Now")
self.setFixedWidth(400)
self.setModal(True)
layout = QVBoxLayout()
message = QLabel(f"A new version of Twitter/X Media Batch Downloader is available!\n\n"
f"Current version: v{current_version}\n"
f"New version: v{new_version}")
message = QLabel(f"Twitter/X Media Batch Downloader v{new_version} Available!")
message.setWordWrap(True)
layout.addWidget(message)
self.disable_check = QCheckBox("Turn off update checking")
self.disable_check.setCursor(Qt.CursorShape.PointingHandCursor)
layout.addWidget(self.disable_check)
button_box = QDialogButtonBox()
self.update_button = QPushButton("Update")
self.update_button = QPushButton("Check")
self.update_button.setCursor(Qt.CursorShape.PointingHandCursor)
self.cancel_button = QPushButton("Cancel")
self.cancel_button = QPushButton("Later")
self.cancel_button.setCursor(Qt.CursorShape.PointingHandCursor)
button_box.addButton(self.update_button, QDialogButtonBox.ButtonRole.AcceptRole)
@@ -348,7 +344,7 @@ class UpdateDialog(QDialog):
class TwitterMediaDownloaderGUI(QWidget):
def __init__(self):
super().__init__()
self.current_version = "3.1"
self.current_version = "3.4"
self.accounts = []
self.temp_dir = os.path.join(tempfile.gettempdir(), "twitterxmediabatchdownloader")
os.makedirs(self.temp_dir, exist_ok=True)
@@ -390,6 +386,42 @@ class TwitterMediaDownloaderGUI(QWidget):
if self.check_for_updates:
QTimer.singleShot(0, self.check_updates)
def get_time_ago(self, timestamp_str):
if not timestamp_str:
return "Unknown"
try:
fetch_time = datetime.fromisoformat(timestamp_str.replace('Z', '+00:00'))
now = datetime.now(fetch_time.tzinfo) if fetch_time.tzinfo else datetime.now()
diff = now - fetch_time
days = diff.days
hours = diff.seconds // 3600
minutes = (diff.seconds % 3600) // 60
if days > 0:
return f"{days} day{'s' if days != 1 else ''} ago"
elif hours > 0:
return f"{hours} hour{'s' if hours != 1 else ''} ago"
elif minutes > 0:
return f"{minutes} minute{'s' if minutes != 1 else ''} ago"
else:
return "Just now"
except:
return "Unknown"
def format_fetch_info(self, timestamp_str):
if not timestamp_str:
return "Fetched: Unknown"
try:
fetch_time = datetime.fromisoformat(timestamp_str.replace('Z', '+00:00'))
formatted_datetime = fetch_time.strftime("%Y/%m/%d • %H:%M")
age = self.get_time_ago(timestamp_str)
return f"Fetched: {formatted_datetime} ({age})"
except:
return "Fetched: Unknown"
def check_updates(self):
try:
response = requests.get("https://raw.githubusercontent.com/afkarxyz/Twitter-X-Media-Batch-Downloader/refs/heads/main/version.json")
@@ -401,15 +433,11 @@ class TwitterMediaDownloaderGUI(QWidget):
dialog = UpdateDialog(self.current_version, new_version, self)
result = dialog.exec()
if dialog.disable_check.isChecked():
self.settings.setValue('check_for_updates', False)
self.check_for_updates = False
if result == QDialog.DialogCode.Accepted:
QDesktopServices.openUrl(QUrl("https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases"))
except Exception as e:
print(f"Error checking for updates: {e}")
pass
def reset_state(self):
self.accounts.clear()
@@ -431,9 +459,8 @@ class TwitterMediaDownloaderGUI(QWidget):
def initUI(self):
self.setWindowTitle('Twitter/X Media Batch Downloader')
self.setMinimumWidth(650)
self.setMinimumHeight(350)
self.resize(650, 350)
self.setMinimumWidth(670)
self.setMinimumHeight(350)
icon_path = os.path.join(os.path.dirname(__file__), "icon.svg")
if os.path.exists(icon_path):
@@ -482,20 +509,18 @@ class TwitterMediaDownloaderGUI(QWidget):
self.account_list = QListWidget()
self.account_list.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
self.account_list.itemSelectionChanged.connect(self.update_button_states)
self.account_list.setIconSize(QSize(36, 36))
self.account_list.setIconSize(QSize(48, 48))
self.account_list.setWordWrap(True)
self.account_list.setStyleSheet("""
QListWidget {
background-color: palette(base);
border: 1px solid palette(mid);
border-radius: 4px;
padding: 0px;
padding: 4px;
outline: none;
}
QListWidget::item {
padding: 8px 12px;
margin: 2px 0px;
padding: 3px 6px;
margin: 0px 0px;
border: none;
border-radius: 4px;
outline: none;
}
QListWidget::item:selected {
@@ -508,7 +533,7 @@ class TwitterMediaDownloaderGUI(QWidget):
outline: none;
}
QListWidget::item:hover {
background-color: palette(midlight);
background-color: palette(highlight);
}
""")
@@ -524,22 +549,22 @@ class TwitterMediaDownloaderGUI(QWidget):
def setup_account_buttons(self):
self.btn_layout = QHBoxLayout()
self.download_selected_btn = QPushButton('Download Selected')
self.download_all_btn = QPushButton('Download All')
self.update_selected_btn = QPushButton('Update Selected')
self.remove_btn = QPushButton('Remove Selected')
self.clear_btn = QPushButton('Clear')
for btn in [self.download_selected_btn, self.download_all_btn, self.remove_btn, self.clear_btn]:
btn.setFixedWidth(150)
for btn in [self.download_selected_btn, self.update_selected_btn, self.remove_btn, self.clear_btn]:
btn.setMinimumWidth(120)
btn.setCursor(Qt.CursorShape.PointingHandCursor)
self.download_selected_btn.clicked.connect(self.download_selected)
self.download_all_btn.clicked.connect(self.download_all)
self.update_selected_btn.clicked.connect(self.update_selected)
self.remove_btn.clicked.connect(self.remove_selected_accounts)
self.clear_btn.clicked.connect(self.clear_accounts)
self.btn_layout.addStretch()
for btn in [self.download_selected_btn, self.download_all_btn, self.remove_btn, self.clear_btn]:
self.btn_layout.addWidget(btn)
for btn in [self.download_selected_btn, self.update_selected_btn, self.remove_btn, self.clear_btn]:
self.btn_layout.addWidget(btn, 1)
self.btn_layout.addStretch()
def setup_process_tab(self):
@@ -567,8 +592,8 @@ class TwitterMediaDownloaderGUI(QWidget):
self.stop_btn = QPushButton('Stop')
self.pause_resume_btn = QPushButton('Pause')
self.stop_btn.setFixedWidth(150)
self.pause_resume_btn.setFixedWidth(150)
self.stop_btn.setFixedWidth(120)
self.pause_resume_btn.setFixedWidth(120)
self.stop_btn.setCursor(Qt.CursorShape.PointingHandCursor)
self.pause_resume_btn.setCursor(Qt.CursorShape.PointingHandCursor)
@@ -587,7 +612,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.stop_fetch_btn = QPushButton('Stop Fetch')
for btn in [self.next_batch_btn, self.auto_batch_btn, self.stop_fetch_btn]:
btn.setFixedWidth(150)
btn.setFixedWidth(120)
btn.setCursor(Qt.CursorShape.PointingHandCursor)
self.next_batch_btn.setToolTip("Fetch next batch manually")
@@ -636,6 +661,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.output_dir.setText(self.last_output_path)
self.output_dir.textChanged.connect(self.save_settings)
self.output_browse = QPushButton('Browse')
self.output_browse.setFixedWidth(100)
self.output_browse.setCursor(Qt.CursorShape.PointingHandCursor)
self.output_browse.clicked.connect(self.browse_output)
@@ -657,7 +683,7 @@ class TwitterMediaDownloaderGUI(QWidget):
auth_token_label = QLabel('Auth Token:')
self.auth_token_input = QLineEdit()
self.auth_token_input.setPlaceholderText("Enter your Twitter/X auth_token")
self.auth_token_input.setPlaceholderText("Enter Auth Token")
self.auth_token_input.setText(self.last_auth_token)
self.auth_token_input.textChanged.connect(self.save_settings)
self.auth_token_input.setClearButtonEnabled(True)
@@ -679,7 +705,7 @@ class TwitterMediaDownloaderGUI(QWidget):
first_row_layout = QHBoxLayout()
first_row_layout.setSpacing(5)
self.batch_checkbox = QCheckBox("Batch")
self.batch_checkbox = QCheckBox("Fetch Batch")
self.batch_checkbox.setCursor(Qt.CursorShape.PointingHandCursor)
self.batch_checkbox.setToolTip("Enable for accounts with thousands of media")
self.batch_checkbox.stateChanged.connect(self.handle_batch_checkbox)
@@ -745,7 +771,7 @@ class TwitterMediaDownloaderGUI(QWidget):
download_layout.addWidget(download_label)
batch_layout = QHBoxLayout()
batch_label = QLabel('Batch Size:')
batch_label = QLabel('Concurrent Downloads:')
self.download_batch_combo = QComboBox()
self.download_batch_combo.setCursor(Qt.CursorShape.PointingHandCursor)
@@ -764,7 +790,7 @@ class TwitterMediaDownloaderGUI(QWidget):
batch_layout.addWidget(self.download_batch_combo)
batch_layout.addWidget(self.convert_gif_checkbox)
self.gif_resolution_label = QLabel("GIF Quality:")
self.gif_resolution_label = QLabel("Converted GIF Quality:")
self.gif_resolution_combo = QComboBox()
self.gif_resolution_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.gif_resolution_combo.setFixedWidth(85)
@@ -797,53 +823,36 @@ class TwitterMediaDownloaderGUI(QWidget):
about_tab = QWidget()
about_layout = QVBoxLayout()
about_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
about_layout.setSpacing(3)
about_layout.setSpacing(15)
sections = [
("Check for Updates", "https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases"),
("Report an Issue", "https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/issues"),
("gallery-dl Repository", "https://github.com/mikf/gallery-dl")
("Check for Updates", "Check", "https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases"),
("Report an Issue", "Report", "https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/issues"),
("gallery-dl Repository", "Visit", "https://github.com/mikf/gallery-dl")
]
for title, url in sections:
for title, button_text, url in sections:
section_widget = QWidget()
section_layout = QVBoxLayout(section_widget)
section_layout.setSpacing(10)
section_layout.setContentsMargins(0, 0, 0, 0)
label = QLabel(title)
label.setStyleSheet("color: palette(text); font-weight: bold;")
label.setStyleSheet("font-weight: bold;")
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
section_layout.addWidget(label)
button = QPushButton("Click Here!")
button.setFixedWidth(150)
button.setStyleSheet("""
QPushButton {
background-color: palette(button);
color: palette(button-text);
border: 1px solid palette(mid);
padding: 6px;
border-radius: 15px;
}
QPushButton:hover {
background-color: palette(light);
}
QPushButton:pressed {
background-color: palette(midlight);
}
""")
button = QPushButton(button_text)
button.setFixedSize(100, 25)
button.setCursor(Qt.CursorShape.PointingHandCursor)
button.clicked.connect(lambda _, url=url: QDesktopServices.openUrl(QUrl(url if url.startswith(('http://', 'https://')) else f'https://{url}')))
section_layout.addWidget(button, alignment=Qt.AlignmentFlag.AlignCenter)
about_layout.addWidget(section_widget)
if sections.index((title, url)) < len(sections) - 1:
spacer = QSpacerItem(20, 6, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed)
about_layout.addItem(spacer)
section_layout.addWidget(button, alignment=Qt.AlignmentFlag.AlignCenter)
footer_label = QLabel("v3.1 | gallery-dl v1.30.0 | July 2025")
footer_label.setStyleSheet("font-size: 12px; margin-top: 10px;")
about_layout.addWidget(section_widget)
footer_label = QLabel(f"v{self.current_version} | gallery-dl v1.30.2 | August 2025")
about_layout.addWidget(footer_label, alignment=Qt.AlignmentFlag.AlignCenter)
about_tab.setLayout(about_layout)
self.tab_widget.addTab(about_tab, "About")
@@ -936,7 +945,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.twitter_url.setText(last_username_url)
except Exception as e:
print(f"Error loading settings: {e}")
pass
def handle_batch_checkbox(self, state):
if not hasattr(self, 'size_label') or not hasattr(self, 'batch_size_combo'):
@@ -1054,7 +1063,9 @@ class TwitterMediaDownloaderGUI(QWidget):
posts=posts,
media_type=media_type,
profile_image=profile_image_url,
media_list=timeline
media_list=timeline,
fetch_mode='batch' if cached_data.get('is_batch', False) else 'all',
fetch_timestamp=cached_data.get('fetch_timestamp')
)
self.accounts.append(account)
@@ -1131,7 +1142,9 @@ class TwitterMediaDownloaderGUI(QWidget):
following=following,
posts=posts,
media_type=media_type,
media_list=timeline
media_list=timeline,
fetch_mode='batch' if cached_data.get('is_batch', False) else 'all',
fetch_timestamp=cached_data.get('fetch_timestamp')
)
self.accounts.append(account)
@@ -1216,7 +1229,9 @@ class TwitterMediaDownloaderGUI(QWidget):
posts=posts,
media_type=media_type,
profile_image=profile_image_url,
media_list=timeline
media_list=timeline,
fetch_mode='batch' if self.batch_mode else 'all',
fetch_timestamp=datetime.now().isoformat()
)
self.accounts.append(account)
@@ -1226,7 +1241,9 @@ class TwitterMediaDownloaderGUI(QWidget):
updated_data = {
'account_info': account_info,
'timeline': existing_account.media_list,
'metadata': metadata
'metadata': metadata,
'is_batch': self.batch_mode,
'fetch_timestamp': existing_account.fetch_timestamp
}
self.save_cached_data(username, media_type, updated_data, is_batch=self.batch_mode)
@@ -1264,7 +1281,12 @@ class TwitterMediaDownloaderGUI(QWidget):
self.log_output.append(f'All batches complete! Total: {total_items:,} media items for {username}')
self.twitter_url.clear()
self.tab_widget.setCurrentIndex(0)
if hasattr(self, 'accounts_to_update') and hasattr(self, 'current_update_index'):
self.current_update_index += 1
self.update_next_account()
else:
self.tab_widget.setCurrentIndex(0)
except Exception as e:
self.log_output.append(f'Error: {str(e)}')
self.update_account_list()
@@ -1281,6 +1303,10 @@ class TwitterMediaDownloaderGUI(QWidget):
self.enable_batch_buttons()
if hasattr(self, 'accounts_to_update') and hasattr(self, 'current_update_index'):
self.current_update_index += 1
self.update_next_account()
self.update_account_list()
def update_account_list(self):
@@ -1291,21 +1317,22 @@ class TwitterMediaDownloaderGUI(QWidget):
line1 = f"{i}. {account.username} ({account.nick})"
line2 = f"Followers: {account.followers:,} • Following: {account.following:,} • Posts: {account.posts:,} • {media_type_display}: {media_count:,}"
display_text = f"{line1}\n{line2}"
line3 = self.format_fetch_info(account.fetch_timestamp)
display_text = f"{line1}\n{line2}\n{line3}"
item = QListWidgetItem()
item.setText(display_text)
item.setSizeHint(QSize(0, 52))
item.setSizeHint(QSize(0, 70))
if account.profile_image:
if account.profile_image in self.profile_image_cache:
item.setIcon(QIcon(self.profile_image_cache[account.profile_image]))
else:
self.download_profile_image(account.profile_image)
placeholder = self.create_placeholder_icon(52)
placeholder = self.create_placeholder_icon(48)
if placeholder:
item.setIcon(QIcon(placeholder))
else:
placeholder = self.create_placeholder_icon(52)
placeholder = self.create_placeholder_icon(48)
if placeholder:
item.setIcon(QIcon(placeholder))
@@ -1313,7 +1340,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.update_button_states()
def create_placeholder_icon(self, size=36):
def create_placeholder_icon(self, size=48):
pixmap = QPixmap(size, size)
pixmap.fill(Qt.GlobalColor.transparent)
@@ -1332,7 +1359,7 @@ class TwitterMediaDownloaderGUI(QWidget):
painter.end()
return pixmap
def create_square_pixmap(self, original_pixmap, size=36):
def create_square_pixmap(self, original_pixmap, size=48):
if original_pixmap.isNull():
return self.create_placeholder_icon(size)
@@ -1372,7 +1399,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.pending_downloads[url] = reply
reply.finished.connect(lambda: self.on_profile_image_downloaded(reply, url))
except Exception as e:
print(f"Error downloading profile image: {e}")
pass
def on_profile_image_downloaded(self, reply, image_url):
try:
@@ -1380,7 +1407,7 @@ class TwitterMediaDownloaderGUI(QWidget):
data = reply.readAll()
pixmap = QPixmap()
if pixmap.loadFromData(data):
square_pixmap = self.create_square_pixmap(pixmap, 52)
square_pixmap = self.create_square_pixmap(pixmap, 48)
self.profile_image_cache[image_url] = square_pixmap
self.update_account_list()
@@ -1389,21 +1416,23 @@ class TwitterMediaDownloaderGUI(QWidget):
del self.pending_downloads[image_url]
except Exception as e:
print(f"Error processing profile image: {e}")
pass
finally:
reply.deleteLater()
def update_button_states(self):
has_accounts = len(self.accounts) > 0
self.download_selected_btn.setEnabled(has_accounts)
self.download_all_btn.setEnabled(has_accounts)
self.remove_btn.setEnabled(has_accounts)
has_selected = len(self.account_list.selectedItems()) > 0
self.download_selected_btn.setEnabled(has_accounts and has_selected)
self.update_selected_btn.setEnabled(has_accounts and has_selected)
self.remove_btn.setEnabled(has_accounts and has_selected)
self.clear_btn.setEnabled(has_accounts)
if has_accounts:
self.download_selected_btn.show()
self.download_all_btn.show()
self.update_selected_btn.show()
self.remove_btn.show()
self.clear_btn.show()
else:
@@ -1412,7 +1441,7 @@ class TwitterMediaDownloaderGUI(QWidget):
def hide_account_buttons(self):
buttons = [
self.download_selected_btn,
self.download_all_btn,
self.update_selected_btn,
self.remove_btn,
self.clear_btn
]
@@ -1429,6 +1458,113 @@ class TwitterMediaDownloaderGUI(QWidget):
def download_all(self):
self.download_accounts(range(len(self.accounts)))
def update_selected(self):
selected_items = self.account_list.selectedItems()
if not selected_items:
self.log_output.append('Warning: Please select accounts to update.')
return
selected_accounts = []
for item in selected_items:
index = self.account_list.row(item)
if index < len(self.accounts):
selected_accounts.append(self.accounts[index])
if not selected_accounts:
return
self.tab_widget.setCurrentIndex(1)
self.log_output.clear()
self.log_output.append(f'Starting update for {len(selected_accounts)} account(s)...')
self.accounts_to_update = selected_accounts.copy()
self.current_update_index = 0
self.update_next_account()
def update_next_account(self):
if not hasattr(self, 'accounts_to_update') or self.current_update_index >= len(self.accounts_to_update):
self.log_output.append('All selected accounts have been updated!')
if hasattr(self, 'accounts_to_update'):
delattr(self, 'accounts_to_update')
if hasattr(self, 'current_update_index'):
delattr(self, 'current_update_index')
return
account = self.accounts_to_update[self.current_update_index]
self.log_output.append(f'Updating account {self.current_update_index + 1}/{len(self.accounts_to_update)}: {account.username} ({account.media_type})')
self.update_account(account)
def update_account(self, account):
original_batch_mode = self.batch_mode
original_batch_size = self.batch_size
original_media_type = self.media_type_combo.currentData()
self.batch_mode = (account.fetch_mode == 'batch')
if self.batch_mode:
self.batch_size = self.settings.value('batch_size', 100, type=int)
for i in range(self.media_type_combo.count()):
if self.media_type_combo.itemData(i) == account.media_type:
self.media_type_combo.setCurrentIndex(i)
break
self.twitter_url.setText(account.username)
self.tab_widget.setCurrentIndex(1)
self.log_output.append(f'Updating {account.username} ({account.media_type}) using {account.fetch_mode} mode...')
username = account.username
media_type = account.media_type
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, media_type, is_batch=is_batch)
try:
if os.path.exists(cache_file):
os.remove(cache_file)
self.log_output.append(f'Removed existing cache: {os.path.basename(cache_file)}')
except Exception as e:
self.log_output.append(f'Warning: Could not remove cache {os.path.basename(cache_file)}: {str(e)}')
for i, existing_account in enumerate(self.accounts):
if existing_account.username == account.username and existing_account.media_type == account.media_type:
self.accounts.pop(i)
break
self.update_account_list()
self.start_fetch_process(username, media_type)
self.batch_mode = original_batch_mode
self.batch_size = original_batch_size
for i in range(self.media_type_combo.count()):
if self.media_type_combo.itemData(i) == original_media_type:
self.media_type_combo.setCurrentIndex(i)
break
def start_fetch_process(self, username, media_type):
if not self.auth_token_input.text().strip():
self.log_output.append("Error: Please enter your auth token")
return
self.current_page = 0
self.disable_batch_buttons()
self.worker = MetadataFetchWorker(
username,
media_type,
batch_mode=self.batch_mode,
batch_size=self.batch_size if self.batch_mode else 0,
page=0
)
self.worker.auth_token = self.auth_token_input.text().strip()
self.worker.finished.connect(lambda data: self.on_metadata_fetched(data, username, media_type))
self.worker.error.connect(self.on_metadata_error)
self.worker.start()
def download_accounts(self, indices):
self.log_output.clear()
outpath = self.output_dir.text()
@@ -1467,7 +1603,7 @@ class TwitterMediaDownloaderGUI(QWidget):
def update_ui_for_download_start(self, account_count):
self.download_selected_btn.setEnabled(False)
self.download_all_btn.setEnabled(False)
self.update_selected_btn.setEnabled(False)
self.stop_btn.show()
self.pause_resume_btn.show()
@@ -1551,7 +1687,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.stop_timer()
self.download_selected_btn.setEnabled(True)
self.download_all_btn.setEnabled(True)
self.update_selected_btn.setEnabled(True)
if (self.batch_mode and self.current_fetch_metadata and
self.current_fetch_metadata.get('has_more', False) and not self.is_auto_fetching):
@@ -1698,7 +1834,7 @@ class TwitterMediaDownloaderGUI(QWidget):
def show_account_buttons(self):
self.download_selected_btn.show()
self.download_all_btn.show()
self.update_selected_btn.show()
self.remove_btn.show()
self.clear_btn.show()
@@ -1707,6 +1843,7 @@ def main():
os.chdir(os.path.dirname(sys.executable))
app = QApplication(sys.argv)
app.setStyle('fusion')
window = TwitterMediaDownloaderGUI()
window.show()
sys.exit(app.exec())
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -1,3 +1,3 @@
{
"version": "3.0"
"version": "3.3"
}