Compare commits

..
8 Commits
Author SHA1 Message Date
afkarxyz 64bd8b4b2d v3.7 2025-10-05 19:58:57 +07:00
afkarxyz 0f2427ad2b Chrome extension 2025-09-20 07:07:17 +07:00
afkarxyz 05e8230063 Update README.md 2025-09-14 16:11:32 +07:00
afkarxyz 83672f42b6 v3.6 2025-09-14 07:52:14 +07:00
afkarxyz affd36c968 v3.6 2025-09-14 07:45:19 +07:00
afkarxyz 281ea82656 Update README.md 2025-09-14 07:32:12 +07:00
afkarxyz aa003fab4c Update README.md 2025-09-14 07:30:12 +07:00
afkarxyz 805fade0fb v3.5 2025-09-11 22:31:16 +07:00
13 changed files with 1485 additions and 570 deletions

No files matched your search

+13 -92
View File
@@ -8,30 +8,16 @@
## 📥 Download ## 📥 Download
- [**Windows**](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.4/TwitterXMediaBatchDownloader_Windows.exe) - [**Windows**](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.6/TwitterXMediaBatchDownloader_Windows.exe)
- [**Linux**](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.4/TwitterXMediaBatchDownloader_Linux) - [**Linux**](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.6/TwitterXMediaBatchDownloader_Linux)
- [**Mac**](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.4/TwitterXMediaBatchDownloader_Mac.app.zip) - [**Mac**](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.6/TwitterXMediaBatchDownloader_Mac.app.zip)
- If you're familiar with **userscripts**, please install it [**here**](https://greasyfork.org/en/scripts/523157) - If you're familiar with **userscripts**, please install it [**here**](https://greasyfork.org/en/scripts/523157)
- The **Chrome extension** version is now available, please install it [**here**](https://www.patreon.com/posts/chrome-extension-139296789)
### The downloaded application won't run❓
🐧 **Solution (Ubuntu/Linux)**: Open your terminal and run:
```bash
chmod +x TwitterXMediaBatchDownloader_Linux
```
https://github.com/user-attachments/assets/cc7400ec-76dd-4519-848d-71a834b7ec95
🍎 **Solution (macOS)**: Open your terminal and run:
```bash
xattr -rd com.apple.quarantine ~/Downloads/TwitterXMediaBatchDownloader_Mac.app
```
https://github.com/user-attachments/assets/4b13c0b9-cf3a-48ce-ac35-a19007189ac8
## ✨ Features ## ✨ Features
- Powered by `gallery-dl`, similar to `yt-dlp` - Powered by `gallery-dl`, similar to `yt-dlp`
- **Bulk fetch**: Fetch multiple accounts at once
- **Bulk download**: Download multiple accounts at once - **Bulk download**: Download multiple accounts at once
- Media-type selection: All (Images + GIFs + Videos) or specific (Images / GIFs / Videos) - Media-type selection: All (Images + GIFs + Videos) or specific (Images / GIFs / Videos)
- **MP4 → GIF conversion:** Convert downloaded MP4 videos into GIF format - **MP4 → GIF conversion:** Convert downloaded MP4 videos into GIF format
@@ -41,88 +27,23 @@ https://github.com/user-attachments/assets/4b13c0b9-cf3a-48ce-ac35-a19007189ac8
![image](https://github.com/user-attachments/assets/bae739f3-c6be-415f-8e9b-18cceae659f6) ![image](https://github.com/user-attachments/assets/bae739f3-c6be-415f-8e9b-18cceae659f6)
![image](https://github.com/user-attachments/assets/cfb57b60-661d-4d82-a1f3-1e859a33e8c4) ![image](https://github.com/user-attachments/assets/a03ca334-779d-47d6-82dd-2edba28f5b76)
## 🐧 Build Yourself (Ubuntu/Linux) ### The downloaded application won't run❓
### 1. Install Required Packages 🐧 **Solution (Ubuntu/Linux)**: Open your terminal and run:
```bash ```bash
sudo apt install git python3-pip python3-venv chmod +x TwitterXMediaBatchDownloader_Linux
``` ```
![Linux](https://github.com/user-attachments/assets/fd04a4ee-3a6d-4e41-893d-1e3ed1a76186)
### 2. Clone the Repository 🍎 **Solution (macOS)**: Open your terminal and run:
```bash ```bash
git clone https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader.git xattr -rd com.apple.quarantine ~/Downloads/TwitterXMediaBatchDownloader_Mac.app
cd Twitter-X-Media-Batch-Downloader
``` ```
![Mac](https://github.com/user-attachments/assets/24731c2f-019f-496d-8f98-870997f15758)
### 3. Create and Activate a Virtual Environment
```bash
python3 -m venv .venv
source .venv/bin/activate
```
### 4. Install Python Dependencies
```bash
pip install -r requirements.txt
pip install pyinstaller
```
### 5. Build the Application
```bash
pyinstaller --onefile --windowed TwitterXMediaBatchDownloader_Linux.py
```
The compiled binary will be located in the `dist/` folder.
## 🍎 Build Yourself (macOS)
### 1. Install Homebrew (if not already installed)
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
### 2. Install Git and Python
```bash
brew install git python
```
### 3. Go to Downloads and Clone the Repository
```bash
cd ~/Downloads
git clone https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader.git
cd Twitter-X-Media-Batch-Downloader
```
### 4. Create and Activate a Virtual Environment
```bash
python3 -m venv .venv
source .venv/bin/activate
```
### 5. Install Python Dependencies
```bash
pip install -r requirements.txt
pip install pyinstaller
```
### 6. Build the Application
```bash
pyinstaller --onefile --windowed --icon=Archived/icon.icns TwitterXMediaBatchDownloader_Mac.py
```
The `.app` bundle will be generated inside the `dist/` folder.
## 🔑 How to Obtain Auth Token ## 🔑 How to Obtain Auth Token
+488 -159
View File
@@ -14,11 +14,12 @@ from dataclasses import dataclass
from PyQt6.QtWidgets import ( from PyQt6.QtWidgets import (
QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit, QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit,
QLabel, QFileDialog, QListWidget, QTextEdit, QTabWidget, QAbstractItemView, QProgressBar, QCheckBox, QDialog, QLabel, QFileDialog, QListWidget, QTextEdit, QTabWidget, QAbstractItemView, QProgressBar, QCheckBox, QDialog,
QDialogButtonBox, QComboBox, QListWidgetItem QDialogButtonBox, QComboBox, QListWidgetItem, QMessageBox
) )
from PyQt6.QtCore import Qt, QThread, pyqtSignal, QUrl, QTimer, QTime, QSettings, QSize from PyQt6.QtCore import Qt, QThread, pyqtSignal, QUrl, QTimer, QTime, QSettings, QSize
from PyQt6.QtNetwork import QNetworkAccessManager, QNetworkRequest from PyQt6.QtNetwork import QNetworkAccessManager, QNetworkRequest
from PyQt6.QtGui import QIcon, QTextCursor, QDesktopServices, QPixmap, QPainter, QPainterPath from PyQt6.QtGui import QIcon, QTextCursor, QDesktopServices, QPixmap, QPainter, QPainterPath
from PyQt6.QtSvg import QSvgRenderer
from getMetadata import get_metadata from getMetadata import get_metadata
@dataclass @dataclass
@@ -84,7 +85,7 @@ class DownloadWorker(QThread):
download_progress = pyqtSignal(str, int) download_progress = pyqtSignal(str, int)
def __init__(self, accounts, outpath, auth_token, filename_format='username_date', def __init__(self, accounts, outpath, auth_token, filename_format='username_date',
download_batch_size=25, convert_gif=False, gif_resolution='original'): download_batch_size=25, convert_gif=False, gif_resolution='original', gif_conversion_mode='better'):
super().__init__() super().__init__()
self.accounts = accounts self.accounts = accounts
self.outpath = outpath self.outpath = outpath
@@ -93,6 +94,7 @@ class DownloadWorker(QThread):
self.download_batch_size = download_batch_size self.download_batch_size = download_batch_size
self.convert_gif = convert_gif self.convert_gif = convert_gif
self.gif_resolution = gif_resolution self.gif_resolution = gif_resolution
self.gif_conversion_mode = gif_conversion_mode
self.is_paused = False self.is_paused = False
self.is_stopped = False self.is_stopped = False
self.filepath_map = [] self.filepath_map = []
@@ -256,19 +258,24 @@ class DownloadWorker(QThread):
os.remove(fp) os.remove(fp)
skipped_count += 1 skipped_count += 1
conv_progress = int((idx / total_gifs) * 100) conv_progress = int((idx / total_gifs) * 100)
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} ({self.gif_resolution}) - Skipped (exists)", conv_progress) quality_display = f"({self.gif_conversion_mode}) - ({self.gif_resolution})"
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} {quality_display} - Skipped (exists)", conv_progress)
continue continue
except Exception: except Exception:
pass pass
if self.gif_resolution == 'high':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=800:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=800:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '15', '-y', gif_fp] if self.gif_conversion_mode == 'fast':
elif self.gif_resolution == 'medium': ffmpeg_args = [ffmpeg_exe, '-i', fp, '-y', gif_fp]
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=600:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=600:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '10', '-y', gif_fp]
elif self.gif_resolution == 'low':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=400:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=400:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '8', '-y', gif_fp]
else: else:
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'palettegen=stats_mode=full[palette];[0:v][palette]paletteuse=dither=sierra2_4a', '-y', gif_fp] if self.gif_resolution == 'high':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=800:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=800:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '15', '-y', gif_fp]
elif self.gif_resolution == 'medium':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=600:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=600:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '10', '-y', gif_fp]
elif self.gif_resolution == 'low':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=400:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=400:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '8', '-y', gif_fp]
else:
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'palettegen=stats_mode=full[palette];[0:v][palette]paletteuse=dither=sierra2_4a', '-y', gif_fp]
result = subprocess.run(ffmpeg_args, capture_output=True, creationflags=creationflags) result = subprocess.run(ffmpeg_args, capture_output=True, creationflags=creationflags)
if result.returncode == 0 and os.path.exists(gif_fp): if result.returncode == 0 and os.path.exists(gif_fp):
@@ -281,7 +288,8 @@ class DownloadWorker(QThread):
pass pass
conv_progress = int((idx / total_gifs) * 100) conv_progress = int((idx / total_gifs) * 100)
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} ({self.gif_resolution})", conv_progress) quality_display = f"({self.gif_conversion_mode}) - ({self.gif_resolution})"
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} {quality_display}", conv_progress)
if converted_count > 0 or skipped_count > 0: if converted_count > 0 or skipped_count > 0:
completion_msg = f"GIF conversion completed: {converted_count:,} converted" completion_msg = f"GIF conversion completed: {converted_count:,} converted"
if skipped_count > 0: if skipped_count > 0:
@@ -344,9 +352,9 @@ class UpdateDialog(QDialog):
class TwitterMediaDownloaderGUI(QWidget): class TwitterMediaDownloaderGUI(QWidget):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.current_version = "3.5" self.current_version = "3.7"
self.accounts = [] self.accounts = []
self.temp_dir = os.path.join(tempfile.gettempdir(), "twitterxmediabatchdownloader") self.temp_dir = os.path.join(Path.home(), ".twitterxmediabatchdownloader")
os.makedirs(self.temp_dir, exist_ok=True) os.makedirs(self.temp_dir, exist_ok=True)
self.reset_state() self.reset_state()
@@ -362,6 +370,8 @@ class TwitterMediaDownloaderGUI(QWidget):
self.media_type = self.settings.value('media_type', 'all') self.media_type = self.settings.value('media_type', 'all')
self.convert_gif = self.settings.value('convert_gif', False, type=bool) self.convert_gif = self.settings.value('convert_gif', False, type=bool)
self.gif_resolution = self.settings.value('gif_resolution', 'original') self.gif_resolution = self.settings.value('gif_resolution', 'original')
self.gif_conversion_mode = self.settings.value('gif_conversion_mode', 'better')
self.gif_conversion_quality = self.settings.value('gif_conversion_quality', 'original')
self.check_for_updates = self.settings.value('check_for_updates', True, type=bool) self.check_for_updates = self.settings.value('check_for_updates', True, type=bool)
self.is_auto_fetching = False self.is_auto_fetching = False
@@ -462,7 +472,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.setMinimumWidth(670) self.setMinimumWidth(670)
self.setMinimumHeight(350) self.setMinimumHeight(350)
icon_path = os.path.join(os.path.dirname(__file__), "icon.svg") icon_path = os.path.join(os.path.dirname(__file__), "icons", "icon.svg")
if os.path.exists(icon_path): if os.path.exists(icon_path):
self.setWindowIcon(QIcon(icon_path)) self.setWindowIcon(QIcon(icon_path))
@@ -548,25 +558,52 @@ class TwitterMediaDownloaderGUI(QWidget):
def setup_account_buttons(self): def setup_account_buttons(self):
self.btn_layout = QHBoxLayout() self.btn_layout = QHBoxLayout()
self.download_selected_btn = QPushButton('Download Selected') self.import_btn = QPushButton(' Import')
self.update_selected_btn = QPushButton('Update Selected') self.export_btn = QPushButton(' Export')
self.remove_btn = QPushButton('Remove Selected') self.download_selected_btn = QPushButton(' Download')
self.clear_btn = QPushButton('Clear') self.update_selected_btn = QPushButton(' Update')
self.delete_btn = QPushButton(' Delete')
for btn in [self.download_selected_btn, self.update_selected_btn, self.remove_btn, self.clear_btn]: icon_dir = os.path.join(os.path.dirname(__file__), 'icons')
btn.setMinimumWidth(120) icon_color = self.palette().color(self.palette().ColorRole.ButtonText).name()
self.import_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'database-import.svg'), icon_color))
self.export_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'database-export.svg'), icon_color))
self.download_selected_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'download.svg'), icon_color))
self.update_selected_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'reload.svg'), icon_color))
self.delete_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'trash.svg'), icon_color))
for btn in [self.import_btn, self.export_btn, self.download_selected_btn,
self.update_selected_btn, self.delete_btn]:
btn.setMinimumWidth(100)
btn.setCursor(Qt.CursorShape.PointingHandCursor) btn.setCursor(Qt.CursorShape.PointingHandCursor)
btn.setIconSize(QSize(18, 18))
self.import_btn.clicked.connect(self.import_accounts)
self.export_btn.clicked.connect(self.export_accounts)
self.download_selected_btn.clicked.connect(self.download_selected) self.download_selected_btn.clicked.connect(self.download_selected)
self.update_selected_btn.clicked.connect(self.update_selected) self.update_selected_btn.clicked.connect(self.update_selected)
self.remove_btn.clicked.connect(self.remove_selected_accounts) self.delete_btn.clicked.connect(self.delete_accounts)
self.clear_btn.clicked.connect(self.clear_accounts)
self.btn_layout.addStretch() self.btn_layout.addStretch()
for btn in [self.download_selected_btn, self.update_selected_btn, self.remove_btn, self.clear_btn]: for btn in [self.import_btn, self.export_btn, self.download_selected_btn,
self.update_selected_btn, self.delete_btn]:
self.btn_layout.addWidget(btn, 1) self.btn_layout.addWidget(btn, 1)
self.btn_layout.addStretch() self.btn_layout.addStretch()
def update_button_icons(self):
if not hasattr(self, 'import_btn'):
return
icon_dir = os.path.join(os.path.dirname(__file__), 'icons')
icon_color = self.palette().color(self.palette().ColorRole.ButtonText).name()
self.import_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'database-import.svg'), icon_color))
self.export_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'database-export.svg'), icon_color))
self.download_selected_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'download.svg'), icon_color))
self.update_selected_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'reload.svg'), icon_color))
self.delete_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'trash.svg'), icon_color))
def setup_process_tab(self): def setup_process_tab(self):
self.process_tab = QWidget() self.process_tab = QWidget()
process_layout = QVBoxLayout() process_layout = QVBoxLayout()
@@ -710,6 +747,37 @@ class TwitterMediaDownloaderGUI(QWidget):
first_row_layout = QHBoxLayout() first_row_layout = QHBoxLayout()
first_row_layout.setSpacing(5) first_row_layout.setSpacing(5)
timeline_label = QLabel("Timeline:")
self.timeline_type_combo = QComboBox()
self.timeline_type_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.timeline_type_combo.setFixedWidth(75)
timeline_types = [
('media', 'Media'),
('timeline', 'Post'),
('tweets', 'Tweets'),
('with_replies', 'Replies')
]
for value, display in timeline_types:
self.timeline_type_combo.addItem(display, value)
self.timeline_type_combo.currentTextChanged.connect(self.save_settings)
first_row_layout.addWidget(timeline_label)
first_row_layout.addWidget(self.timeline_type_combo)
first_row_layout.addSpacing(5)
media_label = QLabel("Media:")
self.media_type_combo = QComboBox()
self.media_type_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.media_type_combo.setFixedWidth(85)
media_types = [('all', 'All'), ('image', 'Image'), ('video', 'Video'), ('gif', 'GIF')]
for value, display in media_types:
self.media_type_combo.addItem(display, value)
self.media_type_combo.currentTextChanged.connect(self.save_settings)
first_row_layout.addWidget(media_label)
first_row_layout.addWidget(self.media_type_combo)
first_row_layout.addSpacing(5)
self.batch_checkbox = QCheckBox("Fetch Batch") self.batch_checkbox = QCheckBox("Fetch Batch")
self.batch_checkbox.setCursor(Qt.CursorShape.PointingHandCursor) self.batch_checkbox.setCursor(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")
@@ -731,52 +799,41 @@ class TwitterMediaDownloaderGUI(QWidget):
self.size_label.hide() self.size_label.hide()
self.batch_size_combo.hide() self.batch_size_combo.hide()
first_row_layout.addSpacing(5)
timeline_label = QLabel("Timeline Type:")
self.timeline_type_combo = QComboBox()
self.timeline_type_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.timeline_type_combo.setFixedWidth(75)
timeline_types = [
('media', 'Media'),
('timeline', 'Post'),
('tweets', 'Tweets'),
('with_replies', 'Replies')
]
for value, display in timeline_types:
self.timeline_type_combo.addItem(display, value)
self.timeline_type_combo.currentTextChanged.connect(self.save_settings)
first_row_layout.addWidget(timeline_label)
first_row_layout.addWidget(self.timeline_type_combo)
first_row_layout.addSpacing(5)
media_type_label = QLabel("Media Type:")
self.media_type_combo = QComboBox()
self.media_type_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.media_type_combo.setFixedWidth(85)
media_types = [('all', 'All'), ('image', 'Image'), ('video', 'Video'), ('gif', 'GIF')]
for value, display in media_types:
self.media_type_combo.addItem(display, value)
self.media_type_combo.currentTextChanged.connect(self.save_settings)
first_row_layout.addWidget(media_type_label)
first_row_layout.addWidget(self.media_type_combo)
first_row_layout.addStretch() first_row_layout.addStretch()
gallery_dl_layout.addLayout(first_row_layout) gallery_dl_layout.addLayout(first_row_layout)
settings_layout.addWidget(gallery_dl_group) settings_layout.addWidget(gallery_dl_group)
download_group = QWidget() download_conversion_group = QWidget()
download_layout = QVBoxLayout(download_group) download_conversion_layout = QVBoxLayout(download_conversion_group)
download_layout.setSpacing(5) download_conversion_layout.setSpacing(5)
labels_layout = QHBoxLayout()
download_label_container = QWidget()
download_label_layout = QHBoxLayout(download_label_container)
download_label_layout.setContentsMargins(0, 0, 0, 0)
download_label = QLabel('Download Settings') download_label = QLabel('Download Settings')
download_label.setStyleSheet("font-weight: bold;") download_label.setStyleSheet("font-weight: bold;")
download_layout.addWidget(download_label) download_label_layout.addWidget(download_label)
download_label_layout.addStretch()
download_label_container.setFixedWidth(180)
labels_layout.addWidget(download_label_container)
batch_layout = QHBoxLayout() conversion_label = QLabel('Conversion Settings')
batch_label = QLabel('Concurrent Downloads:') conversion_label.setStyleSheet("font-weight: bold;")
labels_layout.addWidget(conversion_label)
labels_layout.addStretch()
download_conversion_layout.addLayout(labels_layout)
controls_layout = QHBoxLayout()
download_controls_container = QWidget()
download_controls_layout = QHBoxLayout(download_controls_container)
download_controls_layout.setContentsMargins(0, 0, 0, 0)
batch_label = QLabel('Concurrents:')
download_controls_layout.addWidget(batch_label)
self.download_batch_combo = QComboBox() self.download_batch_combo = QComboBox()
self.download_batch_combo.setCursor(Qt.CursorShape.PointingHandCursor) self.download_batch_combo.setCursor(Qt.CursorShape.PointingHandCursor)
@@ -785,40 +842,62 @@ class TwitterMediaDownloaderGUI(QWidget):
self.download_batch_combo.addItem(str(size)) self.download_batch_combo.addItem(str(size))
self.download_batch_combo.setCurrentText(str(self.download_batch_size)) self.download_batch_combo.setCurrentText(str(self.download_batch_size))
self.download_batch_combo.currentTextChanged.connect(self.save_settings) self.download_batch_combo.currentTextChanged.connect(self.save_settings)
download_controls_layout.addWidget(self.download_batch_combo)
download_controls_layout.addStretch()
download_controls_container.setFixedWidth(180)
controls_layout.addWidget(download_controls_container)
self.convert_gif_checkbox = QCheckBox("Convert GIF") self.convert_gif_checkbox = QCheckBox("Convert GIF")
self.convert_gif_checkbox.setCursor(Qt.CursorShape.PointingHandCursor) self.convert_gif_checkbox.setCursor(Qt.CursorShape.PointingHandCursor)
self.convert_gif_checkbox.setChecked(self.convert_gif) self.convert_gif_checkbox.setChecked(self.convert_gif)
self.convert_gif_checkbox.toggled.connect(self.handle_gif_checkbox) self.convert_gif_checkbox.toggled.connect(self.handle_conversion_checkbox)
controls_layout.addWidget(self.convert_gif_checkbox)
batch_layout.addWidget(batch_label) controls_layout.addSpacing(5)
batch_layout.addWidget(self.download_batch_combo)
batch_layout.addWidget(self.convert_gif_checkbox)
self.gif_resolution_label = QLabel("Converted GIF Quality:") mode_label = QLabel("Mode:")
self.gif_resolution_combo = QComboBox() self.conversion_mode_combo = QComboBox()
self.gif_resolution_combo.setCursor(Qt.CursorShape.PointingHandCursor) self.conversion_mode_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.gif_resolution_combo.setFixedWidth(85) self.conversion_mode_combo.setFixedWidth(80)
gif_resolutions = [ conversion_modes = [('better', 'Better'), ('fast', 'Fast')]
for value, display in conversion_modes:
self.conversion_mode_combo.addItem(display, value)
self.conversion_mode_combo.currentTextChanged.connect(self.save_settings)
controls_layout.addWidget(mode_label)
controls_layout.addWidget(self.conversion_mode_combo)
controls_layout.addSpacing(5)
quality_label = QLabel("Quality:")
self.conversion_quality_combo = QComboBox()
self.conversion_quality_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.conversion_quality_combo.setFixedWidth(85)
gif_qualities = [
('original', 'Original'), ('original', 'Original'),
('high', 'High'), ('high', 'High'),
('medium', 'Medium'), ('medium', 'Medium'),
('low', 'Low') ('low', 'Low')
] ]
for value, display in gif_resolutions: for value, display in gif_qualities:
self.gif_resolution_combo.addItem(display, value) self.conversion_quality_combo.addItem(display, value)
self.gif_resolution_combo.currentTextChanged.connect(self.save_settings) self.conversion_quality_combo.currentTextChanged.connect(self.save_settings)
batch_layout.addWidget(self.gif_resolution_label) controls_layout.addWidget(quality_label)
batch_layout.addWidget(self.gif_resolution_combo) controls_layout.addWidget(self.conversion_quality_combo)
self.mode_label = mode_label
self.quality_label = quality_label
if not self.convert_gif: if not self.convert_gif:
self.gif_resolution_label.hide() mode_label.hide()
self.gif_resolution_combo.hide() self.conversion_mode_combo.hide()
quality_label.hide()
self.conversion_quality_combo.hide()
batch_layout.addStretch() controls_layout.addStretch()
download_layout.addLayout(batch_layout) download_conversion_layout.addLayout(controls_layout)
settings_layout.addWidget(download_group) settings_layout.addWidget(download_conversion_group)
settings_layout.addStretch() settings_layout.addStretch()
settings_tab.setLayout(settings_layout) settings_tab.setLayout(settings_layout)
@@ -855,7 +934,7 @@ class TwitterMediaDownloaderGUI(QWidget):
about_layout.addWidget(section_widget) about_layout.addWidget(section_widget)
footer_label = QLabel(f"v{self.current_version} | gallery-dl v1.30.6 | September 2025") footer_label = QLabel(f"v{self.current_version} | gallery-dl v1.30.9 | October 2025")
about_layout.addWidget(footer_label, alignment=Qt.AlignmentFlag.AlignCenter) about_layout.addWidget(footer_label, alignment=Qt.AlignmentFlag.AlignCenter)
about_tab.setLayout(about_layout) about_tab.setLayout(about_layout)
@@ -880,9 +959,13 @@ class TwitterMediaDownloaderGUI(QWidget):
self.settings.setValue('convert_gif', self.convert_gif_checkbox.isChecked()) self.settings.setValue('convert_gif', self.convert_gif_checkbox.isChecked())
self.convert_gif = self.convert_gif_checkbox.isChecked() self.convert_gif = self.convert_gif_checkbox.isChecked()
if hasattr(self, 'gif_resolution_combo'): if hasattr(self, 'conversion_mode_combo'):
self.settings.setValue('gif_resolution', self.gif_resolution_combo.currentData()) self.settings.setValue('gif_conversion_mode', self.conversion_mode_combo.currentData())
self.gif_resolution = self.gif_resolution_combo.currentData() self.gif_conversion_mode = self.conversion_mode_combo.currentData()
if hasattr(self, 'conversion_quality_combo'):
self.settings.setValue('gif_conversion_quality', self.conversion_quality_combo.currentData())
self.gif_conversion_quality = self.conversion_quality_combo.currentData()
self.settings.sync() self.settings.sync()
@@ -932,17 +1015,36 @@ class TwitterMediaDownloaderGUI(QWidget):
self.convert_gif_checkbox.blockSignals(False) self.convert_gif_checkbox.blockSignals(False)
if convert_gif: if convert_gif:
self.gif_resolution_label.show() if hasattr(self, 'mode_label'):
self.gif_resolution_combo.show() self.mode_label.show()
if hasattr(self, 'conversion_mode_combo'):
self.conversion_mode_combo.show()
if hasattr(self, 'quality_label'):
self.quality_label.show()
if hasattr(self, 'conversion_quality_combo'):
self.conversion_quality_combo.show()
else: else:
self.gif_resolution_label.hide() if hasattr(self, 'mode_label'):
self.gif_resolution_combo.hide() self.mode_label.hide()
if hasattr(self, 'conversion_mode_combo'):
self.conversion_mode_combo.hide()
if hasattr(self, 'quality_label'):
self.quality_label.hide()
if hasattr(self, 'conversion_quality_combo'):
self.conversion_quality_combo.hide()
gif_resolution = self.settings.value('gif_resolution', 'original') gif_conversion_mode = self.settings.value('gif_conversion_mode', 'better')
if hasattr(self, 'gif_resolution_combo'): if hasattr(self, 'conversion_mode_combo'):
for i in range(self.gif_resolution_combo.count()): for i in range(self.conversion_mode_combo.count()):
if self.gif_resolution_combo.itemData(i) == gif_resolution: if self.conversion_mode_combo.itemData(i) == gif_conversion_mode:
self.gif_resolution_combo.setCurrentIndex(i) self.conversion_mode_combo.setCurrentIndex(i)
break
gif_conversion_quality = self.settings.value('gif_conversion_quality', 'original')
if hasattr(self, 'conversion_quality_combo'):
for i in range(self.conversion_quality_combo.count()):
if self.conversion_quality_combo.itemData(i) == gif_conversion_quality:
self.conversion_quality_combo.setCurrentIndex(i)
break break
last_username_url = self.settings.value('twitter_url', '') last_username_url = self.settings.value('twitter_url', '')
@@ -969,16 +1071,28 @@ class TwitterMediaDownloaderGUI(QWidget):
self.fetch_btn.setText('Fetch') self.fetch_btn.setText('Fetch')
self.update_button_states() self.update_button_states()
def handle_gif_checkbox(self, checked): def handle_conversion_checkbox(self, checked):
self.convert_gif = checked self.convert_gif = checked
self.save_settings() self.save_settings()
if checked: if checked:
self.gif_resolution_label.show() if hasattr(self, 'mode_label'):
self.gif_resolution_combo.show() self.mode_label.show()
if hasattr(self, 'conversion_mode_combo'):
self.conversion_mode_combo.show()
if hasattr(self, 'quality_label'):
self.quality_label.show()
if hasattr(self, 'conversion_quality_combo'):
self.conversion_quality_combo.show()
else: else:
self.gif_resolution_label.hide() if hasattr(self, 'mode_label'):
self.gif_resolution_combo.hide() self.mode_label.hide()
if hasattr(self, 'conversion_mode_combo'):
self.conversion_mode_combo.hide()
if hasattr(self, 'quality_label'):
self.quality_label.hide()
if hasattr(self, 'conversion_quality_combo'):
self.conversion_quality_combo.hide()
def browse_output(self): def browse_output(self):
directory = QFileDialog.getExistingDirectory(self, "Select Output Directory") directory = QFileDialog.getExistingDirectory(self, "Select Output Directory")
@@ -1736,6 +1850,23 @@ class TwitterMediaDownloaderGUI(QWidget):
self.update_button_states() self.update_button_states()
def create_colored_icon(self, svg_path, color):
with open(svg_path, 'r', encoding='utf-8') as f:
svg_content = f.read()
svg_content = svg_content.replace('stroke="currentColor"', f'stroke="{color}"')
svg_content = svg_content.replace('fill="currentColor"', f'fill="{color}"')
pixmap = QPixmap(24, 24)
pixmap.fill(Qt.GlobalColor.transparent)
renderer = QSvgRenderer(svg_content.encode('utf-8'))
painter = QPainter(pixmap)
renderer.render(painter)
painter.end()
return QIcon(pixmap)
def create_placeholder_icon(self, size=48): def create_placeholder_icon(self, size=48):
pixmap = QPixmap(size, size) pixmap = QPixmap(size, size)
pixmap.fill(Qt.GlobalColor.transparent) pixmap.fill(Qt.GlobalColor.transparent)
@@ -1821,34 +1952,46 @@ class TwitterMediaDownloaderGUI(QWidget):
has_selected = len(self.account_list.selectedItems()) > 0 has_selected = len(self.account_list.selectedItems()) > 0
self.download_selected_btn.setEnabled(has_accounts and has_selected) self.import_btn.setEnabled(True)
self.update_selected_btn.setEnabled(has_accounts and has_selected) self.export_btn.setEnabled(has_accounts)
self.remove_btn.setEnabled(has_accounts and has_selected) self.download_selected_btn.setEnabled(has_accounts)
self.clear_btn.setEnabled(has_accounts) self.update_selected_btn.setEnabled(has_accounts)
self.delete_btn.setEnabled(has_accounts)
if has_accounts: self.import_btn.show()
self.download_selected_btn.show() self.export_btn.show()
self.update_selected_btn.show() self.download_selected_btn.show()
self.remove_btn.show() self.update_selected_btn.show()
self.clear_btn.show() self.delete_btn.show()
else:
self.hide_account_buttons()
def hide_account_buttons(self): def hide_account_buttons(self):
buttons = [ self.import_btn.setEnabled(True)
self.download_selected_btn, self.export_btn.setEnabled(False)
self.update_selected_btn, self.download_selected_btn.setEnabled(False)
self.remove_btn, self.update_selected_btn.setEnabled(False)
self.clear_btn self.delete_btn.setEnabled(False)
]
for btn in buttons: self.import_btn.show()
btn.hide() self.export_btn.show()
self.download_selected_btn.show()
self.update_selected_btn.show()
self.delete_btn.show()
def download_selected(self): def download_selected(self):
selected_items = self.account_list.selectedItems() selected_items = self.account_list.selectedItems()
if not selected_items: if not selected_items:
self.log_output.append('Warning: Please select accounts to download.') reply = QMessageBox.question(
self,
'Confirm Download All',
f'No accounts selected. Download all {len(self.accounts)} account(s)?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.Yes:
self.download_accounts(list(range(len(self.accounts))))
return return
self.download_accounts([self.account_list.row(item) for item in selected_items]) self.download_accounts([self.account_list.row(item) for item in selected_items])
def download_all(self): def download_all(self):
@@ -1856,15 +1999,24 @@ class TwitterMediaDownloaderGUI(QWidget):
def update_selected(self): def update_selected(self):
selected_items = self.account_list.selectedItems() selected_items = self.account_list.selectedItems()
if not selected_items:
self.log_output.append('Warning: Please select accounts to update.')
return
selected_accounts = [] if not selected_items:
for item in selected_items: reply = QMessageBox.question(
index = self.account_list.row(item) self,
if index < len(self.accounts): 'Confirm Update All',
selected_accounts.append(self.accounts[index]) f'No accounts selected. Update all {len(self.accounts)} account(s)?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.No:
return
selected_accounts = self.accounts.copy()
else:
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: if not selected_accounts:
return return
@@ -1988,7 +2140,8 @@ class TwitterMediaDownloaderGUI(QWidget):
self.filename_format, self.filename_format,
self.download_batch_size, self.download_batch_size,
self.convert_gif, self.convert_gif,
self.gif_resolution self.gif_conversion_quality,
self.gif_conversion_mode
) )
self.worker.finished.connect(self.on_download_finished) self.worker.finished.connect(self.on_download_finished)
self.worker.progress.connect(self.update_progress) self.worker.progress.connect(self.update_progress)
@@ -2110,45 +2263,221 @@ class TwitterMediaDownloaderGUI(QWidget):
self.worker.pause() self.worker.pause()
self.pause_resume_btn.setText('Resume') self.pause_resume_btn.setText('Resume')
def remove_selected_accounts(self): def delete_accounts(self):
selected_indices = sorted([self.account_list.row(item) for item in self.account_list.selectedItems()], reverse=True) selected_items = self.account_list.selectedItems()
if not selected_indices: if not selected_items:
reply = QMessageBox.question(
self,
'Confirm Delete All',
f'No accounts selected. Delete all {len(self.accounts)} account(s) and their cache files?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.No:
return
for account in self.accounts:
username = account.username
if username:
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, account.media_type, is_batch=is_batch)
try:
if os.path.exists(cache_file):
os.remove(cache_file)
self.log_output.append(f'Removed temp file: {os.path.basename(cache_file)}')
except Exception as e:
self.log_output.append(f'Warning: Could not remove temp file {os.path.basename(cache_file)}: {str(e)}')
self.reset_state()
self.reset_ui()
self.tab_widget.setCurrentIndex(0)
else:
reply = QMessageBox.question(
self,
'Confirm Delete',
f'Delete {len(selected_items)} selected account(s) and their cache files?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.No:
return
selected_indices = sorted([self.account_list.row(item) for item in selected_items], reverse=True)
for index in selected_indices:
account = self.accounts[index]
username = account.username
if username:
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, account.media_type, is_batch=is_batch)
try:
if os.path.exists(cache_file):
os.remove(cache_file)
self.log_output.append(f'Removed temp file: {os.path.basename(cache_file)}')
except Exception as e:
self.log_output.append(f'Warning: Could not remove temp file {os.path.basename(cache_file)}: {str(e)}')
self.accounts.pop(index)
self.update_account_list()
self.update_button_states()
def export_accounts(self):
self.tab_widget.setCurrentIndex(1)
selected_items = self.account_list.selectedItems()
if not selected_items:
reply = QMessageBox.question(
self,
'Confirm Export All',
f'No accounts selected. Export all {len(self.accounts)} account(s)?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.No:
self.log_output.append('Export cancelled')
return
selected_accounts = self.accounts.copy()
else:
selected_accounts = []
for item in selected_items:
row = self.account_list.row(item)
if 0 <= row < len(self.accounts):
selected_accounts.append(self.accounts[row])
if not selected_accounts:
self.log_output.append('No valid accounts found for export')
return return
for index in selected_indices: export_dir = QFileDialog.getExistingDirectory(self, "Select Export Directory", self.last_output_path)
account = self.accounts[index] if not export_dir:
username = account.username self.log_output.append('Export cancelled')
if username: return
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, account.media_type, is_batch=is_batch) self.log_output.append(f'Starting export of {len(selected_accounts)} account(s)...')
try: exported_count = 0
if os.path.exists(cache_file):
os.remove(cache_file) for account in selected_accounts:
self.log_output.append(f'Removed temp file: {os.path.basename(cache_file)}') try:
except Exception as e: now = datetime.now()
self.log_output.append(f'Warning: Could not remove temp file {os.path.basename(cache_file)}: {str(e)}') date_str = now.strftime("%Y%m%d_%H%M%S")
self.accounts.pop(index) if account.fetch_mode == 'batch':
filename = f"{account.username}_batch_{date_str}.json"
else:
filename = f"{account.username}_{date_str}.json"
filepath = os.path.join(export_dir, filename)
export_data = {
'username': account.username,
'nick': account.nick,
'followers': account.followers,
'following': account.following,
'posts': account.posts,
'media_type': account.media_type,
'profile_image': account.profile_image,
'media_list': account.media_list,
'fetch_mode': account.fetch_mode,
'fetch_timestamp': account.fetch_timestamp,
'export_timestamp': now.isoformat()
}
with open(filepath, 'w', encoding='utf-8') as f:
json.dump(export_data, f, indent=2, ensure_ascii=False)
exported_count += 1
self.log_output.append(f'Exported: {filename}')
except Exception as e:
self.log_output.append(f'Error exporting {account.username}: {str(e)}')
self.log_output.append(f'Export completed: {exported_count}/{len(selected_accounts)} account(s) exported')
self.log_output.append(f'Export location: {export_dir}')
def import_accounts(self):
self.tab_widget.setCurrentIndex(1)
file_paths, _ = QFileDialog.getOpenFileNames(
self,
"Select JSON Files to Import",
self.last_output_path,
"JSON Files (*.json)"
)
if not file_paths:
self.log_output.append('Import cancelled')
return
self.log_output.append(f'Starting import of {len(file_paths)} file(s)...')
imported_count = 0
skipped_count = 0
error_count = 0
for filepath in file_paths:
try:
with open(filepath, 'r', encoding='utf-8') as f:
data = json.load(f)
username = data.get('username')
if not username:
self.log_output.append(f'Skipped {os.path.basename(filepath)}: No username found')
skipped_count += 1
continue
existing_account = next((acc for acc in self.accounts if acc.username == username), None)
if existing_account:
self.log_output.append(f'Skipped {username}: Already exists in dashboard')
skipped_count += 1
continue
account = Account(
username=username,
nick=data.get('nick', ''),
followers=data.get('followers', 0),
following=data.get('following', 0),
posts=data.get('posts', 0),
media_type=data.get('media_type', 'all'),
profile_image=data.get('profile_image'),
media_list=data.get('media_list', []),
fetch_mode=data.get('fetch_mode', 'all'),
fetch_timestamp=data.get('fetch_timestamp')
)
self.accounts.append(account)
account_info = {
'followers_count': account.followers,
'friends_count': account.following,
'statuses_count': account.posts,
'nick': account.nick,
'name': account.nick,
'profile_image': account.profile_image
}
cache_data = {
'account_info': account_info,
'timeline': account.media_list,
'metadata': {},
'is_batch': (account.fetch_mode == 'batch'),
'fetch_timestamp': account.fetch_timestamp
}
self.save_cached_data(username, account.media_type, cache_data, is_batch=(account.fetch_mode == 'batch'))
imported_count += 1
media_count = len(account.media_list) if account.media_list else 0
self.log_output.append(f'Imported: {username} ({media_count:,} media)')
except Exception as e:
self.log_output.append(f'Error importing {os.path.basename(filepath)}: {str(e)}')
error_count += 1
self.update_account_list() self.update_account_list()
self.update_button_states() self.update_button_states()
self.log_output.append(f'Import completed: {imported_count} imported, {skipped_count} skipped, {error_count} errors')
def clear_accounts(self):
for account in self.accounts:
username = account.username
if username:
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, account.media_type, is_batch=is_batch)
try:
if os.path.exists(cache_file):
os.remove(cache_file)
self.log_output.append(f'Removed temp file: {os.path.basename(cache_file)}')
except Exception as e:
self.log_output.append(f'Warning: Could not remove temp file {os.path.basename(cache_file)}: {str(e)}')
self.reset_state()
self.reset_ui()
self.tab_widget.setCurrentIndex(0) self.tab_widget.setCurrentIndex(0)
+488 -159
View File
@@ -14,11 +14,12 @@ from dataclasses import dataclass
from PyQt6.QtWidgets import ( from PyQt6.QtWidgets import (
QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit, QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit,
QLabel, QFileDialog, QListWidget, QTextEdit, QTabWidget, QAbstractItemView, QProgressBar, QCheckBox, QDialog, QLabel, QFileDialog, QListWidget, QTextEdit, QTabWidget, QAbstractItemView, QProgressBar, QCheckBox, QDialog,
QDialogButtonBox, QComboBox, QListWidgetItem QDialogButtonBox, QComboBox, QListWidgetItem, QMessageBox
) )
from PyQt6.QtCore import Qt, QThread, pyqtSignal, QUrl, QTimer, QTime, QSettings, QSize from PyQt6.QtCore import Qt, QThread, pyqtSignal, QUrl, QTimer, QTime, QSettings, QSize
from PyQt6.QtNetwork import QNetworkAccessManager, QNetworkRequest from PyQt6.QtNetwork import QNetworkAccessManager, QNetworkRequest
from PyQt6.QtGui import QIcon, QTextCursor, QDesktopServices, QPixmap, QPainter, QPainterPath from PyQt6.QtGui import QIcon, QTextCursor, QDesktopServices, QPixmap, QPainter, QPainterPath
from PyQt6.QtSvg import QSvgRenderer
from getMetadata import get_metadata from getMetadata import get_metadata
@dataclass @dataclass
@@ -84,7 +85,7 @@ class DownloadWorker(QThread):
download_progress = pyqtSignal(str, int) download_progress = pyqtSignal(str, int)
def __init__(self, accounts, outpath, auth_token, filename_format='username_date', def __init__(self, accounts, outpath, auth_token, filename_format='username_date',
download_batch_size=25, convert_gif=False, gif_resolution='original'): download_batch_size=25, convert_gif=False, gif_resolution='original', gif_conversion_mode='better'):
super().__init__() super().__init__()
self.accounts = accounts self.accounts = accounts
self.outpath = outpath self.outpath = outpath
@@ -93,6 +94,7 @@ class DownloadWorker(QThread):
self.download_batch_size = download_batch_size self.download_batch_size = download_batch_size
self.convert_gif = convert_gif self.convert_gif = convert_gif
self.gif_resolution = gif_resolution self.gif_resolution = gif_resolution
self.gif_conversion_mode = gif_conversion_mode
self.is_paused = False self.is_paused = False
self.is_stopped = False self.is_stopped = False
self.filepath_map = [] self.filepath_map = []
@@ -256,19 +258,24 @@ class DownloadWorker(QThread):
os.remove(fp) os.remove(fp)
skipped_count += 1 skipped_count += 1
conv_progress = int((idx / total_gifs) * 100) conv_progress = int((idx / total_gifs) * 100)
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} ({self.gif_resolution}) - Skipped (exists)", conv_progress) quality_display = f"({self.gif_conversion_mode}) - ({self.gif_resolution})"
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} {quality_display} - Skipped (exists)", conv_progress)
continue continue
except Exception: except Exception:
pass pass
if self.gif_resolution == 'high':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=800:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=800:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '15', '-y', gif_fp] if self.gif_conversion_mode == 'fast':
elif self.gif_resolution == 'medium': ffmpeg_args = [ffmpeg_exe, '-i', fp, '-y', gif_fp]
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=600:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=600:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '10', '-y', gif_fp]
elif self.gif_resolution == 'low':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=400:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=400:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '8', '-y', gif_fp]
else: else:
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'palettegen=stats_mode=full[palette];[0:v][palette]paletteuse=dither=sierra2_4a', '-y', gif_fp] if self.gif_resolution == 'high':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=800:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=800:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '15', '-y', gif_fp]
elif self.gif_resolution == 'medium':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=600:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=600:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '10', '-y', gif_fp]
elif self.gif_resolution == 'low':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=400:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=400:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '8', '-y', gif_fp]
else:
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'palettegen=stats_mode=full[palette];[0:v][palette]paletteuse=dither=sierra2_4a', '-y', gif_fp]
result = subprocess.run(ffmpeg_args, capture_output=True, creationflags=creationflags) result = subprocess.run(ffmpeg_args, capture_output=True, creationflags=creationflags)
if result.returncode == 0 and os.path.exists(gif_fp): if result.returncode == 0 and os.path.exists(gif_fp):
@@ -281,7 +288,8 @@ class DownloadWorker(QThread):
pass pass
conv_progress = int((idx / total_gifs) * 100) conv_progress = int((idx / total_gifs) * 100)
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} ({self.gif_resolution})", conv_progress) quality_display = f"({self.gif_conversion_mode}) - ({self.gif_resolution})"
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} {quality_display}", conv_progress)
if converted_count > 0 or skipped_count > 0: if converted_count > 0 or skipped_count > 0:
completion_msg = f"GIF conversion completed: {converted_count:,} converted" completion_msg = f"GIF conversion completed: {converted_count:,} converted"
if skipped_count > 0: if skipped_count > 0:
@@ -344,9 +352,9 @@ class UpdateDialog(QDialog):
class TwitterMediaDownloaderGUI(QWidget): class TwitterMediaDownloaderGUI(QWidget):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.current_version = "3.5" self.current_version = "3.7"
self.accounts = [] self.accounts = []
self.temp_dir = os.path.join(tempfile.gettempdir(), "twitterxmediabatchdownloader") self.temp_dir = os.path.join(Path.home(), ".twitterxmediabatchdownloader")
os.makedirs(self.temp_dir, exist_ok=True) os.makedirs(self.temp_dir, exist_ok=True)
self.reset_state() self.reset_state()
@@ -362,6 +370,8 @@ class TwitterMediaDownloaderGUI(QWidget):
self.media_type = self.settings.value('media_type', 'all') self.media_type = self.settings.value('media_type', 'all')
self.convert_gif = self.settings.value('convert_gif', False, type=bool) self.convert_gif = self.settings.value('convert_gif', False, type=bool)
self.gif_resolution = self.settings.value('gif_resolution', 'original') self.gif_resolution = self.settings.value('gif_resolution', 'original')
self.gif_conversion_mode = self.settings.value('gif_conversion_mode', 'better')
self.gif_conversion_quality = self.settings.value('gif_conversion_quality', 'original')
self.check_for_updates = self.settings.value('check_for_updates', True, type=bool) self.check_for_updates = self.settings.value('check_for_updates', True, type=bool)
self.is_auto_fetching = False self.is_auto_fetching = False
@@ -462,7 +472,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.setMinimumWidth(670) self.setMinimumWidth(670)
self.setMinimumHeight(350) self.setMinimumHeight(350)
icon_path = os.path.join(os.path.dirname(__file__), "icon.svg") icon_path = os.path.join(os.path.dirname(__file__), "icons", "icon.svg")
if os.path.exists(icon_path): if os.path.exists(icon_path):
self.setWindowIcon(QIcon(icon_path)) self.setWindowIcon(QIcon(icon_path))
@@ -548,25 +558,52 @@ class TwitterMediaDownloaderGUI(QWidget):
def setup_account_buttons(self): def setup_account_buttons(self):
self.btn_layout = QHBoxLayout() self.btn_layout = QHBoxLayout()
self.download_selected_btn = QPushButton('Download Selected') self.import_btn = QPushButton(' Import')
self.update_selected_btn = QPushButton('Update Selected') self.export_btn = QPushButton(' Export')
self.remove_btn = QPushButton('Remove Selected') self.download_selected_btn = QPushButton(' Download')
self.clear_btn = QPushButton('Clear') self.update_selected_btn = QPushButton(' Update')
self.delete_btn = QPushButton(' Delete')
for btn in [self.download_selected_btn, self.update_selected_btn, self.remove_btn, self.clear_btn]: icon_dir = os.path.join(os.path.dirname(__file__), 'icons')
btn.setMinimumWidth(120) icon_color = self.palette().color(self.palette().ColorRole.ButtonText).name()
self.import_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'database-import.svg'), icon_color))
self.export_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'database-export.svg'), icon_color))
self.download_selected_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'download.svg'), icon_color))
self.update_selected_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'reload.svg'), icon_color))
self.delete_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'trash.svg'), icon_color))
for btn in [self.import_btn, self.export_btn, self.download_selected_btn,
self.update_selected_btn, self.delete_btn]:
btn.setMinimumWidth(100)
btn.setCursor(Qt.CursorShape.PointingHandCursor) btn.setCursor(Qt.CursorShape.PointingHandCursor)
btn.setIconSize(QSize(18, 18))
self.import_btn.clicked.connect(self.import_accounts)
self.export_btn.clicked.connect(self.export_accounts)
self.download_selected_btn.clicked.connect(self.download_selected) self.download_selected_btn.clicked.connect(self.download_selected)
self.update_selected_btn.clicked.connect(self.update_selected) self.update_selected_btn.clicked.connect(self.update_selected)
self.remove_btn.clicked.connect(self.remove_selected_accounts) self.delete_btn.clicked.connect(self.delete_accounts)
self.clear_btn.clicked.connect(self.clear_accounts)
self.btn_layout.addStretch() self.btn_layout.addStretch()
for btn in [self.download_selected_btn, self.update_selected_btn, self.remove_btn, self.clear_btn]: for btn in [self.import_btn, self.export_btn, self.download_selected_btn,
self.update_selected_btn, self.delete_btn]:
self.btn_layout.addWidget(btn, 1) self.btn_layout.addWidget(btn, 1)
self.btn_layout.addStretch() self.btn_layout.addStretch()
def update_button_icons(self):
if not hasattr(self, 'import_btn'):
return
icon_dir = os.path.join(os.path.dirname(__file__), 'icons')
icon_color = self.palette().color(self.palette().ColorRole.ButtonText).name()
self.import_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'database-import.svg'), icon_color))
self.export_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'database-export.svg'), icon_color))
self.download_selected_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'download.svg'), icon_color))
self.update_selected_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'reload.svg'), icon_color))
self.delete_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'trash.svg'), icon_color))
def setup_process_tab(self): def setup_process_tab(self):
self.process_tab = QWidget() self.process_tab = QWidget()
process_layout = QVBoxLayout() process_layout = QVBoxLayout()
@@ -710,6 +747,37 @@ class TwitterMediaDownloaderGUI(QWidget):
first_row_layout = QHBoxLayout() first_row_layout = QHBoxLayout()
first_row_layout.setSpacing(5) first_row_layout.setSpacing(5)
timeline_label = QLabel("Timeline:")
self.timeline_type_combo = QComboBox()
self.timeline_type_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.timeline_type_combo.setFixedWidth(75)
timeline_types = [
('media', 'Media'),
('timeline', 'Post'),
('tweets', 'Tweets'),
('with_replies', 'Replies')
]
for value, display in timeline_types:
self.timeline_type_combo.addItem(display, value)
self.timeline_type_combo.currentTextChanged.connect(self.save_settings)
first_row_layout.addWidget(timeline_label)
first_row_layout.addWidget(self.timeline_type_combo)
first_row_layout.addSpacing(5)
media_label = QLabel("Media:")
self.media_type_combo = QComboBox()
self.media_type_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.media_type_combo.setFixedWidth(85)
media_types = [('all', 'All'), ('image', 'Image'), ('video', 'Video'), ('gif', 'GIF')]
for value, display in media_types:
self.media_type_combo.addItem(display, value)
self.media_type_combo.currentTextChanged.connect(self.save_settings)
first_row_layout.addWidget(media_label)
first_row_layout.addWidget(self.media_type_combo)
first_row_layout.addSpacing(5)
self.batch_checkbox = QCheckBox("Fetch Batch") self.batch_checkbox = QCheckBox("Fetch Batch")
self.batch_checkbox.setCursor(Qt.CursorShape.PointingHandCursor) self.batch_checkbox.setCursor(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")
@@ -731,52 +799,41 @@ class TwitterMediaDownloaderGUI(QWidget):
self.size_label.hide() self.size_label.hide()
self.batch_size_combo.hide() self.batch_size_combo.hide()
first_row_layout.addSpacing(5)
timeline_label = QLabel("Timeline Type:")
self.timeline_type_combo = QComboBox()
self.timeline_type_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.timeline_type_combo.setFixedWidth(75)
timeline_types = [
('media', 'Media'),
('timeline', 'Post'),
('tweets', 'Tweets'),
('with_replies', 'Replies')
]
for value, display in timeline_types:
self.timeline_type_combo.addItem(display, value)
self.timeline_type_combo.currentTextChanged.connect(self.save_settings)
first_row_layout.addWidget(timeline_label)
first_row_layout.addWidget(self.timeline_type_combo)
first_row_layout.addSpacing(5)
media_type_label = QLabel("Media Type:")
self.media_type_combo = QComboBox()
self.media_type_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.media_type_combo.setFixedWidth(85)
media_types = [('all', 'All'), ('image', 'Image'), ('video', 'Video'), ('gif', 'GIF')]
for value, display in media_types:
self.media_type_combo.addItem(display, value)
self.media_type_combo.currentTextChanged.connect(self.save_settings)
first_row_layout.addWidget(media_type_label)
first_row_layout.addWidget(self.media_type_combo)
first_row_layout.addStretch() first_row_layout.addStretch()
gallery_dl_layout.addLayout(first_row_layout) gallery_dl_layout.addLayout(first_row_layout)
settings_layout.addWidget(gallery_dl_group) settings_layout.addWidget(gallery_dl_group)
download_group = QWidget() download_conversion_group = QWidget()
download_layout = QVBoxLayout(download_group) download_conversion_layout = QVBoxLayout(download_conversion_group)
download_layout.setSpacing(5) download_conversion_layout.setSpacing(5)
labels_layout = QHBoxLayout()
download_label_container = QWidget()
download_label_layout = QHBoxLayout(download_label_container)
download_label_layout.setContentsMargins(0, 0, 0, 0)
download_label = QLabel('Download Settings') download_label = QLabel('Download Settings')
download_label.setStyleSheet("font-weight: bold;") download_label.setStyleSheet("font-weight: bold;")
download_layout.addWidget(download_label) download_label_layout.addWidget(download_label)
download_label_layout.addStretch()
download_label_container.setFixedWidth(180)
labels_layout.addWidget(download_label_container)
batch_layout = QHBoxLayout() conversion_label = QLabel('Conversion Settings')
batch_label = QLabel('Concurrent Downloads:') conversion_label.setStyleSheet("font-weight: bold;")
labels_layout.addWidget(conversion_label)
labels_layout.addStretch()
download_conversion_layout.addLayout(labels_layout)
controls_layout = QHBoxLayout()
download_controls_container = QWidget()
download_controls_layout = QHBoxLayout(download_controls_container)
download_controls_layout.setContentsMargins(0, 0, 0, 0)
batch_label = QLabel('Concurrents:')
download_controls_layout.addWidget(batch_label)
self.download_batch_combo = QComboBox() self.download_batch_combo = QComboBox()
self.download_batch_combo.setCursor(Qt.CursorShape.PointingHandCursor) self.download_batch_combo.setCursor(Qt.CursorShape.PointingHandCursor)
@@ -785,40 +842,62 @@ class TwitterMediaDownloaderGUI(QWidget):
self.download_batch_combo.addItem(str(size)) self.download_batch_combo.addItem(str(size))
self.download_batch_combo.setCurrentText(str(self.download_batch_size)) self.download_batch_combo.setCurrentText(str(self.download_batch_size))
self.download_batch_combo.currentTextChanged.connect(self.save_settings) self.download_batch_combo.currentTextChanged.connect(self.save_settings)
download_controls_layout.addWidget(self.download_batch_combo)
download_controls_layout.addStretch()
download_controls_container.setFixedWidth(180)
controls_layout.addWidget(download_controls_container)
self.convert_gif_checkbox = QCheckBox("Convert GIF") self.convert_gif_checkbox = QCheckBox("Convert GIF")
self.convert_gif_checkbox.setCursor(Qt.CursorShape.PointingHandCursor) self.convert_gif_checkbox.setCursor(Qt.CursorShape.PointingHandCursor)
self.convert_gif_checkbox.setChecked(self.convert_gif) self.convert_gif_checkbox.setChecked(self.convert_gif)
self.convert_gif_checkbox.toggled.connect(self.handle_gif_checkbox) self.convert_gif_checkbox.toggled.connect(self.handle_conversion_checkbox)
controls_layout.addWidget(self.convert_gif_checkbox)
batch_layout.addWidget(batch_label) controls_layout.addSpacing(5)
batch_layout.addWidget(self.download_batch_combo)
batch_layout.addWidget(self.convert_gif_checkbox)
self.gif_resolution_label = QLabel("Converted GIF Quality:") mode_label = QLabel("Mode:")
self.gif_resolution_combo = QComboBox() self.conversion_mode_combo = QComboBox()
self.gif_resolution_combo.setCursor(Qt.CursorShape.PointingHandCursor) self.conversion_mode_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.gif_resolution_combo.setFixedWidth(85) self.conversion_mode_combo.setFixedWidth(80)
gif_resolutions = [ conversion_modes = [('better', 'Better'), ('fast', 'Fast')]
for value, display in conversion_modes:
self.conversion_mode_combo.addItem(display, value)
self.conversion_mode_combo.currentTextChanged.connect(self.save_settings)
controls_layout.addWidget(mode_label)
controls_layout.addWidget(self.conversion_mode_combo)
controls_layout.addSpacing(5)
quality_label = QLabel("Quality:")
self.conversion_quality_combo = QComboBox()
self.conversion_quality_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.conversion_quality_combo.setFixedWidth(85)
gif_qualities = [
('original', 'Original'), ('original', 'Original'),
('high', 'High'), ('high', 'High'),
('medium', 'Medium'), ('medium', 'Medium'),
('low', 'Low') ('low', 'Low')
] ]
for value, display in gif_resolutions: for value, display in gif_qualities:
self.gif_resolution_combo.addItem(display, value) self.conversion_quality_combo.addItem(display, value)
self.gif_resolution_combo.currentTextChanged.connect(self.save_settings) self.conversion_quality_combo.currentTextChanged.connect(self.save_settings)
batch_layout.addWidget(self.gif_resolution_label) controls_layout.addWidget(quality_label)
batch_layout.addWidget(self.gif_resolution_combo) controls_layout.addWidget(self.conversion_quality_combo)
self.mode_label = mode_label
self.quality_label = quality_label
if not self.convert_gif: if not self.convert_gif:
self.gif_resolution_label.hide() mode_label.hide()
self.gif_resolution_combo.hide() self.conversion_mode_combo.hide()
quality_label.hide()
self.conversion_quality_combo.hide()
batch_layout.addStretch() controls_layout.addStretch()
download_layout.addLayout(batch_layout) download_conversion_layout.addLayout(controls_layout)
settings_layout.addWidget(download_group) settings_layout.addWidget(download_conversion_group)
settings_layout.addStretch() settings_layout.addStretch()
settings_tab.setLayout(settings_layout) settings_tab.setLayout(settings_layout)
@@ -855,7 +934,7 @@ class TwitterMediaDownloaderGUI(QWidget):
about_layout.addWidget(section_widget) about_layout.addWidget(section_widget)
footer_label = QLabel(f"v{self.current_version} | gallery-dl v1.30.6 | September 2025") footer_label = QLabel(f"v{self.current_version} | gallery-dl v1.30.9 | October 2025")
about_layout.addWidget(footer_label, alignment=Qt.AlignmentFlag.AlignCenter) about_layout.addWidget(footer_label, alignment=Qt.AlignmentFlag.AlignCenter)
about_tab.setLayout(about_layout) about_tab.setLayout(about_layout)
@@ -880,9 +959,13 @@ class TwitterMediaDownloaderGUI(QWidget):
self.settings.setValue('convert_gif', self.convert_gif_checkbox.isChecked()) self.settings.setValue('convert_gif', self.convert_gif_checkbox.isChecked())
self.convert_gif = self.convert_gif_checkbox.isChecked() self.convert_gif = self.convert_gif_checkbox.isChecked()
if hasattr(self, 'gif_resolution_combo'): if hasattr(self, 'conversion_mode_combo'):
self.settings.setValue('gif_resolution', self.gif_resolution_combo.currentData()) self.settings.setValue('gif_conversion_mode', self.conversion_mode_combo.currentData())
self.gif_resolution = self.gif_resolution_combo.currentData() self.gif_conversion_mode = self.conversion_mode_combo.currentData()
if hasattr(self, 'conversion_quality_combo'):
self.settings.setValue('gif_conversion_quality', self.conversion_quality_combo.currentData())
self.gif_conversion_quality = self.conversion_quality_combo.currentData()
self.settings.sync() self.settings.sync()
@@ -932,17 +1015,36 @@ class TwitterMediaDownloaderGUI(QWidget):
self.convert_gif_checkbox.blockSignals(False) self.convert_gif_checkbox.blockSignals(False)
if convert_gif: if convert_gif:
self.gif_resolution_label.show() if hasattr(self, 'mode_label'):
self.gif_resolution_combo.show() self.mode_label.show()
if hasattr(self, 'conversion_mode_combo'):
self.conversion_mode_combo.show()
if hasattr(self, 'quality_label'):
self.quality_label.show()
if hasattr(self, 'conversion_quality_combo'):
self.conversion_quality_combo.show()
else: else:
self.gif_resolution_label.hide() if hasattr(self, 'mode_label'):
self.gif_resolution_combo.hide() self.mode_label.hide()
if hasattr(self, 'conversion_mode_combo'):
self.conversion_mode_combo.hide()
if hasattr(self, 'quality_label'):
self.quality_label.hide()
if hasattr(self, 'conversion_quality_combo'):
self.conversion_quality_combo.hide()
gif_resolution = self.settings.value('gif_resolution', 'original') gif_conversion_mode = self.settings.value('gif_conversion_mode', 'better')
if hasattr(self, 'gif_resolution_combo'): if hasattr(self, 'conversion_mode_combo'):
for i in range(self.gif_resolution_combo.count()): for i in range(self.conversion_mode_combo.count()):
if self.gif_resolution_combo.itemData(i) == gif_resolution: if self.conversion_mode_combo.itemData(i) == gif_conversion_mode:
self.gif_resolution_combo.setCurrentIndex(i) self.conversion_mode_combo.setCurrentIndex(i)
break
gif_conversion_quality = self.settings.value('gif_conversion_quality', 'original')
if hasattr(self, 'conversion_quality_combo'):
for i in range(self.conversion_quality_combo.count()):
if self.conversion_quality_combo.itemData(i) == gif_conversion_quality:
self.conversion_quality_combo.setCurrentIndex(i)
break break
last_username_url = self.settings.value('twitter_url', '') last_username_url = self.settings.value('twitter_url', '')
@@ -969,16 +1071,28 @@ class TwitterMediaDownloaderGUI(QWidget):
self.fetch_btn.setText('Fetch') self.fetch_btn.setText('Fetch')
self.update_button_states() self.update_button_states()
def handle_gif_checkbox(self, checked): def handle_conversion_checkbox(self, checked):
self.convert_gif = checked self.convert_gif = checked
self.save_settings() self.save_settings()
if checked: if checked:
self.gif_resolution_label.show() if hasattr(self, 'mode_label'):
self.gif_resolution_combo.show() self.mode_label.show()
if hasattr(self, 'conversion_mode_combo'):
self.conversion_mode_combo.show()
if hasattr(self, 'quality_label'):
self.quality_label.show()
if hasattr(self, 'conversion_quality_combo'):
self.conversion_quality_combo.show()
else: else:
self.gif_resolution_label.hide() if hasattr(self, 'mode_label'):
self.gif_resolution_combo.hide() self.mode_label.hide()
if hasattr(self, 'conversion_mode_combo'):
self.conversion_mode_combo.hide()
if hasattr(self, 'quality_label'):
self.quality_label.hide()
if hasattr(self, 'conversion_quality_combo'):
self.conversion_quality_combo.hide()
def browse_output(self): def browse_output(self):
directory = QFileDialog.getExistingDirectory(self, "Select Output Directory") directory = QFileDialog.getExistingDirectory(self, "Select Output Directory")
@@ -1736,6 +1850,23 @@ class TwitterMediaDownloaderGUI(QWidget):
self.update_button_states() self.update_button_states()
def create_colored_icon(self, svg_path, color):
with open(svg_path, 'r', encoding='utf-8') as f:
svg_content = f.read()
svg_content = svg_content.replace('stroke="currentColor"', f'stroke="{color}"')
svg_content = svg_content.replace('fill="currentColor"', f'fill="{color}"')
pixmap = QPixmap(24, 24)
pixmap.fill(Qt.GlobalColor.transparent)
renderer = QSvgRenderer(svg_content.encode('utf-8'))
painter = QPainter(pixmap)
renderer.render(painter)
painter.end()
return QIcon(pixmap)
def create_placeholder_icon(self, size=48): def create_placeholder_icon(self, size=48):
pixmap = QPixmap(size, size) pixmap = QPixmap(size, size)
pixmap.fill(Qt.GlobalColor.transparent) pixmap.fill(Qt.GlobalColor.transparent)
@@ -1821,34 +1952,46 @@ class TwitterMediaDownloaderGUI(QWidget):
has_selected = len(self.account_list.selectedItems()) > 0 has_selected = len(self.account_list.selectedItems()) > 0
self.download_selected_btn.setEnabled(has_accounts and has_selected) self.import_btn.setEnabled(True)
self.update_selected_btn.setEnabled(has_accounts and has_selected) self.export_btn.setEnabled(has_accounts)
self.remove_btn.setEnabled(has_accounts and has_selected) self.download_selected_btn.setEnabled(has_accounts)
self.clear_btn.setEnabled(has_accounts) self.update_selected_btn.setEnabled(has_accounts)
self.delete_btn.setEnabled(has_accounts)
if has_accounts: self.import_btn.show()
self.download_selected_btn.show() self.export_btn.show()
self.update_selected_btn.show() self.download_selected_btn.show()
self.remove_btn.show() self.update_selected_btn.show()
self.clear_btn.show() self.delete_btn.show()
else:
self.hide_account_buttons()
def hide_account_buttons(self): def hide_account_buttons(self):
buttons = [ self.import_btn.setEnabled(True)
self.download_selected_btn, self.export_btn.setEnabled(False)
self.update_selected_btn, self.download_selected_btn.setEnabled(False)
self.remove_btn, self.update_selected_btn.setEnabled(False)
self.clear_btn self.delete_btn.setEnabled(False)
]
for btn in buttons: self.import_btn.show()
btn.hide() self.export_btn.show()
self.download_selected_btn.show()
self.update_selected_btn.show()
self.delete_btn.show()
def download_selected(self): def download_selected(self):
selected_items = self.account_list.selectedItems() selected_items = self.account_list.selectedItems()
if not selected_items: if not selected_items:
self.log_output.append('Warning: Please select accounts to download.') reply = QMessageBox.question(
self,
'Confirm Download All',
f'No accounts selected. Download all {len(self.accounts)} account(s)?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.Yes:
self.download_accounts(list(range(len(self.accounts))))
return return
self.download_accounts([self.account_list.row(item) for item in selected_items]) self.download_accounts([self.account_list.row(item) for item in selected_items])
def download_all(self): def download_all(self):
@@ -1856,15 +1999,24 @@ class TwitterMediaDownloaderGUI(QWidget):
def update_selected(self): def update_selected(self):
selected_items = self.account_list.selectedItems() selected_items = self.account_list.selectedItems()
if not selected_items:
self.log_output.append('Warning: Please select accounts to update.')
return
selected_accounts = [] if not selected_items:
for item in selected_items: reply = QMessageBox.question(
index = self.account_list.row(item) self,
if index < len(self.accounts): 'Confirm Update All',
selected_accounts.append(self.accounts[index]) f'No accounts selected. Update all {len(self.accounts)} account(s)?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.No:
return
selected_accounts = self.accounts.copy()
else:
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: if not selected_accounts:
return return
@@ -1988,7 +2140,8 @@ class TwitterMediaDownloaderGUI(QWidget):
self.filename_format, self.filename_format,
self.download_batch_size, self.download_batch_size,
self.convert_gif, self.convert_gif,
self.gif_resolution self.gif_conversion_quality,
self.gif_conversion_mode
) )
self.worker.finished.connect(self.on_download_finished) self.worker.finished.connect(self.on_download_finished)
self.worker.progress.connect(self.update_progress) self.worker.progress.connect(self.update_progress)
@@ -2110,45 +2263,221 @@ class TwitterMediaDownloaderGUI(QWidget):
self.worker.pause() self.worker.pause()
self.pause_resume_btn.setText('Resume') self.pause_resume_btn.setText('Resume')
def remove_selected_accounts(self): def delete_accounts(self):
selected_indices = sorted([self.account_list.row(item) for item in self.account_list.selectedItems()], reverse=True) selected_items = self.account_list.selectedItems()
if not selected_indices: if not selected_items:
reply = QMessageBox.question(
self,
'Confirm Delete All',
f'No accounts selected. Delete all {len(self.accounts)} account(s) and their cache files?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.No:
return
for account in self.accounts:
username = account.username
if username:
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, account.media_type, is_batch=is_batch)
try:
if os.path.exists(cache_file):
os.remove(cache_file)
self.log_output.append(f'Removed temp file: {os.path.basename(cache_file)}')
except Exception as e:
self.log_output.append(f'Warning: Could not remove temp file {os.path.basename(cache_file)}: {str(e)}')
self.reset_state()
self.reset_ui()
self.tab_widget.setCurrentIndex(0)
else:
reply = QMessageBox.question(
self,
'Confirm Delete',
f'Delete {len(selected_items)} selected account(s) and their cache files?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.No:
return
selected_indices = sorted([self.account_list.row(item) for item in selected_items], reverse=True)
for index in selected_indices:
account = self.accounts[index]
username = account.username
if username:
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, account.media_type, is_batch=is_batch)
try:
if os.path.exists(cache_file):
os.remove(cache_file)
self.log_output.append(f'Removed temp file: {os.path.basename(cache_file)}')
except Exception as e:
self.log_output.append(f'Warning: Could not remove temp file {os.path.basename(cache_file)}: {str(e)}')
self.accounts.pop(index)
self.update_account_list()
self.update_button_states()
def export_accounts(self):
self.tab_widget.setCurrentIndex(1)
selected_items = self.account_list.selectedItems()
if not selected_items:
reply = QMessageBox.question(
self,
'Confirm Export All',
f'No accounts selected. Export all {len(self.accounts)} account(s)?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.No:
self.log_output.append('Export cancelled')
return
selected_accounts = self.accounts.copy()
else:
selected_accounts = []
for item in selected_items:
row = self.account_list.row(item)
if 0 <= row < len(self.accounts):
selected_accounts.append(self.accounts[row])
if not selected_accounts:
self.log_output.append('No valid accounts found for export')
return return
for index in selected_indices: export_dir = QFileDialog.getExistingDirectory(self, "Select Export Directory", self.last_output_path)
account = self.accounts[index] if not export_dir:
username = account.username self.log_output.append('Export cancelled')
if username: return
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, account.media_type, is_batch=is_batch) self.log_output.append(f'Starting export of {len(selected_accounts)} account(s)...')
try: exported_count = 0
if os.path.exists(cache_file):
os.remove(cache_file) for account in selected_accounts:
self.log_output.append(f'Removed temp file: {os.path.basename(cache_file)}') try:
except Exception as e: now = datetime.now()
self.log_output.append(f'Warning: Could not remove temp file {os.path.basename(cache_file)}: {str(e)}') date_str = now.strftime("%Y%m%d_%H%M%S")
self.accounts.pop(index) if account.fetch_mode == 'batch':
filename = f"{account.username}_batch_{date_str}.json"
else:
filename = f"{account.username}_{date_str}.json"
filepath = os.path.join(export_dir, filename)
export_data = {
'username': account.username,
'nick': account.nick,
'followers': account.followers,
'following': account.following,
'posts': account.posts,
'media_type': account.media_type,
'profile_image': account.profile_image,
'media_list': account.media_list,
'fetch_mode': account.fetch_mode,
'fetch_timestamp': account.fetch_timestamp,
'export_timestamp': now.isoformat()
}
with open(filepath, 'w', encoding='utf-8') as f:
json.dump(export_data, f, indent=2, ensure_ascii=False)
exported_count += 1
self.log_output.append(f'Exported: {filename}')
except Exception as e:
self.log_output.append(f'Error exporting {account.username}: {str(e)}')
self.log_output.append(f'Export completed: {exported_count}/{len(selected_accounts)} account(s) exported')
self.log_output.append(f'Export location: {export_dir}')
def import_accounts(self):
self.tab_widget.setCurrentIndex(1)
file_paths, _ = QFileDialog.getOpenFileNames(
self,
"Select JSON Files to Import",
self.last_output_path,
"JSON Files (*.json)"
)
if not file_paths:
self.log_output.append('Import cancelled')
return
self.log_output.append(f'Starting import of {len(file_paths)} file(s)...')
imported_count = 0
skipped_count = 0
error_count = 0
for filepath in file_paths:
try:
with open(filepath, 'r', encoding='utf-8') as f:
data = json.load(f)
username = data.get('username')
if not username:
self.log_output.append(f'Skipped {os.path.basename(filepath)}: No username found')
skipped_count += 1
continue
existing_account = next((acc for acc in self.accounts if acc.username == username), None)
if existing_account:
self.log_output.append(f'Skipped {username}: Already exists in dashboard')
skipped_count += 1
continue
account = Account(
username=username,
nick=data.get('nick', ''),
followers=data.get('followers', 0),
following=data.get('following', 0),
posts=data.get('posts', 0),
media_type=data.get('media_type', 'all'),
profile_image=data.get('profile_image'),
media_list=data.get('media_list', []),
fetch_mode=data.get('fetch_mode', 'all'),
fetch_timestamp=data.get('fetch_timestamp')
)
self.accounts.append(account)
account_info = {
'followers_count': account.followers,
'friends_count': account.following,
'statuses_count': account.posts,
'nick': account.nick,
'name': account.nick,
'profile_image': account.profile_image
}
cache_data = {
'account_info': account_info,
'timeline': account.media_list,
'metadata': {},
'is_batch': (account.fetch_mode == 'batch'),
'fetch_timestamp': account.fetch_timestamp
}
self.save_cached_data(username, account.media_type, cache_data, is_batch=(account.fetch_mode == 'batch'))
imported_count += 1
media_count = len(account.media_list) if account.media_list else 0
self.log_output.append(f'Imported: {username} ({media_count:,} media)')
except Exception as e:
self.log_output.append(f'Error importing {os.path.basename(filepath)}: {str(e)}')
error_count += 1
self.update_account_list() self.update_account_list()
self.update_button_states() self.update_button_states()
self.log_output.append(f'Import completed: {imported_count} imported, {skipped_count} skipped, {error_count} errors')
def clear_accounts(self):
for account in self.accounts:
username = account.username
if username:
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, account.media_type, is_batch=is_batch)
try:
if os.path.exists(cache_file):
os.remove(cache_file)
self.log_output.append(f'Removed temp file: {os.path.basename(cache_file)}')
except Exception as e:
self.log_output.append(f'Warning: Could not remove temp file {os.path.basename(cache_file)}: {str(e)}')
self.reset_state()
self.reset_ui()
self.tab_widget.setCurrentIndex(0) self.tab_widget.setCurrentIndex(0)
+490 -159
View File
@@ -15,11 +15,12 @@ import qdarktheme
from PyQt6.QtWidgets import ( from PyQt6.QtWidgets import (
QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit, QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit,
QLabel, QFileDialog, QListWidget, QTextEdit, QTabWidget, QAbstractItemView, QProgressBar, QCheckBox, QDialog, QLabel, QFileDialog, QListWidget, QTextEdit, QTabWidget, QAbstractItemView, QProgressBar, QCheckBox, QDialog,
QDialogButtonBox, QComboBox, QListWidgetItem QDialogButtonBox, QComboBox, QListWidgetItem, QMessageBox
) )
from PyQt6.QtCore import Qt, QThread, pyqtSignal, QUrl, QTimer, QTime, QSettings, QSize from PyQt6.QtCore import Qt, QThread, pyqtSignal, QUrl, QTimer, QTime, QSettings, QSize
from PyQt6.QtNetwork import QNetworkAccessManager, QNetworkRequest from PyQt6.QtNetwork import QNetworkAccessManager, QNetworkRequest
from PyQt6.QtGui import QIcon, QTextCursor, QDesktopServices, QPixmap, QPainter, QPainterPath from PyQt6.QtGui import QIcon, QTextCursor, QDesktopServices, QPixmap, QPainter, QPainterPath
from PyQt6.QtSvg import QSvgRenderer
from getMetadata import get_metadata from getMetadata import get_metadata
@dataclass @dataclass
@@ -85,7 +86,7 @@ class DownloadWorker(QThread):
download_progress = pyqtSignal(str, int) download_progress = pyqtSignal(str, int)
def __init__(self, accounts, outpath, auth_token, filename_format='username_date', def __init__(self, accounts, outpath, auth_token, filename_format='username_date',
download_batch_size=25, convert_gif=False, gif_resolution='original'): download_batch_size=25, convert_gif=False, gif_resolution='original', gif_conversion_mode='better'):
super().__init__() super().__init__()
self.accounts = accounts self.accounts = accounts
self.outpath = outpath self.outpath = outpath
@@ -94,6 +95,7 @@ class DownloadWorker(QThread):
self.download_batch_size = download_batch_size self.download_batch_size = download_batch_size
self.convert_gif = convert_gif self.convert_gif = convert_gif
self.gif_resolution = gif_resolution self.gif_resolution = gif_resolution
self.gif_conversion_mode = gif_conversion_mode
self.is_paused = False self.is_paused = False
self.is_stopped = False self.is_stopped = False
self.filepath_map = [] self.filepath_map = []
@@ -257,20 +259,24 @@ class DownloadWorker(QThread):
os.remove(fp) os.remove(fp)
skipped_count += 1 skipped_count += 1
conv_progress = int((idx / total_gifs) * 100) conv_progress = int((idx / total_gifs) * 100)
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} ({self.gif_resolution}) - Skipped (exists)", conv_progress) quality_display = f"({self.gif_conversion_mode}) - ({self.gif_resolution})"
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} {quality_display} - Skipped (exists)", conv_progress)
continue continue
except Exception: except Exception:
pass pass
if self.gif_resolution == 'high': if self.gif_conversion_mode == 'fast':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=800:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=800:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '15', '-y', gif_fp] ffmpeg_args = [ffmpeg_exe, '-i', fp, '-y', gif_fp]
elif self.gif_resolution == 'medium':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=600:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=600:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '10', '-y', gif_fp]
elif self.gif_resolution == 'low':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=400:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=400:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '8', '-y', gif_fp]
else: else:
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'palettegen=stats_mode=full[palette];[0:v][palette]paletteuse=dither=sierra2_4a', '-y', gif_fp] if self.gif_resolution == 'high':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=800:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=800:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '15', '-y', gif_fp]
elif self.gif_resolution == 'medium':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=600:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=600:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '10', '-y', gif_fp]
elif self.gif_resolution == 'low':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'scale=400:-1:flags=lanczos,palettegen=stats_mode=full[palette];[0:v]scale=400:-1:flags=lanczos[scaled];[scaled][palette]paletteuse=dither=sierra2_4a', '-r', '8', '-y', gif_fp]
else:
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-lavfi', 'palettegen=stats_mode=full[palette];[0:v][palette]paletteuse=dither=sierra2_4a', '-y', gif_fp]
result = subprocess.run(ffmpeg_args, capture_output=True, creationflags=creationflags) result = subprocess.run(ffmpeg_args, capture_output=True, creationflags=creationflags)
if result.returncode == 0 and os.path.exists(gif_fp): if result.returncode == 0 and os.path.exists(gif_fp):
@@ -281,7 +287,8 @@ class DownloadWorker(QThread):
pass pass
conv_progress = int((idx / total_gifs) * 100) conv_progress = int((idx / total_gifs) * 100)
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} ({self.gif_resolution})", conv_progress) quality_display = f"({self.gif_conversion_mode}) - ({self.gif_resolution})"
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} {quality_display}", conv_progress)
if converted_count > 0 or skipped_count > 0: if converted_count > 0 or skipped_count > 0:
completion_msg = f"GIF conversion completed: {converted_count:,} converted" completion_msg = f"GIF conversion completed: {converted_count:,} converted"
if skipped_count > 0: if skipped_count > 0:
@@ -344,9 +351,9 @@ class UpdateDialog(QDialog):
class TwitterMediaDownloaderGUI(QWidget): class TwitterMediaDownloaderGUI(QWidget):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.current_version = "3.5" self.current_version = "3.7"
self.accounts = [] self.accounts = []
self.temp_dir = os.path.join(tempfile.gettempdir(), "twitterxmediabatchdownloader") self.temp_dir = os.path.join(Path.home(), ".twitterxmediabatchdownloader")
os.makedirs(self.temp_dir, exist_ok=True) os.makedirs(self.temp_dir, exist_ok=True)
self.reset_state() self.reset_state()
@@ -362,6 +369,8 @@ class TwitterMediaDownloaderGUI(QWidget):
self.media_type = self.settings.value('media_type', 'all') self.media_type = self.settings.value('media_type', 'all')
self.convert_gif = self.settings.value('convert_gif', False, type=bool) self.convert_gif = self.settings.value('convert_gif', False, type=bool)
self.gif_resolution = self.settings.value('gif_resolution', 'original') self.gif_resolution = self.settings.value('gif_resolution', 'original')
self.gif_conversion_mode = self.settings.value('gif_conversion_mode', 'better')
self.gif_conversion_quality = self.settings.value('gif_conversion_quality', 'original')
self.check_for_updates = self.settings.value('check_for_updates', True, type=bool) self.check_for_updates = self.settings.value('check_for_updates', True, type=bool)
self.current_theme_color = self.settings.value('theme_color', '#2196F3') self.current_theme_color = self.settings.value('theme_color', '#2196F3')
@@ -463,7 +472,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.setFixedWidth(650) self.setFixedWidth(650)
self.setMinimumHeight(350) self.setMinimumHeight(350)
icon_path = os.path.join(os.path.dirname(__file__), "icon.svg") icon_path = os.path.join(os.path.dirname(__file__), "icons", "icon.svg")
if os.path.exists(icon_path): if os.path.exists(icon_path):
self.setWindowIcon(QIcon(icon_path)) self.setWindowIcon(QIcon(icon_path))
@@ -545,25 +554,52 @@ class TwitterMediaDownloaderGUI(QWidget):
def setup_account_buttons(self): def setup_account_buttons(self):
self.btn_layout = QHBoxLayout() self.btn_layout = QHBoxLayout()
self.download_selected_btn = QPushButton('Download Selected') self.import_btn = QPushButton(' Import')
self.update_selected_btn = QPushButton('Update Selected') self.export_btn = QPushButton(' Export')
self.remove_btn = QPushButton('Remove Selected') self.download_selected_btn = QPushButton(' Download')
self.clear_btn = QPushButton('Clear') self.update_selected_btn = QPushButton(' Update')
self.delete_btn = QPushButton(' Delete')
for btn in [self.download_selected_btn, self.update_selected_btn, self.remove_btn, self.clear_btn]: icon_dir = os.path.join(os.path.dirname(__file__), 'icons')
btn.setMinimumWidth(120) accent_color = self.current_theme_color
self.import_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'database-import.svg'), accent_color))
self.export_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'database-export.svg'), accent_color))
self.download_selected_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'download.svg'), accent_color))
self.update_selected_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'reload.svg'), accent_color))
self.delete_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'trash.svg'), accent_color))
for btn in [self.import_btn, self.export_btn, self.download_selected_btn,
self.update_selected_btn, self.delete_btn]:
btn.setMinimumWidth(100)
btn.setCursor(Qt.CursorShape.PointingHandCursor) btn.setCursor(Qt.CursorShape.PointingHandCursor)
btn.setIconSize(QSize(18, 18))
self.import_btn.clicked.connect(self.import_accounts)
self.export_btn.clicked.connect(self.export_accounts)
self.download_selected_btn.clicked.connect(self.download_selected) self.download_selected_btn.clicked.connect(self.download_selected)
self.update_selected_btn.clicked.connect(self.update_selected) self.update_selected_btn.clicked.connect(self.update_selected)
self.remove_btn.clicked.connect(self.remove_selected_accounts) self.delete_btn.clicked.connect(self.delete_accounts)
self.clear_btn.clicked.connect(self.clear_accounts)
self.btn_layout.addStretch() self.btn_layout.addStretch()
for btn in [self.download_selected_btn, self.update_selected_btn, self.remove_btn, self.clear_btn]: for btn in [self.import_btn, self.export_btn, self.download_selected_btn,
self.update_selected_btn, self.delete_btn]:
self.btn_layout.addWidget(btn, 1) self.btn_layout.addWidget(btn, 1)
self.btn_layout.addStretch() self.btn_layout.addStretch()
def update_button_icons(self):
if not hasattr(self, 'import_btn'):
return
icon_dir = os.path.join(os.path.dirname(__file__), 'icons')
accent_color = self.current_theme_color
self.import_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'database-import.svg'), accent_color))
self.export_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'database-export.svg'), accent_color))
self.download_selected_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'download.svg'), accent_color))
self.update_selected_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'reload.svg'), accent_color))
self.delete_btn.setIcon(self.create_colored_icon(os.path.join(icon_dir, 'trash.svg'), accent_color))
def setup_process_tab(self): def setup_process_tab(self):
self.process_tab = QWidget() self.process_tab = QWidget()
process_layout = QVBoxLayout() process_layout = QVBoxLayout()
@@ -707,6 +743,37 @@ class TwitterMediaDownloaderGUI(QWidget):
first_row_layout = QHBoxLayout() first_row_layout = QHBoxLayout()
first_row_layout.setSpacing(5) first_row_layout.setSpacing(5)
timeline_label = QLabel("Timeline:")
self.timeline_type_combo = QComboBox()
self.timeline_type_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.timeline_type_combo.setFixedWidth(75)
timeline_types = [
('media', 'Media'),
('timeline', 'Post'),
('tweets', 'Tweets'),
('with_replies', 'Replies')
]
for value, display in timeline_types:
self.timeline_type_combo.addItem(display, value)
self.timeline_type_combo.currentTextChanged.connect(self.save_settings)
first_row_layout.addWidget(timeline_label)
first_row_layout.addWidget(self.timeline_type_combo)
first_row_layout.addSpacing(5)
media_label = QLabel("Media:")
self.media_type_combo = QComboBox()
self.media_type_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.media_type_combo.setFixedWidth(85)
media_types = [('all', 'All'), ('image', 'Image'), ('video', 'Video'), ('gif', 'GIF')]
for value, display in media_types:
self.media_type_combo.addItem(display, value)
self.media_type_combo.currentTextChanged.connect(self.save_settings)
first_row_layout.addWidget(media_label)
first_row_layout.addWidget(self.media_type_combo)
first_row_layout.addSpacing(5)
self.batch_checkbox = QCheckBox("Fetch Batch") self.batch_checkbox = QCheckBox("Fetch Batch")
self.batch_checkbox.setCursor(Qt.CursorShape.PointingHandCursor) self.batch_checkbox.setCursor(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")
@@ -728,52 +795,41 @@ class TwitterMediaDownloaderGUI(QWidget):
self.size_label.hide() self.size_label.hide()
self.batch_size_combo.hide() self.batch_size_combo.hide()
first_row_layout.addSpacing(5)
timeline_label = QLabel("Timeline Type:")
self.timeline_type_combo = QComboBox()
self.timeline_type_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.timeline_type_combo.setFixedWidth(75)
timeline_types = [
('media', 'Media'),
('timeline', 'Post'),
('tweets', 'Tweets'),
('with_replies', 'Replies')
]
for value, display in timeline_types:
self.timeline_type_combo.addItem(display, value)
self.timeline_type_combo.currentTextChanged.connect(self.save_settings)
first_row_layout.addWidget(timeline_label)
first_row_layout.addWidget(self.timeline_type_combo)
first_row_layout.addSpacing(5)
media_type_label = QLabel("Media Type:")
self.media_type_combo = QComboBox()
self.media_type_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.media_type_combo.setFixedWidth(85)
media_types = [('all', 'All'), ('image', 'Image'), ('video', 'Video'), ('gif', 'GIF')]
for value, display in media_types:
self.media_type_combo.addItem(display, value)
self.media_type_combo.currentTextChanged.connect(self.save_settings)
first_row_layout.addWidget(media_type_label)
first_row_layout.addWidget(self.media_type_combo)
first_row_layout.addStretch() first_row_layout.addStretch()
gallery_dl_layout.addLayout(first_row_layout) gallery_dl_layout.addLayout(first_row_layout)
settings_layout.addWidget(gallery_dl_group) settings_layout.addWidget(gallery_dl_group)
download_group = QWidget() download_conversion_group = QWidget()
download_layout = QVBoxLayout(download_group) download_conversion_layout = QVBoxLayout(download_conversion_group)
download_layout.setSpacing(5) download_conversion_layout.setSpacing(5)
labels_layout = QHBoxLayout()
download_label_container = QWidget()
download_label_layout = QHBoxLayout(download_label_container)
download_label_layout.setContentsMargins(0, 0, 0, 0)
download_label = QLabel('Download Settings') download_label = QLabel('Download Settings')
download_label.setStyleSheet("font-weight: bold;") download_label.setStyleSheet("font-weight: bold;")
download_layout.addWidget(download_label) download_label_layout.addWidget(download_label)
download_label_layout.addStretch()
download_label_container.setFixedWidth(180)
labels_layout.addWidget(download_label_container)
batch_layout = QHBoxLayout() conversion_label = QLabel('Conversion Settings')
batch_label = QLabel('Concurrent Downloads:') conversion_label.setStyleSheet("font-weight: bold;")
labels_layout.addWidget(conversion_label)
labels_layout.addStretch()
download_conversion_layout.addLayout(labels_layout)
controls_layout = QHBoxLayout()
download_controls_container = QWidget()
download_controls_layout = QHBoxLayout(download_controls_container)
download_controls_layout.setContentsMargins(0, 0, 0, 0)
batch_label = QLabel('Concurrents:')
download_controls_layout.addWidget(batch_label)
self.download_batch_combo = QComboBox() self.download_batch_combo = QComboBox()
self.download_batch_combo.setCursor(Qt.CursorShape.PointingHandCursor) self.download_batch_combo.setCursor(Qt.CursorShape.PointingHandCursor)
@@ -782,40 +838,62 @@ class TwitterMediaDownloaderGUI(QWidget):
self.download_batch_combo.addItem(str(size)) self.download_batch_combo.addItem(str(size))
self.download_batch_combo.setCurrentText(str(self.download_batch_size)) self.download_batch_combo.setCurrentText(str(self.download_batch_size))
self.download_batch_combo.currentTextChanged.connect(self.save_settings) self.download_batch_combo.currentTextChanged.connect(self.save_settings)
download_controls_layout.addWidget(self.download_batch_combo)
download_controls_layout.addStretch()
download_controls_container.setFixedWidth(180)
controls_layout.addWidget(download_controls_container)
self.convert_gif_checkbox = QCheckBox("Convert GIF") self.convert_gif_checkbox = QCheckBox("Convert GIF")
self.convert_gif_checkbox.setCursor(Qt.CursorShape.PointingHandCursor) self.convert_gif_checkbox.setCursor(Qt.CursorShape.PointingHandCursor)
self.convert_gif_checkbox.setChecked(self.convert_gif) self.convert_gif_checkbox.setChecked(self.convert_gif)
self.convert_gif_checkbox.toggled.connect(self.handle_gif_checkbox) self.convert_gif_checkbox.toggled.connect(self.handle_conversion_checkbox)
controls_layout.addWidget(self.convert_gif_checkbox)
batch_layout.addWidget(batch_label) controls_layout.addSpacing(5)
batch_layout.addWidget(self.download_batch_combo)
batch_layout.addWidget(self.convert_gif_checkbox)
self.gif_resolution_label = QLabel("Converted GIF Quality:") mode_label = QLabel("Mode:")
self.gif_resolution_combo = QComboBox() self.conversion_mode_combo = QComboBox()
self.gif_resolution_combo.setCursor(Qt.CursorShape.PointingHandCursor) self.conversion_mode_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.gif_resolution_combo.setFixedWidth(85) self.conversion_mode_combo.setFixedWidth(80)
gif_resolutions = [ conversion_modes = [('better', 'Better'), ('fast', 'Fast')]
for value, display in conversion_modes:
self.conversion_mode_combo.addItem(display, value)
self.conversion_mode_combo.currentTextChanged.connect(self.save_settings)
controls_layout.addWidget(mode_label)
controls_layout.addWidget(self.conversion_mode_combo)
controls_layout.addSpacing(5)
quality_label = QLabel("Quality:")
self.conversion_quality_combo = QComboBox()
self.conversion_quality_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.conversion_quality_combo.setFixedWidth(85)
gif_qualities = [
('original', 'Original'), ('original', 'Original'),
('high', 'High'), ('high', 'High'),
('medium', 'Medium'), ('medium', 'Medium'),
('low', 'Low') ('low', 'Low')
] ]
for value, display in gif_resolutions: for value, display in gif_qualities:
self.gif_resolution_combo.addItem(display, value) self.conversion_quality_combo.addItem(display, value)
self.gif_resolution_combo.currentTextChanged.connect(self.save_settings) self.conversion_quality_combo.currentTextChanged.connect(self.save_settings)
batch_layout.addWidget(self.gif_resolution_label) controls_layout.addWidget(quality_label)
batch_layout.addWidget(self.gif_resolution_combo) controls_layout.addWidget(self.conversion_quality_combo)
self.mode_label = mode_label
self.quality_label = quality_label
if not self.convert_gif: if not self.convert_gif:
self.gif_resolution_label.hide() mode_label.hide()
self.gif_resolution_combo.hide() self.conversion_mode_combo.hide()
quality_label.hide()
self.conversion_quality_combo.hide()
batch_layout.addStretch() controls_layout.addStretch()
download_layout.addLayout(batch_layout) download_conversion_layout.addLayout(controls_layout)
settings_layout.addWidget(download_group) settings_layout.addWidget(download_conversion_group)
settings_layout.addStretch() settings_layout.addStretch()
settings_tab.setLayout(settings_layout) settings_tab.setLayout(settings_layout)
@@ -992,6 +1070,8 @@ class TwitterMediaDownloaderGUI(QWidget):
} }
) )
self.update_button_icons()
def setup_about_tab(self): def setup_about_tab(self):
about_tab = QWidget() about_tab = QWidget()
about_layout = QVBoxLayout() about_layout = QVBoxLayout()
@@ -1023,7 +1103,7 @@ class TwitterMediaDownloaderGUI(QWidget):
about_layout.addWidget(section_widget) about_layout.addWidget(section_widget)
footer_label = QLabel(f"v{self.current_version} | gallery-dl v1.30.6 | September 2025") footer_label = QLabel(f"v{self.current_version} | gallery-dl v1.30.9 | October 2025")
about_layout.addWidget(footer_label, alignment=Qt.AlignmentFlag.AlignCenter) about_layout.addWidget(footer_label, alignment=Qt.AlignmentFlag.AlignCenter)
about_tab.setLayout(about_layout) about_tab.setLayout(about_layout)
@@ -1048,9 +1128,13 @@ class TwitterMediaDownloaderGUI(QWidget):
self.settings.setValue('convert_gif', self.convert_gif_checkbox.isChecked()) self.settings.setValue('convert_gif', self.convert_gif_checkbox.isChecked())
self.convert_gif = self.convert_gif_checkbox.isChecked() self.convert_gif = self.convert_gif_checkbox.isChecked()
if hasattr(self, 'gif_resolution_combo'): if hasattr(self, 'conversion_mode_combo'):
self.settings.setValue('gif_resolution', self.gif_resolution_combo.currentData()) self.settings.setValue('gif_conversion_mode', self.conversion_mode_combo.currentData())
self.gif_resolution = self.gif_resolution_combo.currentData() self.gif_conversion_mode = self.conversion_mode_combo.currentData()
if hasattr(self, 'conversion_quality_combo'):
self.settings.setValue('gif_conversion_quality', self.conversion_quality_combo.currentData())
self.gif_conversion_quality = self.conversion_quality_combo.currentData()
self.settings.sync() self.settings.sync()
@@ -1100,17 +1184,36 @@ class TwitterMediaDownloaderGUI(QWidget):
self.convert_gif_checkbox.blockSignals(False) self.convert_gif_checkbox.blockSignals(False)
if convert_gif: if convert_gif:
self.gif_resolution_label.show() if hasattr(self, 'mode_label'):
self.gif_resolution_combo.show() self.mode_label.show()
if hasattr(self, 'conversion_mode_combo'):
self.conversion_mode_combo.show()
if hasattr(self, 'quality_label'):
self.quality_label.show()
if hasattr(self, 'conversion_quality_combo'):
self.conversion_quality_combo.show()
else: else:
self.gif_resolution_label.hide() if hasattr(self, 'mode_label'):
self.gif_resolution_combo.hide() self.mode_label.hide()
if hasattr(self, 'conversion_mode_combo'):
self.conversion_mode_combo.hide()
if hasattr(self, 'quality_label'):
self.quality_label.hide()
if hasattr(self, 'conversion_quality_combo'):
self.conversion_quality_combo.hide()
gif_resolution = self.settings.value('gif_resolution', 'original') gif_conversion_mode = self.settings.value('gif_conversion_mode', 'better')
if hasattr(self, 'gif_resolution_combo'): if hasattr(self, 'conversion_mode_combo'):
for i in range(self.gif_resolution_combo.count()): for i in range(self.conversion_mode_combo.count()):
if self.gif_resolution_combo.itemData(i) == gif_resolution: if self.conversion_mode_combo.itemData(i) == gif_conversion_mode:
self.gif_resolution_combo.setCurrentIndex(i) self.conversion_mode_combo.setCurrentIndex(i)
break
gif_conversion_quality = self.settings.value('gif_conversion_quality', 'original')
if hasattr(self, 'conversion_quality_combo'):
for i in range(self.conversion_quality_combo.count()):
if self.conversion_quality_combo.itemData(i) == gif_conversion_quality:
self.conversion_quality_combo.setCurrentIndex(i)
break break
last_username_url = self.settings.value('twitter_url', '') last_username_url = self.settings.value('twitter_url', '')
@@ -1137,16 +1240,28 @@ class TwitterMediaDownloaderGUI(QWidget):
self.fetch_btn.setText('Fetch') self.fetch_btn.setText('Fetch')
self.update_button_states() self.update_button_states()
def handle_gif_checkbox(self, checked): def handle_conversion_checkbox(self, checked):
self.convert_gif = checked self.convert_gif = checked
self.save_settings() self.save_settings()
if checked: if checked:
self.gif_resolution_label.show() if hasattr(self, 'mode_label'):
self.gif_resolution_combo.show() self.mode_label.show()
if hasattr(self, 'conversion_mode_combo'):
self.conversion_mode_combo.show()
if hasattr(self, 'quality_label'):
self.quality_label.show()
if hasattr(self, 'conversion_quality_combo'):
self.conversion_quality_combo.show()
else: else:
self.gif_resolution_label.hide() if hasattr(self, 'mode_label'):
self.gif_resolution_combo.hide() self.mode_label.hide()
if hasattr(self, 'conversion_mode_combo'):
self.conversion_mode_combo.hide()
if hasattr(self, 'quality_label'):
self.quality_label.hide()
if hasattr(self, 'conversion_quality_combo'):
self.conversion_quality_combo.hide()
def browse_output(self): def browse_output(self):
directory = QFileDialog.getExistingDirectory(self, "Select Output Directory") directory = QFileDialog.getExistingDirectory(self, "Select Output Directory")
@@ -1897,6 +2012,24 @@ class TwitterMediaDownloaderGUI(QWidget):
self.update_button_states() self.update_button_states()
def create_colored_icon(self, svg_path, color):
with open(svg_path, 'r', encoding='utf-8') as f:
svg_content = f.read()
svg_content = svg_content.replace('stroke="currentColor"', f'stroke="{color}"')
svg_content = svg_content.replace('fill="currentColor"', f'fill="{color}"')
pixmap = QPixmap(24, 24)
pixmap.fill(Qt.GlobalColor.transparent)
from PyQt6.QtSvg import QSvgRenderer
renderer = QSvgRenderer(svg_content.encode('utf-8'))
painter = QPainter(pixmap)
renderer.render(painter)
painter.end()
return QIcon(pixmap)
def create_placeholder_icon(self, size=48): def create_placeholder_icon(self, size=48):
pixmap = QPixmap(size, size) pixmap = QPixmap(size, size)
pixmap.fill(Qt.GlobalColor.transparent) pixmap.fill(Qt.GlobalColor.transparent)
@@ -1980,47 +2113,68 @@ class TwitterMediaDownloaderGUI(QWidget):
has_accounts = len(self.accounts) > 0 has_accounts = len(self.accounts) > 0
has_selected = len(self.account_list.selectedItems()) > 0 has_selected = len(self.account_list.selectedItems()) > 0
self.download_selected_btn.setEnabled(has_accounts and has_selected) self.import_btn.setEnabled(True)
self.update_selected_btn.setEnabled(has_accounts and has_selected) self.export_btn.setEnabled(has_accounts)
self.remove_btn.setEnabled(has_accounts and has_selected) self.download_selected_btn.setEnabled(has_accounts)
self.clear_btn.setEnabled(has_accounts) self.update_selected_btn.setEnabled(has_accounts)
self.delete_btn.setEnabled(has_accounts)
if has_accounts: self.import_btn.show()
self.download_selected_btn.show() self.export_btn.show()
self.update_selected_btn.show() self.download_selected_btn.show()
self.remove_btn.show() self.update_selected_btn.show()
self.clear_btn.show() self.delete_btn.show()
else:
self.hide_account_buttons()
def hide_account_buttons(self): def hide_account_buttons(self):
buttons = [ self.import_btn.setEnabled(True)
self.download_selected_btn, self.export_btn.setEnabled(False)
self.update_selected_btn, self.download_selected_btn.setEnabled(False)
self.remove_btn, self.update_selected_btn.setEnabled(False)
self.clear_btn self.delete_btn.setEnabled(False)
]
for btn in buttons: self.import_btn.show()
btn.hide() self.export_btn.show()
self.download_selected_btn.show()
self.update_selected_btn.show()
self.delete_btn.show()
def download_selected(self): def download_selected(self):
selected_items = self.account_list.selectedItems() selected_items = self.account_list.selectedItems()
if not selected_items: if not selected_items:
self.log_output.append('Warning: Please select accounts to download.') reply = QMessageBox.question(
self,
'Confirm Download All',
f'No accounts selected. Download all {len(self.accounts)} account(s)?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.Yes:
self.download_accounts(list(range(len(self.accounts))))
return return
self.download_accounts([self.account_list.row(item) for item in selected_items]) self.download_accounts([self.account_list.row(item) for item in selected_items])
def update_selected(self): def update_selected(self):
selected_items = self.account_list.selectedItems() selected_items = self.account_list.selectedItems()
if not selected_items:
self.log_output.append('Warning: Please select accounts to update.')
return
selected_accounts = [] if not selected_items:
for item in selected_items: reply = QMessageBox.question(
index = self.account_list.row(item) self,
if index < len(self.accounts): 'Confirm Update All',
selected_accounts.append(self.accounts[index]) f'No accounts selected. Update all {len(self.accounts)} account(s)?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.No:
return
selected_accounts = self.accounts.copy()
else:
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: if not selected_accounts:
return return
@@ -2144,7 +2298,8 @@ class TwitterMediaDownloaderGUI(QWidget):
self.filename_format, self.filename_format,
self.download_batch_size, self.download_batch_size,
self.convert_gif, self.convert_gif,
self.gif_resolution self.gif_conversion_quality,
self.gif_conversion_mode
) )
self.worker.finished.connect(self.on_download_finished) self.worker.finished.connect(self.on_download_finished)
self.worker.progress.connect(self.update_progress) self.worker.progress.connect(self.update_progress)
@@ -2265,45 +2420,221 @@ class TwitterMediaDownloaderGUI(QWidget):
self.worker.pause() self.worker.pause()
self.pause_resume_btn.setText('Resume') self.pause_resume_btn.setText('Resume')
def remove_selected_accounts(self): def delete_accounts(self):
selected_indices = sorted([self.account_list.row(item) for item in self.account_list.selectedItems()], reverse=True) selected_items = self.account_list.selectedItems()
if not selected_indices: if not selected_items:
reply = QMessageBox.question(
self,
'Confirm Delete All',
f'No accounts selected. Delete all {len(self.accounts)} account(s) and their cache files?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.No:
return
for account in self.accounts:
username = account.username
if username:
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, account.media_type, is_batch=is_batch)
try:
if os.path.exists(cache_file):
os.remove(cache_file)
self.log_output.append(f'Removed temp file: {os.path.basename(cache_file)}')
except Exception as e:
self.log_output.append(f'Warning: Could not remove temp file {os.path.basename(cache_file)}: {str(e)}')
self.reset_state()
self.reset_ui()
self.tab_widget.setCurrentIndex(0)
else:
reply = QMessageBox.question(
self,
'Confirm Delete',
f'Delete {len(selected_items)} selected account(s) and their cache files?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.No:
return
selected_indices = sorted([self.account_list.row(item) for item in selected_items], reverse=True)
for index in selected_indices:
account = self.accounts[index]
username = account.username
if username:
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, account.media_type, is_batch=is_batch)
try:
if os.path.exists(cache_file):
os.remove(cache_file)
self.log_output.append(f'Removed temp file: {os.path.basename(cache_file)}')
except Exception as e:
self.log_output.append(f'Warning: Could not remove temp file {os.path.basename(cache_file)}: {str(e)}')
self.accounts.pop(index)
self.update_account_list()
self.update_button_states()
def export_accounts(self):
self.tab_widget.setCurrentIndex(1)
selected_items = self.account_list.selectedItems()
if not selected_items:
reply = QMessageBox.question(
self,
'Confirm Export All',
f'No accounts selected. Export all {len(self.accounts)} account(s)?',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.No:
self.log_output.append('Export cancelled')
return
selected_accounts = self.accounts.copy()
else:
selected_accounts = []
for item in selected_items:
row = self.account_list.row(item)
if 0 <= row < len(self.accounts):
selected_accounts.append(self.accounts[row])
if not selected_accounts:
self.log_output.append('No valid accounts found for export')
return return
for index in selected_indices: export_dir = QFileDialog.getExistingDirectory(self, "Select Export Directory", self.last_output_path)
account = self.accounts[index] if not export_dir:
username = account.username self.log_output.append('Export cancelled')
if username: return
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, account.media_type, is_batch=is_batch) self.log_output.append(f'Starting export of {len(selected_accounts)} account(s)...')
try: exported_count = 0
if os.path.exists(cache_file):
os.remove(cache_file) for account in selected_accounts:
self.log_output.append(f'Removed temp file: {os.path.basename(cache_file)}') try:
except Exception as e: now = datetime.now()
self.log_output.append(f'Warning: Could not remove temp file {os.path.basename(cache_file)}: {str(e)}') date_str = now.strftime("%Y%m%d_%H%M%S")
self.accounts.pop(index) if account.fetch_mode == 'batch':
filename = f"{account.username}_batch_{date_str}.json"
else:
filename = f"{account.username}_{date_str}.json"
filepath = os.path.join(export_dir, filename)
export_data = {
'username': account.username,
'nick': account.nick,
'followers': account.followers,
'following': account.following,
'posts': account.posts,
'media_type': account.media_type,
'profile_image': account.profile_image,
'media_list': account.media_list,
'fetch_mode': account.fetch_mode,
'fetch_timestamp': account.fetch_timestamp,
'export_timestamp': now.isoformat()
}
with open(filepath, 'w', encoding='utf-8') as f:
json.dump(export_data, f, indent=2, ensure_ascii=False)
exported_count += 1
self.log_output.append(f'Exported: {filename}')
except Exception as e:
self.log_output.append(f'Error exporting {account.username}: {str(e)}')
self.log_output.append(f'Export completed: {exported_count}/{len(selected_accounts)} account(s) exported')
self.log_output.append(f'Export location: {export_dir}')
def import_accounts(self):
self.tab_widget.setCurrentIndex(1)
file_paths, _ = QFileDialog.getOpenFileNames(
self,
"Select JSON Files to Import",
self.last_output_path,
"JSON Files (*.json)"
)
if not file_paths:
self.log_output.append('Import cancelled')
return
self.log_output.append(f'Starting import of {len(file_paths)} file(s)...')
imported_count = 0
skipped_count = 0
error_count = 0
for filepath in file_paths:
try:
with open(filepath, 'r', encoding='utf-8') as f:
data = json.load(f)
username = data.get('username')
if not username:
self.log_output.append(f'Skipped {os.path.basename(filepath)}: No username found')
skipped_count += 1
continue
existing_account = next((acc for acc in self.accounts if acc.username == username), None)
if existing_account:
self.log_output.append(f'Skipped {username}: Already exists in dashboard')
skipped_count += 1
continue
account = Account(
username=username,
nick=data.get('nick', ''),
followers=data.get('followers', 0),
following=data.get('following', 0),
posts=data.get('posts', 0),
media_type=data.get('media_type', 'all'),
profile_image=data.get('profile_image'),
media_list=data.get('media_list', []),
fetch_mode=data.get('fetch_mode', 'all'),
fetch_timestamp=data.get('fetch_timestamp')
)
self.accounts.append(account)
account_info = {
'followers_count': account.followers,
'friends_count': account.following,
'statuses_count': account.posts,
'nick': account.nick,
'name': account.nick,
'profile_image': account.profile_image
}
cache_data = {
'account_info': account_info,
'timeline': account.media_list,
'metadata': {},
'is_batch': (account.fetch_mode == 'batch'),
'fetch_timestamp': account.fetch_timestamp
}
self.save_cached_data(username, account.media_type, cache_data, is_batch=(account.fetch_mode == 'batch'))
imported_count += 1
media_count = len(account.media_list) if account.media_list else 0
self.log_output.append(f'Imported: {username} ({media_count:,} media)')
except Exception as e:
self.log_output.append(f'Error importing {os.path.basename(filepath)}: {str(e)}')
error_count += 1
self.update_account_list() self.update_account_list()
self.update_button_states() self.update_button_states()
self.log_output.append(f'Import completed: {imported_count} imported, {skipped_count} skipped, {error_count} errors')
def clear_accounts(self):
for account in self.accounts:
username = account.username
if username:
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, account.media_type, is_batch=is_batch)
try:
if os.path.exists(cache_file):
os.remove(cache_file)
self.log_output.append(f'Removed temp file: {os.path.basename(cache_file)}')
except Exception as e:
self.log_output.append(f'Warning: Could not remove temp file {os.path.basename(cache_file)}: {str(e)}')
self.reset_state()
self.reset_ui()
self.tab_widget.setCurrentIndex(0) self.tab_widget.setCurrentIndex(0)
def update_timer(self): def update_timer(self):
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-database-export"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 6c0 1.657 3.582 3 8 3s8 -1.343 8 -3s-3.582 -3 -8 -3s-8 1.343 -8 3" /><path d="M4 6v6c0 1.657 3.582 3 8 3c1.118 0 2.183 -.086 3.15 -.241" /><path d="M20 12v-6" /><path d="M4 12v6c0 1.657 3.582 3 8 3c.157 0 .312 -.002 .466 -.005" /><path d="M16 19h6" /><path d="M19 16l3 3l-3 3" /></svg>

After

Width:  |  Height:  |  Size: 616 B

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-database-import"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 6c0 1.657 3.582 3 8 3s8 -1.343 8 -3s-3.582 -3 -8 -3s-8 1.343 -8 3" /><path d="M4 6v6c0 1.657 3.582 3 8 3c.856 0 1.68 -.05 2.454 -.144m5.546 -2.856v-6" /><path d="M4 12v6c0 1.657 3.582 3 8 3c.171 0 .341 -.002 .51 -.006" /><path d="M19 22v-6" /><path d="M22 19l-3 -3l-3 3" /></svg>

After

Width:  |  Height:  |  Size: 610 B

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-download"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2" /><path d="M7 11l5 5l5 -5" /><path d="M12 4l0 12" /></svg>

After

Width:  |  Height:  |  Size: 423 B

File renamed without changes.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 865 B

After

Width:  |  Height:  |  Size: 865 B

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-reload"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M19.933 13.041a8 8 0 1 1 -9.925 -8.788c3.899 -1 7.935 1.007 9.425 4.747" /><path d="M20 4v5h-5" /></svg>

After

Width:  |  Height:  |  Size: 423 B

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-trash"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 7l16 0" /><path d="M10 11l0 6" /><path d="M14 11l0 6" /><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12" /><path d="M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3" /></svg>

After

Width:  |  Height:  |  Size: 495 B

+1 -1
View File
@@ -1,3 +1,3 @@
{ {
"version": "3.4" "version": "3.6"
} }