Compare commits

...
33 Commits
Author SHA1 Message Date
afkarxyz ddf6439893 v3.2 2025-07-26 12:27:48 +07:00
afkarxyz fed2bf7b0c Create latest.json 2025-07-26 12:24:54 +07:00
afkarxyz 241884de89 v3.2 2025-07-26 12:20:20 +07:00
afkarxyz 77b443ace0 v3.2 2025-07-26 11:55:30 +07:00
afkarxyz cd48b6f9bc Update README.md 2025-07-26 11:44:31 +07:00
afkarxyz 6f45b48047 v3.1 2025-07-19 05:45:26 +07:00
afkarxyz 7083c56c8b v3.1 2025-07-19 05:40:26 +07:00
afkarxyz 60cb3cbabd v3.1 2025-07-19 01:06:36 +07:00
afkarxyz b38bff238a . 2025-07-19 01:06:15 +07:00
afkarxyz d4d216ed6b v3.1 2025-07-19 01:04:35 +07:00
afkarxyz 129c007f6f v3.1 2025-07-18 23:42:12 +07:00
afkarxyz d78ad32c09 v3.1 2025-07-18 23:26:33 +07:00
afkarxyz 3975e5dd0e v3.0 2025-07-17 09:54:09 +07:00
afkarxyz 37f1d910cb v3.0 2025-07-14 09:49:50 +07:00
afkarxyz 74ed38cc31 v3.0 2025-07-14 09:24:38 +07:00
afkarxyz 2e326c39a0 v3.0 2025-07-14 09:22:56 +07:00
afkarxyz 39c37d4776 v3.0 2025-07-13 22:04:17 +07:00
afkarxyz 5709d76ceb . 2025-07-13 22:04:00 +07:00
afkarxyz 75b3549653 Update README.md 2025-07-13 21:55:44 +07:00
afkarxyz ebe739e612 Add files via upload 2025-07-13 21:20:26 +07:00
afkarxyz d423f20bad Update README.md 2025-07-13 21:14:28 +07:00
afkarxyz fba8a8ac45 Update README.md 2025-07-13 00:15:58 +07:00
afkarxyz a36c7613d2 Update README.md 2025-07-13 00:07:41 +07:00
afkarxyz c7615ed2f6 Merge pull request #16 from Alvin-Zilverstand/main
feat: Add Linux executable and compilation instructions
2025-07-12 22:12:19 +07:00
afkarxyz 0c17f1b419 Update README.md 2025-07-12 22:09:34 +07:00
Alvin dd38880366 feat: Add Linux executable and compilation instructions 2025-07-11 21:12:40 +02:00
afkarxyz 306d2c3c95 v3.0 2025-07-05 06:16:21 +07:00
afkarxyz 1caa59bbcf v3.0 2025-07-04 13:47:23 +07:00
afkarxyz 4d0021092c v3.0 2025-07-04 13:44:57 +07:00
afkarxyz 981bc8d9ec v3.0 2025-07-04 13:37:03 +07:00
afkarxyz c894bfd4d2 . 2025-07-04 13:36:31 +07:00
afkarxyz 61e50b8121 Update README.md 2025-07-04 13:29:21 +07:00
afkarxyz ba69dd7cf4 v2.9 2025-07-04 07:10:01 +07:00
9 changed files with 631 additions and 479 deletions

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
dist/
build/
*.spec
.venv/
-209
View File
@@ -1,209 +0,0 @@
import json
import re
import os
from datetime import datetime
from gallery_dl.extractor import twitter
def get_metadata(username, auth_token, timeline_type="timeline", batch_size=0, page=0, output_file=None):
url = f"https://x.com/{username}/{timeline_type}"
if timeline_type == "media":
extractor_class = twitter.TwitterMediaExtractor
elif timeline_type == "tweets":
extractor_class = twitter.TwitterTweetsExtractor
elif timeline_type == "with_replies":
extractor_class = twitter.TwitterRepliesExtractor
else:
extractor_class = twitter.TwitterTimelineExtractor
match = re.match(extractor_class.pattern, url)
if not match:
raise ValueError(f"Invalid URL for {timeline_type}: {url}")
extractor = extractor_class(match)
config_dict = {
"cookies": {
"auth_token": auth_token
}
}
if batch_size > 0:
config_dict["count"] = batch_size
extractor.config = lambda key, default=None: config_dict.get(key, default)
extractor.initialize()
if output_file is None:
current_dir = os.path.dirname(os.path.abspath(__file__))
output_file = os.path.join(current_dir, f"{username}_{timeline_type}.json")
structured_output = {
'account_info': {},
'total_urls': 0,
'timeline': []
}
if page > 0 and os.path.exists(output_file):
try:
with open(output_file, 'r', encoding='utf-8') as f:
structured_output = json.load(f)
print(f"Loaded existing data with {structured_output['total_urls']} items from {output_file}")
except json.JSONDecodeError:
print(f"Warning: Could not load existing data from {output_file}, starting fresh")
iterator = iter(extractor)
if batch_size > 0 and page > 0:
items_to_skip = page * batch_size
print(f"Skipping {items_to_skip} items for page {page}...")
if hasattr(extractor, '_cursor') and extractor._cursor:
print(f"Using cursor: {extractor._cursor}")
else:
skipped = 0
try:
for _ in range(items_to_skip):
next(iterator)
skipped += 1
except StopIteration:
print(f"Warning: Could only skip {skipped} items")
batch_items = []
new_timeline_entries = []
items_to_fetch = batch_size if batch_size > 0 else float('inf')
items_fetched = 0
try:
while items_fetched < items_to_fetch:
item = next(iterator)
batch_items.append(item)
items_fetched += 1
if isinstance(item, tuple) and len(item) >= 3:
media_url = item[1]
tweet_data = item[2]
if not structured_output['account_info'] and 'user' in tweet_data:
user = tweet_data['user']
user_date = user.get('date', '')
if isinstance(user_date, datetime):
user_date = user_date.strftime("%Y-%m-%d %H:%M:%S")
structured_output['account_info'] = {
'name': user.get('name', ''),
'nick': user.get('nick', ''),
'date': user_date,
'followers_count': user.get('followers_count', 0),
'friends_count': user.get('friends_count', 0),
'profile_image': user.get('profile_image', ''),
'statuses_count': user.get('statuses_count', 0)
}
if 'pbs.twimg.com' in media_url or 'video.twimg.com' in media_url:
tweet_date = tweet_data.get('date', datetime.now())
if isinstance(tweet_date, datetime):
tweet_date = tweet_date.strftime("%Y-%m-%d %H:%M:%S")
timeline_entry = {
'url': media_url,
'date': tweet_date,
'tweet_id': tweet_data.get('tweet_id', 0),
}
if 'type' in tweet_data:
timeline_entry['type'] = tweet_data['type']
new_timeline_entries.append(timeline_entry)
structured_output['total_urls'] += 1
except StopIteration:
pass
structured_output['timeline'].extend(new_timeline_entries)
with open(output_file, 'w', encoding='utf-8') as f:
json.dump(structured_output, f, ensure_ascii=False, indent=2)
if batch_size > 0:
print(f"Page {page}: Added {len(new_timeline_entries)} media URLs. Total URLs: {structured_output['total_urls']}")
else:
print(f"Added {len(new_timeline_entries)} media URLs. Total URLs: {structured_output['total_urls']}")
cursor_info = None
if hasattr(extractor, '_cursor') and extractor._cursor:
cursor_info = extractor._cursor
print(f"Current cursor: {cursor_info}")
return {
"items": batch_items,
"structured_output": structured_output,
"new_entries": len(new_timeline_entries),
"total_urls": structured_output['total_urls'],
"page": page,
"batch_size": batch_size,
"has_more": batch_size > 0 and items_fetched == batch_size,
"cursor": cursor_info
}
def continue_metadata_fetch(username, auth_token, timeline_type="media", batch_size=100, max_pages=None):
current_dir = os.path.dirname(os.path.abspath(__file__))
output_file = os.path.join(current_dir, f"{username}_{timeline_type}.json")
page = 0
total_urls = 0
has_more = True
if os.path.exists(output_file):
try:
with open(output_file, 'r', encoding='utf-8') as f:
existing_data = json.load(f)
total_urls = existing_data.get('total_urls', 0)
page = total_urls // batch_size if batch_size > 0 else 0
print(f"Continuing from page {page} with {total_urls} existing URLs")
except json.JSONDecodeError:
print(f"Warning: Could not load existing data from {output_file}, starting fresh")
while has_more and (max_pages is None or page < max_pages):
result = get_metadata(
username=username,
auth_token=auth_token,
timeline_type=timeline_type,
batch_size=batch_size,
page=page,
output_file=output_file
)
has_more = result["has_more"]
total_urls = result["total_urls"]
if not has_more:
print(f"No more items to fetch. Total URLs: {total_urls}")
break
page += 1
return total_urls
# Usage
if __name__ == "__main__":
username = "takomayuyi"
auth_token = ""
# Example 1: Non-batch mode - fetch all items at once
# This will fetch all items without pagination
# result = get_metadata(username, auth_token, "media")
# print(f"Non-batch mode: Added {result['new_entries']} media URLs")
# Example 2: Batch mode - fetch items in pages
# This will fetch only the specified page with the given batch size
result = get_metadata(username, auth_token, "media", batch_size=100, page=0)
print(f"Batch mode: Added {result['new_entries']} media URLs (page 0)")
# To fetch the next page:
# result = get_metadata(username, auth_token, "media", batch_size=100, page=1)
# To automatically fetch all pages in batch mode:
# total = continue_metadata_fetch(username, auth_token, "media", batch_size=100)
# print(f"Total media URLs fetched across all pages: {total}")
-161
View File
@@ -1,161 +0,0 @@
import json
import re
import os
from gallery_dl.extractor import twitter
def get_metadata(username, auth_token, timeline_type="timeline", batch_size=0, page=0, output_file=None):
url = f"https://x.com/{username}/{timeline_type}"
if timeline_type == "media":
extractor_class = twitter.TwitterMediaExtractor
elif timeline_type == "tweets":
extractor_class = twitter.TwitterTweetsExtractor
elif timeline_type == "with_replies":
extractor_class = twitter.TwitterRepliesExtractor
else:
extractor_class = twitter.TwitterTimelineExtractor
match = re.match(extractor_class.pattern, url)
if not match:
raise ValueError(f"Invalid URL for {timeline_type}: {url}")
extractor = extractor_class(match)
config_dict = {
"cookies": {
"auth_token": auth_token
}
}
if batch_size > 0:
config_dict["count"] = batch_size
extractor.config = lambda key, default=None: config_dict.get(key, default)
extractor.initialize()
if output_file is None:
current_dir = os.path.dirname(os.path.abspath(__file__))
output_file = os.path.join(current_dir, f"{username}_{timeline_type}.json")
all_items = []
if page > 0 and os.path.exists(output_file):
try:
with open(output_file, 'r', encoding='utf-8') as f:
all_items = json.load(f)
print(f"Loaded {len(all_items)} existing items from {output_file}")
except json.JSONDecodeError:
print(f"Warning: Could not load existing data from {output_file}, starting fresh")
iterator = iter(extractor)
if batch_size > 0 and page > 0:
items_to_skip = page * batch_size
print(f"Skipping {items_to_skip} items for page {page}...")
if hasattr(extractor, '_cursor') and extractor._cursor:
print(f"Using cursor: {extractor._cursor}")
else:
skipped = 0
try:
for _ in range(items_to_skip):
next(iterator)
skipped += 1
except StopIteration:
print(f"Warning: Could only skip {skipped} items")
batch_items = []
if batch_size > 0:
try:
for _ in range(batch_size):
item = next(iterator)
batch_items.append(item)
except StopIteration:
pass
else:
batch_items = list(iterator)
all_items.extend(batch_items)
with open(output_file, 'w', encoding='utf-8') as f:
json.dump(all_items, f, indent=2, default=str)
if batch_size > 0:
print(f"Page {page}: Retrieved {len(batch_items)} items. Total items: {len(all_items)}")
else:
print(f"Retrieved {len(batch_items)} items total")
cursor_info = None
if hasattr(extractor, '_cursor') and extractor._cursor:
cursor_info = extractor._cursor
print(f"Current cursor: {cursor_info}")
return {
"items": batch_items,
"total_items": len(all_items),
"page": page,
"batch_size": batch_size,
"has_more": batch_size > 0 and len(batch_items) == batch_size,
"cursor": cursor_info
}
def continue_metadata_fetch(username, auth_token, timeline_type="media", batch_size=100, max_pages=None):
current_dir = os.path.dirname(os.path.abspath(__file__))
output_file = os.path.join(current_dir, f"{username}_{timeline_type}.json")
page = 0
total_items = 0
has_more = True
if os.path.exists(output_file):
try:
with open(output_file, 'r', encoding='utf-8') as f:
existing_data = json.load(f)
total_items = len(existing_data)
page = total_items // batch_size
print(f"Continuing from page {page} with {total_items} existing items")
except json.JSONDecodeError:
print(f"Warning: Could not load existing data from {output_file}, starting fresh")
while has_more and (max_pages is None or page < max_pages):
result = get_metadata(
username=username,
auth_token=auth_token,
timeline_type=timeline_type,
batch_size=batch_size,
page=page,
output_file=output_file
)
has_more = result["has_more"]
total_items = result["total_items"]
if not has_more:
print(f"No more items to fetch. Total items: {total_items}")
break
page += 1
return total_items
# Usage
if __name__ == "__main__":
username = "takomayuyi"
auth_token = ""
# Example 1: Non-batch mode - fetch all items at once
# This will fetch all items without pagination
# result = get_metadata(username, auth_token, "media")
# print(f"Non-batch mode: Retrieved {len(result['items'])} items")
# Example 2: Batch mode - fetch items in pages
# This will fetch only the specified page with the given batch size
result = get_metadata(username, auth_token, "media", batch_size=100, page=0)
print(f"Batch mode: Retrieved {len(result['items'])} items (page 0)")
# To fetch the next page:
# result = get_metadata(username, auth_token, "media", batch_size=100, page=1)
# To automatically fetch all pages in batch mode:
# total = continue_metadata_fetch(username, auth_token, "media", batch_size=100)
# print(f"Total items fetched across all pages: {total}")
Binary file not shown.
+103 -4
View File
@@ -8,9 +8,29 @@
## 📥 Download ## 📥 Download
- Download the latest version of [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v2.8/TwitterXMediaBatchDownloader.exe) - **Windows**: [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.1/TwitterXMediaBatchDownloader.exe)
- **Linux**: [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.1/TwitterXMediaBatchDownloader)
- **Mac**: [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v3.1/TwitterXMediaBatchDownloader.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 downloaded application won't run❓
🐧 **Solution (Ubuntu/Linux)**: Open your terminal and run:
```bash
chmod +x TwitterXMediaBatchDownloader
```
https://github.com/user-attachments/assets/41231de2-e665-4d61-a4f4-62f424973af3
🍎 **Solution (macOS)**: Open your terminal and run:
```bash
xattr -rd com.apple.quarantine ~/Downloads/TwitterXMediaBatchDownloader.app
```
https://github.com/user-attachments/assets/56a89c03-29ab-45f1-979f-4317f45191f7
## ✨ Features ## ✨ Features
- Powered by `gallery-dl`, similar to `yt-dlp` - Powered by `gallery-dl`, similar to `yt-dlp`
@@ -21,11 +41,90 @@
## 🖼️ Screenshots ## 🖼️ Screenshots
![image](https://github.com/user-attachments/assets/7295213a-d9ba-4d75-8359-d43907b74aef) ![image](https://github.com/user-attachments/assets/216cfa1d-90eb-4b48-bacf-42e943f5bbee)
![image](https://github.com/user-attachments/assets/79fb6281-03c1-4629-9db2-c1f8990ca8b8) ![image](https://github.com/user-attachments/assets/cfb57b60-661d-4d82-a1f3-1e859a33e8c4)
![image](https://github.com/user-attachments/assets/b20b3431-f64c-4c18-8946-99ce52018caa) ## 🐧 Build Yourself (Ubuntu/Linux)
### 1. Install Required Packages
```bash
sudo apt install git python3-pip python3-venv
```
### 2. Clone the Repository
```bash
git clone https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader.git
cd Twitter-X-Media-Batch-Downloader
```
### 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.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.py
```
The `.app` bundle will be generated inside the `dist/` folder.
## 🔑 How to Obtain Auth Token ## 🔑 How to Obtain Auth Token
+513 -104
View File
@@ -11,9 +11,10 @@ from datetime import datetime
from pathlib import Path from pathlib import Path
from packaging import version from packaging import version
from dataclasses import dataclass from dataclasses import dataclass
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, QSpacerItem, QSizePolicy, QProgressBar, QCheckBox, QDialog, QLabel, QFileDialog, QListWidget, QTextEdit, QTabWidget, QAbstractItemView, QProgressBar, QCheckBox, QDialog,
QDialogButtonBox, QComboBox, QListWidgetItem QDialogButtonBox, QComboBox, QListWidgetItem
) )
from PyQt6.QtCore import Qt, QThread, pyqtSignal, QUrl, QTimer, QTime, QSettings, QSize from PyQt6.QtCore import Qt, QThread, pyqtSignal, QUrl, QTimer, QTime, QSettings, QSize
@@ -82,7 +83,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): download_batch_size=25, convert_gif=False, gif_resolution='original'):
super().__init__() super().__init__()
self.accounts = accounts self.accounts = accounts
self.outpath = outpath self.outpath = outpath
@@ -90,6 +91,7 @@ class DownloadWorker(QThread):
self.filename_format = filename_format self.filename_format = filename_format
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.is_paused = False self.is_paused = False
self.is_stopped = False self.is_stopped = False
self.filepath_map = [] self.filepath_map = []
@@ -190,7 +192,7 @@ class DownloadWorker(QThread):
progress_percent = int((completed + failed) / total * 100) progress_percent = int((completed + failed) / total * 100)
media_type_display = account.media_type if account.media_type != 'all' else 'media' media_type_display = account.media_type if account.media_type != 'all' else 'media'
self.download_progress.emit(f"Downloading {account.username}'s {media_type_display}: {completed + failed}/{total}", progress_percent) self.download_progress.emit(f"Downloading {account.username}'s {media_type_display}: {completed + failed:,}/{total:,}", progress_percent)
await asyncio.sleep(0.1) await asyncio.sleep(0.1)
@@ -219,7 +221,7 @@ class DownloadWorker(QThread):
overall_completed += completed overall_completed += completed
overall_skipped += skipped overall_skipped += skipped
overall_failed += failed overall_failed += failed
self.progress.emit(f"Account {account.username} ({media_type_display}): {completed} downloaded, {skipped} skipped, {failed} failed", self.progress.emit(f"Account {account.username} ({media_type_display}): {completed:,} downloaded, {skipped:,} skipped, {failed:,} failed",
int((i + 1) / total_accounts * 100)) int((i + 1) / total_accounts * 100))
if not self.is_stopped: if not self.is_stopped:
@@ -230,29 +232,70 @@ class DownloadWorker(QThread):
total_gifs = len(gif_items) total_gifs = len(gif_items)
if total_gifs > 0: if total_gifs > 0:
creationflags = subprocess.CREATE_NO_WINDOW if sys.platform == 'win32' else 0 creationflags = subprocess.CREATE_NO_WINDOW if sys.platform == 'win32' else 0
converted_count = 0
skipped_count = 0
self.progress.emit("Starting GIF conversion...", 0) self.progress.emit("Starting GIF conversion...", 0)
for idx, (item, fp) in enumerate(gif_items, start=1): for idx, (item, fp) in enumerate(gif_items, start=1):
if self.is_stopped: if self.is_stopped:
break break
while self.is_paused:
if self.is_stopped:
break
self.msleep(100)
if self.is_stopped:
break
gif_fp = fp.rsplit('.', 1)[0] + '.gif' gif_fp = fp.rsplit('.', 1)[0] + '.gif'
result = subprocess.run([ffmpeg_exe, '-i', fp, gif_fp], capture_output=True, creationflags=creationflags)
if result.returncode == 0 and os.path.exists(gif_fp): if os.path.exists(gif_fp):
try: try:
os.remove(fp) os.remove(fp)
skipped_count += 1
conv_progress = int((idx / total_gifs) * 100)
self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} ({self.gif_resolution}) - Skipped (exists)", conv_progress)
continue
except Exception: except Exception:
pass pass
if self.gif_resolution == 'high':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-vf', 'scale=800:-1:flags=lanczos', '-r', '15', gif_fp]
elif self.gif_resolution == 'medium':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-vf', 'scale=600:-1:flags=lanczos', '-r', '10', gif_fp]
elif self.gif_resolution == 'low':
ffmpeg_args = [ffmpeg_exe, '-i', fp, '-vf', 'scale=400:-1:flags=lanczos', '-r', '8', gif_fp]
else:
ffmpeg_args = [ffmpeg_exe, '-i', fp, gif_fp]
result = subprocess.run(ffmpeg_args, capture_output=True, creationflags=creationflags)
if result.returncode == 0 and os.path.exists(gif_fp):
try:
os.remove(fp)
converted_count += 1
except Exception:
pass
else:
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}", conv_progress) self.conversion_progress.emit(f"Converting GIF {idx:,}/{total_gifs:,} ({self.gif_resolution})", conv_progress)
if converted_count > 0 or skipped_count > 0:
completion_msg = f"GIF conversion completed: {converted_count:,} converted"
if skipped_count > 0:
completion_msg += f", {skipped_count:,} skipped (already exists)"
self.progress.emit(completion_msg, 100)
else:
self.progress.emit("GIF conversion completed", 100) self.progress.emit("GIF conversion completed", 100)
except Exception as conv_e: except Exception as conv_e:
self.progress.emit(f"GIF conversion error: {conv_e}", 0) self.progress.emit(f"GIF conversion error: {conv_e}", 0)
success_message = f"Download completed! {overall_completed} files downloaded" success_message = f"Download completed! {overall_completed:,} files downloaded"
if overall_skipped > 0: if overall_skipped > 0:
success_message += f", {overall_skipped} skipped" success_message += f", {overall_skipped:,} skipped"
if overall_failed > 0: if overall_failed > 0:
success_message += f", {overall_failed} failed" success_message += f", {overall_failed:,} failed"
self.finished.emit(True, success_message) self.finished.emit(True, success_message)
except Exception as e: except Exception as e:
@@ -271,26 +314,20 @@ class DownloadWorker(QThread):
class UpdateDialog(QDialog): class UpdateDialog(QDialog):
def __init__(self, current_version, new_version, parent=None): def __init__(self, current_version, new_version, parent=None):
super().__init__(parent) super().__init__(parent)
self.setWindowTitle("Update Available") self.setWindowTitle("Update Now")
self.setFixedWidth(400) self.setFixedWidth(400)
self.setModal(True) self.setModal(True)
layout = QVBoxLayout() layout = QVBoxLayout()
message = QLabel(f"A new version of Twitter/X Media Batch Downloader is available!\n\n" message = QLabel(f"Twitter/X Media Batch Downloader v{new_version} Available!")
f"Current version: v{current_version}\n"
f"New version: v{new_version}")
message.setWordWrap(True) message.setWordWrap(True)
layout.addWidget(message) layout.addWidget(message)
self.disable_check = QCheckBox("Turn off update checking")
self.disable_check.setCursor(Qt.CursorShape.PointingHandCursor)
layout.addWidget(self.disable_check)
button_box = QDialogButtonBox() button_box = QDialogButtonBox()
self.update_button = QPushButton("Update") self.update_button = QPushButton("Check")
self.update_button.setCursor(Qt.CursorShape.PointingHandCursor) self.update_button.setCursor(Qt.CursorShape.PointingHandCursor)
self.cancel_button = QPushButton("Cancel") self.cancel_button = QPushButton("Later")
self.cancel_button.setCursor(Qt.CursorShape.PointingHandCursor) self.cancel_button.setCursor(Qt.CursorShape.PointingHandCursor)
button_box.addButton(self.update_button, QDialogButtonBox.ButtonRole.AcceptRole) button_box.addButton(self.update_button, QDialogButtonBox.ButtonRole.AcceptRole)
@@ -306,7 +343,7 @@ class UpdateDialog(QDialog):
class TwitterMediaDownloaderGUI(QWidget): class TwitterMediaDownloaderGUI(QWidget):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.current_version = "2.9" self.current_version = "3.2"
self.accounts = [] self.accounts = []
self.temp_dir = os.path.join(tempfile.gettempdir(), "twitterxmediabatchdownloader") self.temp_dir = os.path.join(tempfile.gettempdir(), "twitterxmediabatchdownloader")
os.makedirs(self.temp_dir, exist_ok=True) os.makedirs(self.temp_dir, exist_ok=True)
@@ -323,11 +360,18 @@ class TwitterMediaDownloaderGUI(QWidget):
self.timeline_type = self.settings.value('timeline_type', 'media') self.timeline_type = self.settings.value('timeline_type', 'media')
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.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_page = 0 self.current_page = 0
self.media_info = None self.media_info = None
self.is_auto_fetching = False
self.current_fetch_username = None
self.current_fetch_media_type = None
self.current_fetch_metadata = None
self.profile_image_cache = {} self.profile_image_cache = {}
self.pending_downloads = {} self.pending_downloads = {}
self.network_manager = QNetworkAccessManager() self.network_manager = QNetworkAccessManager()
@@ -344,7 +388,7 @@ class TwitterMediaDownloaderGUI(QWidget):
def check_updates(self): def check_updates(self):
try: try:
response = requests.get("https://raw.githubusercontent.com/afkarxyz/Twitter-X-Media-Batch-Downloader/refs/heads/main/version.json") response = requests.get("https://raw.githubusercontent.com/afkarxyz/Twitter-X-Media-Batch-Downloader/refs/heads/main/latest.json")
if response.status_code == 200: if response.status_code == 200:
data = response.json() data = response.json()
new_version = data.get("version") new_version = data.get("version")
@@ -353,15 +397,11 @@ class TwitterMediaDownloaderGUI(QWidget):
dialog = UpdateDialog(self.current_version, new_version, self) dialog = UpdateDialog(self.current_version, new_version, self)
result = dialog.exec() result = dialog.exec()
if dialog.disable_check.isChecked():
self.settings.setValue('check_for_updates', False)
self.check_for_updates = False
if result == QDialog.DialogCode.Accepted: if result == QDialog.DialogCode.Accepted:
QDesktopServices.openUrl(QUrl("https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases")) QDesktopServices.openUrl(QUrl("https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases"))
except Exception as e: except Exception as e:
print(f"Error checking for updates: {e}") pass
def reset_state(self): def reset_state(self):
self.accounts.clear() self.accounts.clear()
@@ -374,12 +414,17 @@ class TwitterMediaDownloaderGUI(QWidget):
self.stop_btn.hide() self.stop_btn.hide()
self.pause_resume_btn.hide() self.pause_resume_btn.hide()
self.pause_resume_btn.setText('Pause') self.pause_resume_btn.setText('Pause')
self.next_batch_btn.hide()
self.auto_batch_btn.hide()
self.stop_fetch_btn.hide()
self.is_auto_fetching = False
self.enable_batch_buttons()
self.hide_account_buttons() self.hide_account_buttons()
def initUI(self): def initUI(self):
self.setWindowTitle('Twitter/X Media Batch Downloader') self.setWindowTitle('Twitter/X Media Batch Downloader')
self.setFixedWidth(650) self.setFixedWidth(650)
self.setFixedHeight(350) self.setMinimumHeight(350)
icon_path = os.path.join(os.path.dirname(__file__), "icon.svg") icon_path = os.path.join(os.path.dirname(__file__), "icon.svg")
if os.path.exists(icon_path): if os.path.exists(icon_path):
@@ -403,7 +448,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.twitter_url.setText(self.last_url) self.twitter_url.setText(self.last_url)
self.twitter_url.textChanged.connect(self.save_url) self.twitter_url.textChanged.connect(self.save_url)
self.fetch_btn = QPushButton('Fetch') self.fetch_btn = QPushButton('Fetch')
self.fetch_btn.setFixedWidth(100) self.fetch_btn.setFixedWidth(80)
self.fetch_btn.setCursor(Qt.CursorShape.PointingHandCursor) self.fetch_btn.setCursor(Qt.CursorShape.PointingHandCursor)
self.fetch_btn.clicked.connect(self.fetch_account) self.fetch_btn.clicked.connect(self.fetch_account)
@@ -419,6 +464,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.setup_dashboard_tab() self.setup_dashboard_tab()
self.setup_process_tab() self.setup_process_tab()
self.setup_settings_tab() self.setup_settings_tab()
self.setup_theme_tab()
self.setup_about_tab() self.setup_about_tab()
def setup_dashboard_tab(self): def setup_dashboard_tab(self):
@@ -431,9 +477,6 @@ class TwitterMediaDownloaderGUI(QWidget):
self.account_list.setIconSize(QSize(36, 36)) self.account_list.setIconSize(QSize(36, 36))
self.account_list.setStyleSheet(""" self.account_list.setStyleSheet("""
QListWidget { QListWidget {
background-color: palette(base);
border: 1px solid palette(mid);
border-radius: 4px;
padding: 0px; padding: 0px;
outline: none; outline: none;
} }
@@ -441,11 +484,9 @@ class TwitterMediaDownloaderGUI(QWidget):
padding: 8px 12px; padding: 8px 12px;
margin: 2px 0px; margin: 2px 0px;
border: none; border: none;
border-radius: 4px;
outline: none; outline: none;
} }
QListWidget::item:selected { QListWidget::item:selected {
background-color: palette(highlight);
border: none; border: none;
outline: none; outline: none;
} }
@@ -453,9 +494,6 @@ class TwitterMediaDownloaderGUI(QWidget):
border: none; border: none;
outline: none; outline: none;
} }
QListWidget::item:hover {
background-color: palette(midlight);
}
""") """)
dashboard_layout.addWidget(self.account_list) dashboard_layout.addWidget(self.account_list)
@@ -475,7 +513,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.clear_btn = QPushButton('Clear') self.clear_btn = QPushButton('Clear')
for btn in [self.download_selected_btn, self.download_all_btn, self.remove_btn, self.clear_btn]: for btn in [self.download_selected_btn, self.download_all_btn, self.remove_btn, self.clear_btn]:
btn.setFixedWidth(150) btn.setMinimumWidth(120)
btn.setCursor(Qt.CursorShape.PointingHandCursor) btn.setCursor(Qt.CursorShape.PointingHandCursor)
self.download_selected_btn.clicked.connect(self.download_selected) self.download_selected_btn.clicked.connect(self.download_selected)
@@ -485,7 +523,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.btn_layout.addStretch() self.btn_layout.addStretch()
for btn in [self.download_selected_btn, self.download_all_btn, self.remove_btn, self.clear_btn]: for btn in [self.download_selected_btn, self.download_all_btn, self.remove_btn, self.clear_btn]:
self.btn_layout.addWidget(btn) self.btn_layout.addWidget(btn, 1)
self.btn_layout.addStretch() self.btn_layout.addStretch()
def setup_process_tab(self): def setup_process_tab(self):
@@ -509,18 +547,47 @@ class TwitterMediaDownloaderGUI(QWidget):
process_layout.addLayout(progress_time_layout) process_layout.addLayout(progress_time_layout)
control_layout = QHBoxLayout() download_control_layout = QHBoxLayout()
self.stop_btn = QPushButton('Stop') self.stop_btn = QPushButton('Stop')
self.pause_resume_btn = QPushButton('Pause') self.pause_resume_btn = QPushButton('Pause')
self.stop_btn.setFixedWidth(120)
self.pause_resume_btn.setFixedWidth(120)
self.stop_btn.setCursor(Qt.CursorShape.PointingHandCursor) self.stop_btn.setCursor(Qt.CursorShape.PointingHandCursor)
self.pause_resume_btn.setCursor(Qt.CursorShape.PointingHandCursor) self.pause_resume_btn.setCursor(Qt.CursorShape.PointingHandCursor)
self.stop_btn.clicked.connect(self.stop_download) self.stop_btn.clicked.connect(self.stop_download)
self.pause_resume_btn.clicked.connect(self.toggle_pause_resume) self.pause_resume_btn.clicked.connect(self.toggle_pause_resume)
control_layout.addWidget(self.stop_btn)
control_layout.addWidget(self.pause_resume_btn) download_control_layout.addStretch()
process_layout.addLayout(control_layout) download_control_layout.addWidget(self.stop_btn)
download_control_layout.addWidget(self.pause_resume_btn)
download_control_layout.addStretch()
process_layout.addLayout(download_control_layout)
batch_control_layout = QHBoxLayout()
self.next_batch_btn = QPushButton('Next Batch')
self.auto_batch_btn = QPushButton('Auto Batch')
self.stop_fetch_btn = QPushButton('Stop Fetch')
for btn in [self.next_batch_btn, self.auto_batch_btn, self.stop_fetch_btn]:
btn.setFixedWidth(120)
btn.setCursor(Qt.CursorShape.PointingHandCursor)
self.next_batch_btn.setToolTip("Fetch next batch manually")
self.auto_batch_btn.setToolTip("Start automatic batch fetching")
self.stop_fetch_btn.setToolTip("Stop automatic batch fetching")
self.next_batch_btn.clicked.connect(self.fetch_next_batch)
self.auto_batch_btn.clicked.connect(self.start_auto_batch)
self.stop_fetch_btn.clicked.connect(self.stop_auto_fetch)
batch_control_layout.addStretch()
batch_control_layout.addWidget(self.next_batch_btn)
batch_control_layout.addWidget(self.auto_batch_btn)
batch_control_layout.addWidget(self.stop_fetch_btn)
batch_control_layout.addStretch()
process_layout.addLayout(batch_control_layout)
self.process_tab.setLayout(process_layout) self.process_tab.setLayout(process_layout)
@@ -530,6 +597,9 @@ class TwitterMediaDownloaderGUI(QWidget):
self.time_label.hide() self.time_label.hide()
self.stop_btn.hide() self.stop_btn.hide()
self.pause_resume_btn.hide() self.pause_resume_btn.hide()
self.next_batch_btn.hide()
self.auto_batch_btn.hide()
self.stop_fetch_btn.hide()
def setup_settings_tab(self): def setup_settings_tab(self):
settings_tab = QWidget() settings_tab = QWidget()
@@ -550,6 +620,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.output_dir.setText(self.last_output_path) self.output_dir.setText(self.last_output_path)
self.output_dir.textChanged.connect(self.save_settings) self.output_dir.textChanged.connect(self.save_settings)
self.output_browse = QPushButton('Browse') self.output_browse = QPushButton('Browse')
self.output_browse.setFixedWidth(80)
self.output_browse.setCursor(Qt.CursorShape.PointingHandCursor) self.output_browse.setCursor(Qt.CursorShape.PointingHandCursor)
self.output_browse.clicked.connect(self.browse_output) self.output_browse.clicked.connect(self.browse_output)
@@ -571,7 +642,7 @@ class TwitterMediaDownloaderGUI(QWidget):
auth_token_label = QLabel('Auth Token:') auth_token_label = QLabel('Auth Token:')
self.auth_token_input = QLineEdit() self.auth_token_input = QLineEdit()
self.auth_token_input.setPlaceholderText("Enter your Twitter/X auth_token") self.auth_token_input.setPlaceholderText("Enter Auth Token")
self.auth_token_input.setText(self.last_auth_token) self.auth_token_input.setText(self.last_auth_token)
self.auth_token_input.textChanged.connect(self.save_settings) self.auth_token_input.textChanged.connect(self.save_settings)
self.auth_token_input.setClearButtonEnabled(True) self.auth_token_input.setClearButtonEnabled(True)
@@ -593,7 +664,7 @@ class TwitterMediaDownloaderGUI(QWidget):
first_row_layout = QHBoxLayout() first_row_layout = QHBoxLayout()
first_row_layout.setSpacing(5) first_row_layout.setSpacing(5)
self.batch_checkbox = QCheckBox("Batch") self.batch_checkbox = QCheckBox("Fetch Batch")
self.batch_checkbox.setCursor(Qt.CursorShape.PointingHandCursor) self.batch_checkbox.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")
self.batch_checkbox.stateChanged.connect(self.handle_batch_checkbox) self.batch_checkbox.stateChanged.connect(self.handle_batch_checkbox)
@@ -611,12 +682,6 @@ class TwitterMediaDownloaderGUI(QWidget):
self.batch_size_combo.currentTextChanged.connect(self.save_batch_size) self.batch_size_combo.currentTextChanged.connect(self.save_batch_size)
first_row_layout.addWidget(self.batch_size_combo) first_row_layout.addWidget(self.batch_size_combo)
self.convert_gif_checkbox = QCheckBox("Convert GIF")
self.convert_gif_checkbox.setCursor(Qt.CursorShape.PointingHandCursor)
self.convert_gif_checkbox.setChecked(self.convert_gif)
self.convert_gif_checkbox.toggled.connect(self.save_settings)
first_row_layout.addWidget(self.convert_gif_checkbox)
self.size_label.hide() self.size_label.hide()
self.batch_size_combo.hide() self.batch_size_combo.hide()
@@ -665,7 +730,7 @@ class TwitterMediaDownloaderGUI(QWidget):
download_layout.addWidget(download_label) download_layout.addWidget(download_label)
batch_layout = QHBoxLayout() batch_layout = QHBoxLayout()
batch_label = QLabel('Batch Size:') batch_label = QLabel('Concurrent Downloads:')
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)
@@ -675,9 +740,35 @@ class TwitterMediaDownloaderGUI(QWidget):
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)
self.convert_gif_checkbox = QCheckBox("Convert GIF")
self.convert_gif_checkbox.setCursor(Qt.CursorShape.PointingHandCursor)
self.convert_gif_checkbox.setChecked(self.convert_gif)
self.convert_gif_checkbox.toggled.connect(self.handle_gif_checkbox)
batch_layout.addWidget(batch_label) batch_layout.addWidget(batch_label)
batch_layout.addWidget(self.download_batch_combo) batch_layout.addWidget(self.download_batch_combo)
batch_layout.addWidget(self.convert_gif_checkbox) batch_layout.addWidget(self.convert_gif_checkbox)
self.gif_resolution_label = QLabel("Converted GIF Quality:")
self.gif_resolution_combo = QComboBox()
self.gif_resolution_combo.setCursor(Qt.CursorShape.PointingHandCursor)
self.gif_resolution_combo.setFixedWidth(85)
gif_resolutions = [
('original', 'Original'),
('high', 'High'),
('medium', 'Medium'),
('low', 'Low')
]
for value, display in gif_resolutions:
self.gif_resolution_combo.addItem(display, value)
self.gif_resolution_combo.currentTextChanged.connect(self.save_settings)
batch_layout.addWidget(self.gif_resolution_label)
batch_layout.addWidget(self.gif_resolution_combo)
if not self.convert_gif:
self.gif_resolution_label.hide()
self.gif_resolution_combo.hide()
batch_layout.addStretch() batch_layout.addStretch()
download_layout.addLayout(batch_layout) download_layout.addLayout(batch_layout)
@@ -687,19 +778,190 @@ class TwitterMediaDownloaderGUI(QWidget):
settings_tab.setLayout(settings_layout) settings_tab.setLayout(settings_layout)
self.tab_widget.addTab(settings_tab, "Settings") self.tab_widget.addTab(settings_tab, "Settings")
def setup_theme_tab(self):
theme_tab = QWidget()
theme_layout = QVBoxLayout()
theme_layout.setSpacing(8)
theme_layout.setContentsMargins(15, 15, 15, 15)
grid_layout = QVBoxLayout()
self.color_buttons = {}
first_row_palettes = [
("Red", [
("#FFCDD2", "100"), ("#EF9A9A", "200"), ("#E57373", "300"), ("#EF5350", "400"), ("#F44336", "500"), ("#E53935", "600"), ("#D32F2F", "700"), ("#C62828", "800"), ("#B71C1C", "900"), ("#FF8A80", "A100"), ("#FF5252", "A200"), ("#FF1744", "A400"), ("#D50000", "A700")
]),
("Pink", [
("#F8BBD0", "100"), ("#F48FB1", "200"), ("#F06292", "300"), ("#EC407A", "400"), ("#E91E63", "500"), ("#D81B60", "600"), ("#C2185B", "700"), ("#AD1457", "800"), ("#880E4F", "900"), ("#FF80AB", "A100"), ("#FF4081", "A200"), ("#F50057", "A400"), ("#C51162", "A700")
]),
("Purple", [
("#E1BEE7", "100"), ("#CE93D8", "200"), ("#BA68C8", "300"), ("#AB47BC", "400"), ("#9C27B0", "500"), ("#8E24AA", "600"), ("#7B1FA2", "700"), ("#6A1B9A", "800"), ("#4A148C", "900"), ("#EA80FC", "A100"), ("#E040FB", "A200"), ("#D500F9", "A400"), ("#AA00FF", "A700")
])
]
second_row_palettes = [
("Deep Purple", [
("#D1C4E9", "100"), ("#B39DDB", "200"), ("#9575CD", "300"), ("#7E57C2", "400"), ("#673AB7", "500"), ("#5E35B1", "600"), ("#512DA8", "700"), ("#4527A0", "800"), ("#311B92", "900"), ("#B388FF", "A100"), ("#7C4DFF", "A200"), ("#651FFF", "A400"), ("#6200EA", "A700")
]),
("Indigo", [
("#C5CAE9", "100"), ("#9FA8DA", "200"), ("#7986CB", "300"), ("#5C6BC0", "400"), ("#3F51B5", "500"), ("#3949AB", "600"), ("#303F9F", "700"), ("#283593", "800"), ("#1A237E", "900"), ("#8C9EFF", "A100"), ("#536DFE", "A200"), ("#3D5AFE", "A400"), ("#304FFE", "A700")
]),
("Blue", [
("#BBDEFB", "100"), ("#90CAF9", "200"), ("#64B5F6", "300"), ("#42A5F5", "400"), ("#2196F3", "500"), ("#1E88E5", "600"), ("#1976D2", "700"), ("#1565C0", "800"), ("#0D47A1", "900"), ("#82B1FF", "A100"), ("#448AFF", "A200"), ("#2979FF", "A400"), ("#2962FF", "A700")
])
]
third_row_palettes = [
("Light Blue", [
("#B3E5FC", "100"), ("#81D4FA", "200"), ("#4FC3F7", "300"), ("#29B6F6", "400"), ("#03A9F4", "500"), ("#039BE5", "600"), ("#0288D1", "700"), ("#0277BD", "800"), ("#01579B", "900"), ("#80D8FF", "A100"), ("#40C4FF", "A200"), ("#00B0FF", "A400"), ("#0091EA", "A700")
]),
("Cyan", [
("#B2EBF2", "100"), ("#80DEEA", "200"), ("#4DD0E1", "300"), ("#26C6DA", "400"), ("#00BCD4", "500"), ("#00ACC1", "600"), ("#0097A7", "700"), ("#00838F", "800"), ("#006064", "900"), ("#84FFFF", "A100"), ("#18FFFF", "A200"), ("#00E5FF", "A400"), ("#00B8D4", "A700")
]),
("Teal", [
("#B2DFDB", "100"), ("#80CBC4", "200"), ("#4DB6AC", "300"), ("#26A69A", "400"), ("#009688", "500"), ("#00897B", "600"), ("#00796B", "700"), ("#00695C", "800"), ("#004D40", "900"), ("#A7FFEB", "A100"), ("#64FFDA", "A200"), ("#1DE9B6", "A400"), ("#00BFA5", "A700")
])
]
fourth_row_palettes = [
("Green", [
("#C8E6C9", "100"), ("#A5D6A7", "200"), ("#81C784", "300"), ("#66BB6A", "400"), ("#4CAF50", "500"), ("#43A047", "600"), ("#388E3C", "700"), ("#2E7D32", "800"), ("#1B5E20", "900"), ("#B9F6CA", "A100"), ("#69F0AE", "A200"), ("#00E676", "A400"), ("#00C853", "A700")
]),
("Light Green", [
("#DCEDC8", "100"), ("#C5E1A5", "200"), ("#AED581", "300"), ("#9CCC65", "400"), ("#8BC34A", "500"), ("#7CB342", "600"), ("#689F38", "700"), ("#558B2F", "800"), ("#33691E", "900"), ("#CCFF90", "A100"), ("#B2FF59", "A200"), ("#76FF03", "A400"), ("#64DD17", "A700")
]),
("Lime", [
("#F0F4C3", "100"), ("#E6EE9C", "200"), ("#DCE775", "300"), ("#D4E157", "400"), ("#CDDC39", "500"), ("#C0CA33", "600"), ("#AFB42B", "700"), ("#9E9D24", "800"), ("#827717", "900"), ("#F4FF81", "A100"), ("#EEFF41", "A200"), ("#C6FF00", "A400"), ("#AEEA00", "A700")
])
]
fifth_row_palettes = [
("Yellow", [
("#FFF9C4", "100"), ("#FFF59D", "200"), ("#FFF176", "300"), ("#FFEE58", "400"), ("#FFEB3B", "500"), ("#FDD835", "600"), ("#FBC02D", "700"), ("#F9A825", "800"), ("#F57F17", "900"), ("#FFFF8D", "A100"), ("#FFFF00", "A200"), ("#FFEA00", "A400"), ("#FFD600", "A700")
]),
("Amber", [
("#FFECB3", "100"), ("#FFE082", "200"), ("#FFD54F", "300"), ("#FFCA28", "400"), ("#FFC107", "500"), ("#FFB300", "600"), ("#FFA000", "700"), ("#FF8F00", "800"), ("#FF6F00", "900"), ("#FFE57F", "A100"), ("#FFD740", "A200"), ("#FFC400", "A400"), ("#FFAB00", "A700")
]),
("Orange", [
("#FFE0B2", "100"), ("#FFCC80", "200"), ("#FFB74D", "300"), ("#FFA726", "400"), ("#FF9800", "500"), ("#FB8C00", "600"), ("#F57C00", "700"), ("#EF6C00", "800"), ("#E65100", "900"), ("#FFD180", "A100"), ("#FFAB40", "A200"), ("#FF9100", "A400"), ("#FF6D00", "A700")
])
]
for row_palettes in [first_row_palettes, second_row_palettes, third_row_palettes, fourth_row_palettes, fifth_row_palettes]:
row_layout = QHBoxLayout()
row_layout.setSpacing(15)
for palette_name, colors in row_palettes:
column_layout = QVBoxLayout()
column_layout.setSpacing(3)
palette_label = QLabel(palette_name)
palette_label.setStyleSheet("margin-bottom: 2px;")
palette_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
column_layout.addWidget(palette_label)
color_buttons_layout = QHBoxLayout()
color_buttons_layout.setSpacing(3)
for color_hex, color_name in colors:
color_btn = QPushButton()
color_btn.setFixedSize(18, 18)
is_current = color_hex == self.current_theme_color
border_style = "2px solid #fff" if is_current else "none"
color_btn.setStyleSheet(f"""
QPushButton {{
background-color: {color_hex};
border: {border_style};
border-radius: 9px;
}}
QPushButton:hover {{
border: 2px solid #fff;
}}
QPushButton:pressed {{
border: 2px solid #fff;
}}
""")
color_btn.setCursor(Qt.CursorShape.PointingHandCursor)
color_btn.setToolTip(f"{palette_name} {color_name}\n{color_hex}")
color_btn.clicked.connect(lambda checked, color=color_hex, btn=color_btn: self.change_theme_color(color, btn))
self.color_buttons[color_hex] = color_btn
color_buttons_layout.addWidget(color_btn)
column_layout.addLayout(color_buttons_layout)
row_layout.addLayout(column_layout)
grid_layout.addLayout(row_layout)
theme_layout.addLayout(grid_layout)
theme_layout.addStretch()
theme_tab.setLayout(theme_layout)
self.tab_widget.addTab(theme_tab, "Theme")
def change_theme_color(self, color, clicked_btn=None):
if hasattr(self, 'color_buttons'):
for color_hex, btn in self.color_buttons.items():
if color_hex == self.current_theme_color:
btn.setStyleSheet(f"""
QPushButton {{
background-color: {color_hex};
border: none;
border-radius: 9px;
}}
QPushButton:hover {{
border: 2px solid #fff;
}}
QPushButton:pressed {{
border: 2px solid #fff;
}}
""")
break
self.current_theme_color = color
self.settings.setValue('theme_color', color)
self.settings.sync()
if clicked_btn:
clicked_btn.setStyleSheet(f"""
QPushButton {{
background-color: {color};
border: 2px solid #fff;
border-radius: 9px;
}}
QPushButton:hover {{
border: 2px solid #fff;
}}
QPushButton:pressed {{
border: 2px solid #fff;
}}
""")
qdarktheme.setup_theme(
custom_colors={
"[dark]": {
"primary": color,
}
}
)
def setup_about_tab(self): def setup_about_tab(self):
about_tab = QWidget() about_tab = QWidget()
about_layout = QVBoxLayout() about_layout = QVBoxLayout()
about_layout.setAlignment(Qt.AlignmentFlag.AlignCenter) about_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
about_layout.setSpacing(3) about_layout.setSpacing(15)
sections = [ sections = [
("Check for Updates", "https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases"), ("Check for Updates", "Check", "https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases"),
("Report an Issue", "https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/issues"), ("Report an Issue", "Report", "https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/issues"),
("gallery-dl Repository", "https://github.com/mikf/gallery-dl") ("gallery-dl Repository", "Visit", "https://github.com/mikf/gallery-dl")
] ]
for title, url in sections: for title, button_text, url in sections:
section_widget = QWidget() section_widget = QWidget()
section_layout = QVBoxLayout(section_widget) section_layout = QVBoxLayout(section_widget)
section_layout.setSpacing(10) section_layout.setSpacing(10)
@@ -710,33 +972,16 @@ class TwitterMediaDownloaderGUI(QWidget):
label.setAlignment(Qt.AlignmentFlag.AlignCenter) label.setAlignment(Qt.AlignmentFlag.AlignCenter)
section_layout.addWidget(label) section_layout.addWidget(label)
button = QPushButton("Click Here!") button = QPushButton(button_text)
button.setFixedWidth(150) button.setFixedSize(120, 25)
button.setStyleSheet("""
QPushButton {
background-color: palette(button);
color: palette(button-text);
border: 1px solid palette(mid);
padding: 6px;
border-radius: 15px;
}
QPushButton:hover {
background-color: palette(light);
}
QPushButton:pressed {
background-color: palette(midlight);
}
""")
button.setCursor(Qt.CursorShape.PointingHandCursor) button.setCursor(Qt.CursorShape.PointingHandCursor)
button.clicked.connect(lambda _, url=url: QDesktopServices.openUrl(QUrl(url if url.startswith(('http://', 'https://')) else f'https://{url}'))) button.clicked.connect(lambda _, url=url: QDesktopServices.openUrl(QUrl(url if url.startswith(('http://', 'https://')) else f'https://{url}')))
section_layout.addWidget(button, alignment=Qt.AlignmentFlag.AlignCenter) section_layout.addWidget(button, alignment=Qt.AlignmentFlag.AlignCenter)
about_layout.addWidget(section_widget)
if sections.index((title, url)) < len(sections) - 1:
spacer = QSpacerItem(20, 6, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed)
about_layout.addItem(spacer)
footer_label = QLabel("v2.9 | gallery-dl v1.30.0 | July 2025") about_layout.addWidget(section_widget)
footer_label.setStyleSheet("font-size: 12px; margin-top: 10px;")
footer_label = QLabel(f"v{self.current_version} | July 2025")
footer_label.setStyleSheet("font-size: 12px; margin-top: 20px;")
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)
@@ -760,6 +1005,11 @@ class TwitterMediaDownloaderGUI(QWidget):
if hasattr(self, 'convert_gif_checkbox'): if hasattr(self, 'convert_gif_checkbox'):
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'):
self.settings.setValue('gif_resolution', self.gif_resolution_combo.currentData())
self.gif_resolution = self.gif_resolution_combo.currentData()
self.settings.sync() self.settings.sync()
def load_settings(self): def load_settings(self):
@@ -795,24 +1045,38 @@ class TwitterMediaDownloaderGUI(QWidget):
self.download_batch_combo.setCurrentIndex(index) self.download_batch_combo.setCurrentIndex(index)
else: else:
self.download_batch_combo.setCurrentIndex(0) self.download_batch_combo.setCurrentIndex(0)
media_type = self.settings.value('media_type', 'all') media_type = self.settings.value('media_type', 'all')
for i in range(self.media_type_combo.count()): for i in range(self.media_type_combo.count()):
if self.media_type_combo.itemData(i) == media_type: if self.media_type_combo.itemData(i) == media_type:
self.media_type_combo.setCurrentIndex(i) self.media_type_combo.setCurrentIndex(i)
break break
convert_gif = self.settings.value('convert_gif', False, type=bool) convert_gif = self.settings.value('convert_gif', False, type=bool)
if hasattr(self, 'convert_gif_checkbox'): if hasattr(self, 'convert_gif_checkbox'):
self.convert_gif_checkbox.blockSignals(True) self.convert_gif_checkbox.blockSignals(True)
self.convert_gif_checkbox.setChecked(convert_gif) self.convert_gif_checkbox.setChecked(convert_gif)
self.convert_gif_checkbox.blockSignals(False) self.convert_gif_checkbox.blockSignals(False)
if convert_gif:
self.gif_resolution_label.show()
self.gif_resolution_combo.show()
else:
self.gif_resolution_label.hide()
self.gif_resolution_combo.hide()
gif_resolution = self.settings.value('gif_resolution', 'original')
if hasattr(self, 'gif_resolution_combo'):
for i in range(self.gif_resolution_combo.count()):
if self.gif_resolution_combo.itemData(i) == gif_resolution:
self.gif_resolution_combo.setCurrentIndex(i)
break
last_username_url = self.settings.value('twitter_url', '') last_username_url = self.settings.value('twitter_url', '')
if last_username_url and hasattr(self, 'twitter_url'): if last_username_url and hasattr(self, 'twitter_url'):
self.twitter_url.setText(last_username_url) self.twitter_url.setText(last_username_url)
except Exception as e: except Exception as e:
print(f"Error loading settings: {e}") pass
def handle_batch_checkbox(self, state): def handle_batch_checkbox(self, state):
if not hasattr(self, 'size_label') or not hasattr(self, 'batch_size_combo'): if not hasattr(self, 'size_label') or not hasattr(self, 'batch_size_combo'):
@@ -829,9 +1093,19 @@ class TwitterMediaDownloaderGUI(QWidget):
self.size_label.hide() self.size_label.hide()
self.batch_size_combo.hide() self.batch_size_combo.hide()
self.fetch_btn.setText('Fetch') self.fetch_btn.setText('Fetch')
self.update_button_states() self.update_button_states()
def handle_gif_checkbox(self, checked):
self.convert_gif = checked
self.save_settings()
if checked:
self.gif_resolution_label.show()
self.gif_resolution_combo.show()
else:
self.gif_resolution_label.hide()
self.gif_resolution_combo.hide()
def browse_output(self): def browse_output(self):
directory = QFileDialog.getExistingDirectory(self, "Select Output Directory") directory = QFileDialog.getExistingDirectory(self, "Select Output Directory")
if directory: if directory:
@@ -957,11 +1231,28 @@ class TwitterMediaDownloaderGUI(QWidget):
media_type = self.media_type_combo.currentData() media_type = self.media_type_combo.currentData()
existing_account = None
for account in self.accounts: for account in self.accounts:
if account.username == username and account.media_type == media_type: if account.username == username and account.media_type == media_type:
self.log_output.append(f'Account {username} with {media_type} media type already in list.') existing_account = account
return break
if existing_account:
self.accounts.remove(existing_account)
for is_batch in [True, False]:
cache_file = self.get_cache_file_path(username, media_type, is_batch=is_batch)
try:
if os.path.exists(cache_file):
os.remove(cache_file)
self.log_output.append(f'Removed existing cache: {os.path.basename(cache_file)}')
except Exception as e:
self.log_output.append(f'Warning: Could not remove cache {os.path.basename(cache_file)}: {str(e)}')
self.log_output.append(f'Preparing new batch for {username} ({media_type}) - cache cleared')
self.update_account_list()
if not existing_account:
cached_data = self.load_cached_data(username, media_type, is_batch=self.batch_mode) cached_data = self.load_cached_data(username, media_type, is_batch=self.batch_mode)
if cached_data: if cached_data:
try: try:
@@ -994,6 +1285,12 @@ class TwitterMediaDownloaderGUI(QWidget):
try: try:
self.reset_ui() self.reset_ui()
self.is_auto_fetching = False
self.current_fetch_username = username
self.current_fetch_media_type = media_type
self.disable_batch_buttons()
self.log_output.append(f'Fetching metadata for {username}...') self.log_output.append(f'Fetching metadata for {username}...')
self.tab_widget.setCurrentWidget(self.process_tab) self.tab_widget.setCurrentWidget(self.process_tab)
@@ -1023,8 +1320,14 @@ class TwitterMediaDownloaderGUI(QWidget):
account_info = data.get('account_info', {}) account_info = data.get('account_info', {})
timeline = data.get('timeline', []) timeline = data.get('timeline', [])
metadata = data.get('metadata', {}) metadata = data.get('metadata', {})
if not account_info or not timeline: if not account_info:
self.log_output.append('Error: Invalid data received') self.log_output.append('Error: Invalid account data received')
self.update_account_list()
return
if not timeline:
media_type_display = media_type if media_type != 'all' else 'media'
self.log_output.append(f'Error: No {media_type_display} found for account {username}')
self.update_account_list() self.update_account_list()
return return
existing_account = None existing_account = None
@@ -1069,27 +1372,37 @@ class TwitterMediaDownloaderGUI(QWidget):
self.update_account_list() self.update_account_list()
self.current_fetch_username = username
self.current_fetch_media_type = media_type
self.current_fetch_metadata = metadata
if self.batch_mode and metadata.get('has_more', False): if self.batch_mode and metadata.get('has_more', False):
current_page = metadata.get('page', 0) current_page = metadata.get('page', 0)
next_page = current_page + 1 next_page = current_page + 1
self.log_output.append(f'Batch {current_page + 1} completed. Next batch ({next_page + 1}) available.')
self.log_output.append(f'Auto-fetching batch {next_page + 1} for {username}...') if self.is_auto_fetching:
self.next_batch_btn.hide()
self.metadata_worker = MetadataFetchWorker( self.auto_batch_btn.hide()
username, self.stop_fetch_btn.show()
media_type, self.fetch_next_batch_internal()
batch_mode=True,
batch_size=self.batch_size,
page=next_page
)
self.metadata_worker.auth_token = self.auth_token_input.text().strip()
self.metadata_worker.finished.connect(lambda data: self.on_metadata_fetched(data, username, media_type))
self.metadata_worker.error.connect(self.on_metadata_error)
self.metadata_worker.start()
else: else:
self.next_batch_btn.show()
self.auto_batch_btn.show()
self.stop_fetch_btn.hide()
self.enable_batch_buttons()
self.log_output.append('Use "Next Batch" for manual fetch or "Auto Batch" for automatic fetching.')
else:
self.next_batch_btn.hide()
self.auto_batch_btn.hide()
self.stop_fetch_btn.hide()
self.is_auto_fetching = False
self.enable_batch_buttons()
if self.batch_mode: if self.batch_mode:
total_items = len(existing_account.media_list) total_items = len(existing_account.media_list)
self.log_output.append(f'Auto-fetch complete! Total: {total_items:,} media items for {username}') self.log_output.append(f'All batches complete! Total: {total_items:,} media items for {username}')
self.twitter_url.clear() self.twitter_url.clear()
self.tab_widget.setCurrentIndex(0) self.tab_widget.setCurrentIndex(0)
except Exception as e: except Exception as e:
@@ -1099,6 +1412,15 @@ class TwitterMediaDownloaderGUI(QWidget):
def on_metadata_error(self, error_message): def on_metadata_error(self, error_message):
self.log_output.append(f'Error: {error_message}') self.log_output.append(f'Error: {error_message}')
if self.is_auto_fetching:
self.stop_auto_fetch()
self.next_batch_btn.hide()
self.auto_batch_btn.hide()
self.stop_fetch_btn.hide()
self.enable_batch_buttons()
self.update_account_list() self.update_account_list()
def update_account_list(self): def update_account_list(self):
@@ -1190,7 +1512,7 @@ class TwitterMediaDownloaderGUI(QWidget):
self.pending_downloads[url] = reply self.pending_downloads[url] = reply
reply.finished.connect(lambda: self.on_profile_image_downloaded(reply, url)) reply.finished.connect(lambda: self.on_profile_image_downloaded(reply, url))
except Exception as e: except Exception as e:
print(f"Error downloading profile image: {e}") pass
def on_profile_image_downloaded(self, reply, image_url): def on_profile_image_downloaded(self, reply, image_url):
try: try:
@@ -1207,7 +1529,7 @@ class TwitterMediaDownloaderGUI(QWidget):
del self.pending_downloads[image_url] del self.pending_downloads[image_url]
except Exception as e: except Exception as e:
print(f"Error processing profile image: {e}") pass
finally: finally:
reply.deleteLater() reply.deleteLater()
@@ -1272,7 +1594,8 @@ class TwitterMediaDownloaderGUI(QWidget):
self.auth_token_input.text().strip(), self.auth_token_input.text().strip(),
self.filename_format, self.filename_format,
self.download_batch_size, self.download_batch_size,
self.convert_gif self.convert_gif,
self.gif_resolution
) )
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)
@@ -1288,6 +1611,10 @@ class TwitterMediaDownloaderGUI(QWidget):
self.stop_btn.show() self.stop_btn.show()
self.pause_resume_btn.show() self.pause_resume_btn.show()
self.next_batch_btn.hide()
self.auto_batch_btn.hide()
self.stop_fetch_btn.hide()
self.progress_bar.show() self.progress_bar.show()
self.progress_bar.setValue(0) self.progress_bar.setValue(0)
@@ -1366,6 +1693,12 @@ class TwitterMediaDownloaderGUI(QWidget):
self.download_selected_btn.setEnabled(True) self.download_selected_btn.setEnabled(True)
self.download_all_btn.setEnabled(True) self.download_all_btn.setEnabled(True)
if (self.batch_mode and self.current_fetch_metadata and
self.current_fetch_metadata.get('has_more', False) and not self.is_auto_fetching):
self.next_batch_btn.show()
self.auto_batch_btn.show()
self.enable_batch_buttons()
if success: if success:
self.log_output.append(f"\nStatus: {message}") self.log_output.append(f"\nStatus: {message}")
else: else:
@@ -1424,6 +1757,8 @@ class TwitterMediaDownloaderGUI(QWidget):
self.reset_ui() self.reset_ui()
self.tab_widget.setCurrentIndex(0) self.tab_widget.setCurrentIndex(0)
def update_timer(self): def update_timer(self):
self.elapsed_time = self.elapsed_time.addSecs(1) self.elapsed_time = self.elapsed_time.addSecs(1)
self.time_label.setText(self.elapsed_time.toString("hh:mm:ss")) self.time_label.setText(self.elapsed_time.toString("hh:mm:ss"))
@@ -1438,6 +1773,69 @@ class TwitterMediaDownloaderGUI(QWidget):
self.timer.stop() self.timer.stop()
self.time_label.hide() self.time_label.hide()
def fetch_next_batch(self):
if not self.current_fetch_metadata or not self.current_fetch_metadata.get('has_more', False):
self.log_output.append('No more batches available.')
return
self.disable_batch_buttons()
self.fetch_next_batch_internal()
def start_auto_batch(self):
if not self.current_fetch_metadata or not self.current_fetch_metadata.get('has_more', False):
self.log_output.append('No more batches available.')
return
self.is_auto_fetching = True
self.auto_batch_btn.hide()
self.next_batch_btn.hide()
self.stop_fetch_btn.show()
self.log_output.append('Auto batch mode enabled. Fetching will continue automatically...')
self.fetch_next_batch_internal()
def stop_auto_fetch(self):
self.is_auto_fetching = False
self.stop_fetch_btn.hide()
if self.current_fetch_metadata and self.current_fetch_metadata.get('has_more', False):
self.next_batch_btn.show()
self.auto_batch_btn.show()
self.log_output.append('Auto batch mode stopped. Use "Next Batch" or "Auto Batch" to continue.')
else:
self.log_output.append('Auto batch mode stopped.')
def disable_batch_buttons(self):
self.next_batch_btn.setEnabled(False)
self.auto_batch_btn.setEnabled(False)
def enable_batch_buttons(self):
self.next_batch_btn.setEnabled(True)
self.auto_batch_btn.setEnabled(True)
def fetch_next_batch_internal(self):
if not self.current_fetch_username or not self.current_fetch_media_type or not self.current_fetch_metadata:
return
self.disable_batch_buttons()
current_page = self.current_fetch_metadata.get('page', 0)
next_page = current_page + 1
self.log_output.append(f'Fetching batch {next_page + 1} for {self.current_fetch_username}...')
self.metadata_worker = MetadataFetchWorker(
self.current_fetch_username,
self.current_fetch_media_type,
batch_mode=True,
batch_size=self.batch_size,
page=next_page
)
self.metadata_worker.auth_token = self.auth_token_input.text().strip()
self.metadata_worker.finished.connect(lambda data: self.on_metadata_fetched(data, self.current_fetch_username, self.current_fetch_media_type))
self.metadata_worker.error.connect(self.on_metadata_error)
self.metadata_worker.start()
def show_account_buttons(self): def show_account_buttons(self):
self.download_selected_btn.show() self.download_selected_btn.show()
self.download_all_btn.show() self.download_all_btn.show()
@@ -1449,6 +1847,17 @@ def main():
os.chdir(os.path.dirname(sys.executable)) os.chdir(os.path.dirname(sys.executable))
app = QApplication(sys.argv) app = QApplication(sys.argv)
settings = QSettings('TwitterMediaDownloader', 'Settings')
theme_color = settings.value('theme_color', '#2196F3')
qdarktheme.setup_theme(
custom_colors={
"[dark]": {
"primary": theme_color,
}
}
)
window = TwitterMediaDownloaderGUI() window = TwitterMediaDownloaderGUI()
window.show() window.show()
sys.exit(app.exec()) sys.exit(app.exec())
+3
View File
@@ -0,0 +1,3 @@
{
"version": "3.2"
}
+7
View File
@@ -0,0 +1,7 @@
PyQt6
requests
aiohttp
imageio-ffmpeg
packaging
gallery-dl
pyqtdarktheme
+1 -1
View File
@@ -1,3 +1,3 @@
{ {
"version": "2.8" "version": "3.1"
} }