This commit is contained in:
afkarxyz committed 2025-10-05 19:58:57 +07:00
1 parent 0f2427ad2b
commit 64bd8b4b2d
11 files changed
+959 -225

No files matched your search

+317 -75
View File
@@ -14,11 +14,12 @@ from dataclasses import dataclass
from PyQt6.QtWidgets import (
QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit,
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.QtNetwork import QNetworkAccessManager, QNetworkRequest
from PyQt6.QtGui import QIcon, QTextCursor, QDesktopServices, QPixmap, QPainter, QPainterPath
from PyQt6.QtSvg import QSvgRenderer
from getMetadata import get_metadata
@dataclass
@@ -351,9 +352,9 @@ class UpdateDialog(QDialog):
class TwitterMediaDownloaderGUI(QWidget):
def __init__(self):
super().__init__()
self.current_version = "3.6"
self.current_version = "3.7"
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)
self.reset_state()
@@ -471,7 +472,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.setMinimumWidth(670)
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):
self.setWindowIcon(QIcon(icon_path))
@@ -557,25 +558,52 @@ class TwitterMediaDownloaderGUI(QWidget):
def setup_account_buttons(self):
self.btn_layout = QHBoxLayout()
self.download_selected_btn = QPushButton('Download Selected')
self.update_selected_btn = QPushButton('Update Selected')
self.remove_btn = QPushButton('Remove Selected')
self.clear_btn = QPushButton('Clear')
self.import_btn = QPushButton(' Import')
self.export_btn = QPushButton(' Export')
self.download_selected_btn = QPushButton(' Download')
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]:
btn.setMinimumWidth(120)
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))
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.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.update_selected_btn.clicked.connect(self.update_selected)
self.remove_btn.clicked.connect(self.remove_selected_accounts)
self.clear_btn.clicked.connect(self.clear_accounts)
self.delete_btn.clicked.connect(self.delete_accounts)
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.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):
self.process_tab = QWidget()
process_layout = QVBoxLayout()
@@ -906,7 +934,7 @@ class TwitterMediaDownloaderGUI(QWidget):
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_tab.setLayout(about_layout)
@@ -1822,6 +1850,23 @@ class TwitterMediaDownloaderGUI(QWidget):
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):
pixmap = QPixmap(size, size)
pixmap.fill(Qt.GlobalColor.transparent)
@@ -1907,34 +1952,46 @@ class TwitterMediaDownloaderGUI(QWidget):
has_selected = len(self.account_list.selectedItems()) > 0
self.download_selected_btn.setEnabled(has_accounts and has_selected)
self.update_selected_btn.setEnabled(has_accounts and has_selected)
self.remove_btn.setEnabled(has_accounts and has_selected)
self.clear_btn.setEnabled(has_accounts)
self.import_btn.setEnabled(True)
self.export_btn.setEnabled(has_accounts)
self.download_selected_btn.setEnabled(has_accounts)
self.update_selected_btn.setEnabled(has_accounts)
self.delete_btn.setEnabled(has_accounts)
if has_accounts:
self.download_selected_btn.show()
self.update_selected_btn.show()
self.remove_btn.show()
self.clear_btn.show()
else:
self.hide_account_buttons()
self.import_btn.show()
self.export_btn.show()
self.download_selected_btn.show()
self.update_selected_btn.show()
self.delete_btn.show()
def hide_account_buttons(self):
buttons = [
self.download_selected_btn,
self.update_selected_btn,
self.remove_btn,
self.clear_btn
]
for btn in buttons:
btn.hide()
self.import_btn.setEnabled(True)
self.export_btn.setEnabled(False)
self.download_selected_btn.setEnabled(False)
self.update_selected_btn.setEnabled(False)
self.delete_btn.setEnabled(False)
self.import_btn.show()
self.export_btn.show()
self.download_selected_btn.show()
self.update_selected_btn.show()
self.delete_btn.show()
def download_selected(self):
selected_items = self.account_list.selectedItems()
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
self.download_accounts([self.account_list.row(item) for item in selected_items])
def download_all(self):
@@ -1942,15 +1999,24 @@ class TwitterMediaDownloaderGUI(QWidget):
def update_selected(self):
selected_items = self.account_list.selectedItems()
if not selected_items:
self.log_output.append('Warning: Please select accounts to update.')
return
selected_accounts = []
for item in selected_items:
index = self.account_list.row(item)
if index < len(self.accounts):
selected_accounts.append(self.accounts[index])
if not selected_items:
reply = QMessageBox.question(
self,
'Confirm Update All',
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:
return
@@ -2197,45 +2263,221 @@ class TwitterMediaDownloaderGUI(QWidget):
self.worker.pause()
self.pause_resume_btn.setText('Resume')
def remove_selected_accounts(self):
selected_indices = sorted([self.account_list.row(item) for item in self.account_list.selectedItems()], reverse=True)
def delete_accounts(self):
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
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)
export_dir = QFileDialog.getExistingDirectory(self, "Select Export Directory", self.last_output_path)
if not export_dir:
self.log_output.append('Export cancelled')
return
self.log_output.append(f'Starting export of {len(selected_accounts)} account(s)...')
exported_count = 0
for account in selected_accounts:
try:
now = datetime.now()
date_str = now.strftime("%Y%m%d_%H%M%S")
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_button_states()
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.log_output.append(f'Import completed: {imported_count} imported, {skipped_count} skipped, {error_count} errors')
self.tab_widget.setCurrentIndex(0)
+317 -75
View File
@@ -14,11 +14,12 @@ from dataclasses import dataclass
from PyQt6.QtWidgets import (
QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit,
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.QtNetwork import QNetworkAccessManager, QNetworkRequest
from PyQt6.QtGui import QIcon, QTextCursor, QDesktopServices, QPixmap, QPainter, QPainterPath
from PyQt6.QtSvg import QSvgRenderer
from getMetadata import get_metadata
@dataclass
@@ -351,9 +352,9 @@ class UpdateDialog(QDialog):
class TwitterMediaDownloaderGUI(QWidget):
def __init__(self):
super().__init__()
self.current_version = "3.6"
self.current_version = "3.7"
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)
self.reset_state()
@@ -471,7 +472,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.setMinimumWidth(670)
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):
self.setWindowIcon(QIcon(icon_path))
@@ -557,25 +558,52 @@ class TwitterMediaDownloaderGUI(QWidget):
def setup_account_buttons(self):
self.btn_layout = QHBoxLayout()
self.download_selected_btn = QPushButton('Download Selected')
self.update_selected_btn = QPushButton('Update Selected')
self.remove_btn = QPushButton('Remove Selected')
self.clear_btn = QPushButton('Clear')
self.import_btn = QPushButton(' Import')
self.export_btn = QPushButton(' Export')
self.download_selected_btn = QPushButton(' Download')
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]:
btn.setMinimumWidth(120)
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))
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.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.update_selected_btn.clicked.connect(self.update_selected)
self.remove_btn.clicked.connect(self.remove_selected_accounts)
self.clear_btn.clicked.connect(self.clear_accounts)
self.delete_btn.clicked.connect(self.delete_accounts)
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.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):
self.process_tab = QWidget()
process_layout = QVBoxLayout()
@@ -906,7 +934,7 @@ class TwitterMediaDownloaderGUI(QWidget):
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_tab.setLayout(about_layout)
@@ -1822,6 +1850,23 @@ class TwitterMediaDownloaderGUI(QWidget):
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):
pixmap = QPixmap(size, size)
pixmap.fill(Qt.GlobalColor.transparent)
@@ -1907,34 +1952,46 @@ class TwitterMediaDownloaderGUI(QWidget):
has_selected = len(self.account_list.selectedItems()) > 0
self.download_selected_btn.setEnabled(has_accounts and has_selected)
self.update_selected_btn.setEnabled(has_accounts and has_selected)
self.remove_btn.setEnabled(has_accounts and has_selected)
self.clear_btn.setEnabled(has_accounts)
self.import_btn.setEnabled(True)
self.export_btn.setEnabled(has_accounts)
self.download_selected_btn.setEnabled(has_accounts)
self.update_selected_btn.setEnabled(has_accounts)
self.delete_btn.setEnabled(has_accounts)
if has_accounts:
self.download_selected_btn.show()
self.update_selected_btn.show()
self.remove_btn.show()
self.clear_btn.show()
else:
self.hide_account_buttons()
self.import_btn.show()
self.export_btn.show()
self.download_selected_btn.show()
self.update_selected_btn.show()
self.delete_btn.show()
def hide_account_buttons(self):
buttons = [
self.download_selected_btn,
self.update_selected_btn,
self.remove_btn,
self.clear_btn
]
for btn in buttons:
btn.hide()
self.import_btn.setEnabled(True)
self.export_btn.setEnabled(False)
self.download_selected_btn.setEnabled(False)
self.update_selected_btn.setEnabled(False)
self.delete_btn.setEnabled(False)
self.import_btn.show()
self.export_btn.show()
self.download_selected_btn.show()
self.update_selected_btn.show()
self.delete_btn.show()
def download_selected(self):
selected_items = self.account_list.selectedItems()
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
self.download_accounts([self.account_list.row(item) for item in selected_items])
def download_all(self):
@@ -1942,15 +1999,24 @@ class TwitterMediaDownloaderGUI(QWidget):
def update_selected(self):
selected_items = self.account_list.selectedItems()
if not selected_items:
self.log_output.append('Warning: Please select accounts to update.')
return
selected_accounts = []
for item in selected_items:
index = self.account_list.row(item)
if index < len(self.accounts):
selected_accounts.append(self.accounts[index])
if not selected_items:
reply = QMessageBox.question(
self,
'Confirm Update All',
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:
return
@@ -2197,45 +2263,221 @@ class TwitterMediaDownloaderGUI(QWidget):
self.worker.pause()
self.pause_resume_btn.setText('Resume')
def remove_selected_accounts(self):
selected_indices = sorted([self.account_list.row(item) for item in self.account_list.selectedItems()], reverse=True)
def delete_accounts(self):
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
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)
export_dir = QFileDialog.getExistingDirectory(self, "Select Export Directory", self.last_output_path)
if not export_dir:
self.log_output.append('Export cancelled')
return
self.log_output.append(f'Starting export of {len(selected_accounts)} account(s)...')
exported_count = 0
for account in selected_accounts:
try:
now = datetime.now()
date_str = now.strftime("%Y%m%d_%H%M%S")
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_button_states()
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.log_output.append(f'Import completed: {imported_count} imported, {skipped_count} skipped, {error_count} errors')
self.tab_widget.setCurrentIndex(0)
+320 -75
View File
@@ -15,11 +15,12 @@ import qdarktheme
from PyQt6.QtWidgets import (
QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit,
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.QtNetwork import QNetworkAccessManager, QNetworkRequest
from PyQt6.QtGui import QIcon, QTextCursor, QDesktopServices, QPixmap, QPainter, QPainterPath
from PyQt6.QtSvg import QSvgRenderer
from getMetadata import get_metadata
@dataclass
@@ -350,9 +351,9 @@ class UpdateDialog(QDialog):
class TwitterMediaDownloaderGUI(QWidget):
def __init__(self):
super().__init__()
self.current_version = "3.6"
self.current_version = "3.7"
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)
self.reset_state()
@@ -471,7 +472,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.setFixedWidth(650)
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):
self.setWindowIcon(QIcon(icon_path))
@@ -553,25 +554,52 @@ class TwitterMediaDownloaderGUI(QWidget):
def setup_account_buttons(self):
self.btn_layout = QHBoxLayout()
self.download_selected_btn = QPushButton('Download Selected')
self.update_selected_btn = QPushButton('Update Selected')
self.remove_btn = QPushButton('Remove Selected')
self.clear_btn = QPushButton('Clear')
self.import_btn = QPushButton(' Import')
self.export_btn = QPushButton(' Export')
self.download_selected_btn = QPushButton(' Download')
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]:
btn.setMinimumWidth(120)
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))
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.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.update_selected_btn.clicked.connect(self.update_selected)
self.remove_btn.clicked.connect(self.remove_selected_accounts)
self.clear_btn.clicked.connect(self.clear_accounts)
self.delete_btn.clicked.connect(self.delete_accounts)
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.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):
self.process_tab = QWidget()
process_layout = QVBoxLayout()
@@ -1042,6 +1070,8 @@ class TwitterMediaDownloaderGUI(QWidget):
}
)
self.update_button_icons()
def setup_about_tab(self):
about_tab = QWidget()
about_layout = QVBoxLayout()
@@ -1073,7 +1103,7 @@ class TwitterMediaDownloaderGUI(QWidget):
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_tab.setLayout(about_layout)
@@ -1982,6 +2012,24 @@ class TwitterMediaDownloaderGUI(QWidget):
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):
pixmap = QPixmap(size, size)
pixmap.fill(Qt.GlobalColor.transparent)
@@ -2065,47 +2113,68 @@ class TwitterMediaDownloaderGUI(QWidget):
has_accounts = len(self.accounts) > 0
has_selected = len(self.account_list.selectedItems()) > 0
self.download_selected_btn.setEnabled(has_accounts and has_selected)
self.update_selected_btn.setEnabled(has_accounts and has_selected)
self.remove_btn.setEnabled(has_accounts and has_selected)
self.clear_btn.setEnabled(has_accounts)
self.import_btn.setEnabled(True)
self.export_btn.setEnabled(has_accounts)
self.download_selected_btn.setEnabled(has_accounts)
self.update_selected_btn.setEnabled(has_accounts)
self.delete_btn.setEnabled(has_accounts)
if has_accounts:
self.download_selected_btn.show()
self.update_selected_btn.show()
self.remove_btn.show()
self.clear_btn.show()
else:
self.hide_account_buttons()
self.import_btn.show()
self.export_btn.show()
self.download_selected_btn.show()
self.update_selected_btn.show()
self.delete_btn.show()
def hide_account_buttons(self):
buttons = [
self.download_selected_btn,
self.update_selected_btn,
self.remove_btn,
self.clear_btn
]
for btn in buttons:
btn.hide()
self.import_btn.setEnabled(True)
self.export_btn.setEnabled(False)
self.download_selected_btn.setEnabled(False)
self.update_selected_btn.setEnabled(False)
self.delete_btn.setEnabled(False)
self.import_btn.show()
self.export_btn.show()
self.download_selected_btn.show()
self.update_selected_btn.show()
self.delete_btn.show()
def download_selected(self):
selected_items = self.account_list.selectedItems()
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
self.download_accounts([self.account_list.row(item) for item in selected_items])
def update_selected(self):
selected_items = self.account_list.selectedItems()
if not selected_items:
self.log_output.append('Warning: Please select accounts to update.')
return
selected_accounts = []
for item in selected_items:
index = self.account_list.row(item)
if index < len(self.accounts):
selected_accounts.append(self.accounts[index])
if not selected_items:
reply = QMessageBox.question(
self,
'Confirm Update All',
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:
return
@@ -2351,45 +2420,221 @@ class TwitterMediaDownloaderGUI(QWidget):
self.worker.pause()
self.pause_resume_btn.setText('Resume')
def remove_selected_accounts(self):
selected_indices = sorted([self.account_list.row(item) for item in self.account_list.selectedItems()], reverse=True)
def delete_accounts(self):
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
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)
export_dir = QFileDialog.getExistingDirectory(self, "Select Export Directory", self.last_output_path)
if not export_dir:
self.log_output.append('Export cancelled')
return
self.log_output.append(f'Starting export of {len(selected_accounts)} account(s)...')
exported_count = 0
for account in selected_accounts:
try:
now = datetime.now()
date_str = now.strftime("%Y%m%d_%H%M%S")
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_button_states()
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.log_output.append(f'Import completed: {imported_count} imported, {skipped_count} skipped, {error_count} errors')
self.tab_widget.setCurrentIndex(0)
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