mirror of
https://github.com/Alvin-Zilverstand/Twitter-X-Media-Batch-Downloader.git
synced 2026-11-24 15:23:11 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91210f1c82 | ||
|
|
cb2a244e37 | ||
|
|
096425a0e1 | ||
|
|
c01a995b3d | ||
|
|
b28b4ef14c | ||
|
|
1e14fa6934 | ||
|
|
eac8a0f168 | ||
|
|
f3904c276c | ||
|
|
fe9724fa2f | ||
|
|
85e8f3135a | ||
|
|
1e2725f900 | ||
|
|
8e114a45e0 |
No files matched your search
@@ -4,7 +4,7 @@ import os
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from gallery_dl.extractor import twitter
|
from gallery_dl.extractor import twitter
|
||||||
|
|
||||||
def get_metadata(username):
|
def get_metadata(username, auth_token):
|
||||||
url = f"https://x.com/{username}/timeline"
|
url = f"https://x.com/{username}/timeline"
|
||||||
|
|
||||||
match = re.match(twitter.TwitterTimelineExtractor.pattern, url)
|
match = re.match(twitter.TwitterTimelineExtractor.pattern, url)
|
||||||
@@ -15,7 +15,7 @@ def get_metadata(username):
|
|||||||
|
|
||||||
extractor.config = lambda key, default=None: {
|
extractor.config = lambda key, default=None: {
|
||||||
"cookies": {
|
"cookies": {
|
||||||
"auth_token": ""
|
"auth_token": auth_token
|
||||||
}
|
}
|
||||||
}.get(key, default)
|
}.get(key, default)
|
||||||
|
|
||||||
@@ -75,4 +75,5 @@ def get_metadata(username):
|
|||||||
return output
|
return output
|
||||||
|
|
||||||
username = ""
|
username = ""
|
||||||
get_metadata(username)
|
auth_token = ""
|
||||||
|
get_metadata(username, auth_token)
|
||||||
+4
-3
@@ -3,7 +3,7 @@ import re
|
|||||||
import os
|
import os
|
||||||
from gallery_dl.extractor import twitter
|
from gallery_dl.extractor import twitter
|
||||||
|
|
||||||
def get_metadata(username):
|
def get_metadata(username, auth_token):
|
||||||
url = f"https://x.com/{username}/timeline"
|
url = f"https://x.com/{username}/timeline"
|
||||||
|
|
||||||
match = re.match(twitter.TwitterTimelineExtractor.pattern, url)
|
match = re.match(twitter.TwitterTimelineExtractor.pattern, url)
|
||||||
@@ -14,7 +14,7 @@ def get_metadata(username):
|
|||||||
|
|
||||||
extractor.config = lambda key, default=None: {
|
extractor.config = lambda key, default=None: {
|
||||||
"cookies": {
|
"cookies": {
|
||||||
"auth_token": ""
|
"auth_token": auth_token
|
||||||
}
|
}
|
||||||
}.get(key, default)
|
}.get(key, default)
|
||||||
|
|
||||||
@@ -31,4 +31,5 @@ def get_metadata(username):
|
|||||||
json.dump(all_items, f, indent=2, default=str)
|
json.dump(all_items, f, indent=2, default=str)
|
||||||
|
|
||||||
username = ""
|
username = ""
|
||||||
get_metadata(username)
|
auth_token = ""
|
||||||
|
get_metadata(username, auth_token)
|
||||||
@@ -8,18 +8,15 @@
|
|||||||
|
|
||||||
## Download
|
## Download
|
||||||
|
|
||||||
- Download the latest version of [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v1.4/TwitterXMediaBatchDownloader.exe)
|
- Download the latest version of [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v1.7/TwitterXMediaBatchDownloader.exe)
|
||||||
- If you're familiar with **userscripts**, please install it [here](https://greasyfork.org/en/scripts/523157-twitter-x-media-batch-downloader)
|
- If you're familiar with **userscripts**, please install it [here](https://greasyfork.org/en/scripts/523157-twitter-x-media-batch-downloader)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Uses the powerful `gallery-dl` library, similar to `yt-dlp`
|
- Uses the powerful `gallery-dl` library, similar to `yt-dlp`
|
||||||
- The ability to download media from **Withheld Accounts** (requires unchecking the Local option)
|
- The ability to download media from **Withheld Accounts** _(maybe requires checking the **Use gallery-dl API** option)_
|
||||||
- Simple and compact GUI
|
- Option to choose the media type to download: **All Media** (Image + GIF + Video) or just **Image/GIF/Video**
|
||||||
- Download images and videos in original quality
|
- Download images and videos in original quality
|
||||||
- Option to choose the media type to download: **media** (image + GIF + video) or just **image/GIF/video**
|
|
||||||
- **Batch** download settings, ranging from 10 to 100 files per download
|
|
||||||
- Filename format customization
|
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
@@ -43,12 +40,19 @@
|
|||||||
> - I suggest not using the **main account** to obtain the token.
|
> - I suggest not using the **main account** to obtain the token.
|
||||||
> - You can use https://temp-mail.io to register a Twitter account.
|
> - You can use https://temp-mail.io to register a Twitter account.
|
||||||
> - Using an auth token or cookies has the potential to get the **account suspended.**
|
> - Using an auth token or cookies has the potential to get the **account suspended.**
|
||||||
|
> - If too many media files are fetched, it will trigger a **rate limit**, and the media retrieval will fail.
|
||||||
|
|
||||||
1. Go to [Twitter's website](https://www.x.com/)
|
1. Go to [Twitter's website](https://www.x.com/)
|
||||||
2. Log into your account
|
2. Log into your account
|
||||||
3. Open the Developer Tools by pressing `F12`
|
3. Open the Developer Tools by pressing `F12`
|
||||||
4. Navigate to the **Application** tab, then select **Storage** > **Cookies**
|
4. Navigate to the **Application** tab, then select **Storage** > **Cookies**
|
||||||
5. Find and copy the `auth_token` value or use the browser extension [Cookie-Editor](https://cookie-editor.com/)
|
5. Find and copy the `auth_token` value or use the browser extension [X.com Auth Token Grabber](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v1.0/X.com.Auth.Token.Grabber.zip)
|
||||||
6. Do not log out of your account, as a new `auth_token` will be generated by Twitter
|
6. Do not log out of your account, as a new `auth_token` will be generated by Twitter
|
||||||
|
|
||||||
|
> X.com Auth Token Grabber
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
> Developer Tools
|
||||||
|
|
||||||

|

|
||||||
@@ -2,16 +2,18 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import asyncio
|
import asyncio
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import requests
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from packaging import version
|
||||||
from PyQt6.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout,
|
from PyQt6.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout,
|
||||||
QHBoxLayout, QLabel, QLineEdit, QPushButton,
|
QHBoxLayout, QLabel, QLineEdit, QPushButton,
|
||||||
QProgressBar, QFileDialog, QRadioButton, QComboBox,
|
QProgressBar, QFileDialog, QRadioButton, QComboBox,
|
||||||
QGroupBox, QCheckBox)
|
QGroupBox, QCheckBox, QDialog, QDialogButtonBox)
|
||||||
from PyQt6.QtCore import QThread, pyqtSignal, Qt, QSettings
|
from PyQt6.QtCore import QThread, pyqtSignal, Qt, QSettings, QTimer, QUrl
|
||||||
from PyQt6.QtGui import QIcon, QPixmap, QCursor, QPainter, QPainterPath
|
from PyQt6.QtGui import QIcon, QPixmap, QCursor, QPainter, QPainterPath, QDesktopServices
|
||||||
from gallery_dl.extractor import twitter
|
from gallery_dl.extractor import twitter
|
||||||
|
|
||||||
class ImageDownloader(QThread):
|
class ImageDownloader(QThread):
|
||||||
@@ -341,11 +343,50 @@ class MediaDownloader(QThread):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.error.emit(str(e))
|
self.error.emit(str(e))
|
||||||
|
|
||||||
|
class UpdateDialog(QDialog):
|
||||||
|
def __init__(self, current_version, new_version, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.setWindowTitle("Update Available")
|
||||||
|
self.setFixedWidth(400)
|
||||||
|
self.setModal(True)
|
||||||
|
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
|
||||||
|
message = QLabel(f"A new version of Twitter/X Media Batch Downloader is available!\n\n"
|
||||||
|
f"Current version: v{current_version}\n"
|
||||||
|
f"New version: v{new_version}")
|
||||||
|
message.setWordWrap(True)
|
||||||
|
layout.addWidget(message)
|
||||||
|
|
||||||
|
self.disable_check = QCheckBox("Turn off update checking")
|
||||||
|
self.disable_check.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||||
|
layout.addWidget(self.disable_check)
|
||||||
|
|
||||||
|
button_box = QDialogButtonBox()
|
||||||
|
self.update_button = QPushButton("Update")
|
||||||
|
self.update_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||||
|
self.cancel_button = QPushButton("Cancel")
|
||||||
|
self.cancel_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||||
|
|
||||||
|
button_box.addButton(self.update_button, QDialogButtonBox.ButtonRole.AcceptRole)
|
||||||
|
button_box.addButton(self.cancel_button, QDialogButtonBox.ButtonRole.RejectRole)
|
||||||
|
|
||||||
|
layout.addWidget(button_box)
|
||||||
|
|
||||||
|
self.setLayout(layout)
|
||||||
|
|
||||||
|
self.update_button.clicked.connect(self.accept)
|
||||||
|
self.cancel_button.clicked.connect(self.reject)
|
||||||
|
|
||||||
class TwitterMediaDownloaderGUI(QMainWindow):
|
class TwitterMediaDownloaderGUI(QMainWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.current_version = "1.6"
|
||||||
self.setWindowTitle("Twitter/X Media Batch Downloader")
|
self.setWindowTitle("Twitter/X Media Batch Downloader")
|
||||||
|
|
||||||
|
self.settings = QSettings('TwitterMediaDownloader', 'Settings')
|
||||||
|
self.check_for_updates = self.settings.value('check_for_updates', True, type=bool)
|
||||||
|
|
||||||
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):
|
||||||
self.setWindowIcon(QIcon(icon_path))
|
self.setWindowIcon(QIcon(icon_path))
|
||||||
@@ -357,12 +398,34 @@ class TwitterMediaDownloaderGUI(QMainWindow):
|
|||||||
os.makedirs(self.default_pictures_dir, exist_ok=True)
|
os.makedirs(self.default_pictures_dir, exist_ok=True)
|
||||||
|
|
||||||
self.media_info = None
|
self.media_info = None
|
||||||
self.settings = QSettings('TwitterMediaDownloader', 'Settings')
|
|
||||||
|
|
||||||
self.init_ui()
|
self.init_ui()
|
||||||
self.load_settings()
|
self.load_settings()
|
||||||
self.setup_auto_save()
|
self.setup_auto_save()
|
||||||
self.clean_username = None
|
self.clean_username = None
|
||||||
|
|
||||||
|
if self.check_for_updates:
|
||||||
|
QTimer.singleShot(0, self.check_updates)
|
||||||
|
|
||||||
|
def check_updates(self):
|
||||||
|
try:
|
||||||
|
response = requests.get("https://raw.githubusercontent.com/afkarxyz/Twitter-X-Media-Batch-Downloader/refs/heads/main/version.json")
|
||||||
|
if response.status_code == 200:
|
||||||
|
data = response.json()
|
||||||
|
new_version = data.get("version")
|
||||||
|
|
||||||
|
if new_version and version.parse(new_version) > version.parse(self.current_version):
|
||||||
|
dialog = UpdateDialog(self.current_version, new_version, self)
|
||||||
|
result = dialog.exec()
|
||||||
|
|
||||||
|
if dialog.disable_check.isChecked():
|
||||||
|
self.settings.setValue('check_for_updates', False)
|
||||||
|
self.check_for_updates = False
|
||||||
|
|
||||||
|
if result == QDialog.DialogCode.Accepted:
|
||||||
|
QDesktopServices.openUrl(QUrl("https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases"))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error checking for updates: {e}")
|
||||||
|
|
||||||
def init_ui(self):
|
def init_ui(self):
|
||||||
central_widget = QWidget()
|
central_widget = QWidget()
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"version": "1.7"
|
||||||
|
}
|
||||||
Reference in new issue
Block a user