Compare commits

...
10 Commits
Author SHA1 Message Date
afkarxyz dfb536f663 Update README.md 2025-01-22 17:35:38 +07:00
afkarxyz 2b5e7985d5 Create getRAW.py 2025-01-22 17:34:52 +07:00
afkarxyz 81bacad4d8 Update and rename GetMetadata.py to getMetadata.py 2025-01-22 17:34:28 +07:00
afkarxyz aa89fda847 Update v1.2 2025-01-22 17:33:24 +07:00
afkarxyz e98cd51cf4 Update README.md 2025-01-22 05:30:38 +07:00
afkarxyz 6bb5348485 Update README.md 2025-01-21 12:03:57 +07:00
afkarxyz 784bb494fc Update README.md 2025-01-21 10:22:43 +07:00
afkarxyz 5096e18cb8 Update README.md 2025-01-21 00:08:41 +07:00
afkarxyz 2237de2b2c Update README.md 2025-01-21 00:05:14 +07:00
afkarxyz 4656ebc56c Update README.md 2025-01-20 23:49:42 +07:00
4 changed files with 74 additions and 15 deletions

No files matched your search

@@ -53,10 +53,17 @@ def get_metadata(username):
tweet_date = tweet_data.get('date', datetime.now()) tweet_date = tweet_data.get('date', datetime.now())
if isinstance(tweet_date, datetime): if isinstance(tweet_date, datetime):
tweet_date = tweet_date.strftime("%Y-%m-%d %H:%M:%S") tweet_date = tweet_date.strftime("%Y-%m-%d %H:%M:%S")
output['timeline'].append({
timeline_entry = {
'url': media_url, 'url': media_url,
'date': tweet_date 'date': tweet_date,
}) 'tweet_id': tweet_data.get('tweet_id', 0),
}
if 'type' in tweet_data:
timeline_entry['type'] = tweet_data['type']
output['timeline'].append(timeline_entry)
output['total_urls'] += 1 output['total_urls'] += 1
current_dir = os.path.dirname(os.path.abspath(__file__)) current_dir = os.path.dirname(os.path.abspath(__file__))
+34
View File
@@ -0,0 +1,34 @@
import json
import re
import os
from gallery_dl.extractor import twitter
def get_metadata(username):
url = f"https://x.com/{username}/timeline"
match = re.match(twitter.TwitterTimelineExtractor.pattern, url)
if not match:
raise ValueError(f"Invalid URL: {url}")
extractor = twitter.TwitterTimelineExtractor(match)
extractor.config = lambda key, default=None: {
"cookies": {
"auth_token": ""
}
}.get(key, default)
extractor.initialize()
all_items = []
for item in extractor:
all_items.append(item)
current_dir = os.path.dirname(os.path.abspath(__file__))
output_file = os.path.join(current_dir, f"{username}.json")
with open(output_file, 'w', encoding='utf-8') as f:
json.dump(all_items, f, indent=2, default=str)
username = ""
get_metadata(username)
+15 -5
View File
@@ -2,13 +2,24 @@
![TwitterXMediaBatchDownloader](https://github.com/user-attachments/assets/354d7470-c01c-4aa6-9da1-ea6c42d27330) ![TwitterXMediaBatchDownloader](https://github.com/user-attachments/assets/354d7470-c01c-4aa6-9da1-ea6c42d27330)
**Twitter/X Media Batch Downloader** is a GUI tool for downloading all media, including images and videos, from Twitter/X accounts, using `gallery-dl` <div align="center">
<b>Twitter/X Media Batch Downloader</b> is a GUI tool that allows users to download all media, including images and videos, in their original quality from Twitter/X accounts using <code>gallery-dl</code>
</div>
## Download ## Download
- Download the latest version of [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v1.1/TwitterXMediaBatchDownloader.exe) - Download the latest version of [TwitterXMediaBatchDownloader](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/download/v1.2/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
- Uses the powerful `gallery-dl` library, similar to `yt-dlp`
- Simple and compact GUI
- Download images and videos in original quality
- Option to choose the media type to download: **media** (image + video) or just **image/video**
- **Batch** download settings, ranging from 10 to 100 files per download
- Filename format customization
## Screenshots ## Screenshots
![image](https://github.com/user-attachments/assets/ccdd8a8d-890f-4d3c-a3b1-56dad3eb82a9) ![image](https://github.com/user-attachments/assets/ccdd8a8d-890f-4d3c-a3b1-56dad3eb82a9)
@@ -17,7 +28,7 @@
![image](https://github.com/user-attachments/assets/1779659e-3512-4e74-be0a-088419267fe0) ![image](https://github.com/user-attachments/assets/1779659e-3512-4e74-be0a-088419267fe0)
## How to obtain Auth Token ## How to Obtain Auth Token
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
@@ -25,6 +36,5 @@
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 [Cookie-Editor](https://cookie-editor.com/)
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
7. Close your browser
![image](https://github.com/user-attachments/assets/50f819da-7490-4f3c-b130-c5a3ee482e2d) ![image](https://github.com/user-attachments/assets/50f819da-7490-4f3c-b130-c5a3ee482e2d)
+15 -7
View File
@@ -93,14 +93,19 @@ class MetadataFetcher(QThread):
} }
should_include = False should_include = False
media_type = tweet_data.get('type', '')
if self.media_type == 'media': if self.media_type == 'media':
should_include = ('pbs.twimg.com' in media_url or should_include = ('pbs.twimg.com' in media_url or
'video.twimg.com' in media_url) 'video.twimg.com' in media_url)
elif self.media_type == 'image': elif self.media_type == 'image':
should_include = 'pbs.twimg.com' in media_url should_include = ('pbs.twimg.com' in media_url and
media_type == 'photo')
elif self.media_type == 'gif':
should_include = media_type == 'animated_gif'
elif self.media_type == 'video': elif self.media_type == 'video':
should_include = 'video.twimg.com' in media_url should_include = (media_type == 'video' and
'video.twimg.com' in media_url)
if should_include: if should_include:
tweet_date = tweet_data.get('date', datetime.now()) tweet_date = tweet_data.get('date', datetime.now())
@@ -110,8 +115,8 @@ class MetadataFetcher(QThread):
output['timeline'].append({ output['timeline'].append({
'url': media_url, 'url': media_url,
'date': tweet_date, 'date': tweet_date,
'type': ('video' if 'video.twimg.com' in media_url 'type': media_type,
else 'image') 'tweet_id': tweet_data.get('tweet_id', '')
}) })
if not output['account_info']: if not output['account_info']:
@@ -122,6 +127,8 @@ class MetadataFetcher(QThread):
message = "No media found in timeline" message = "No media found in timeline"
elif self.media_type == 'image': elif self.media_type == 'image':
message = "No images found in timeline" message = "No images found in timeline"
elif self.media_type == 'gif':
message = "No GIFs found in timeline"
else: else:
message = "No videos found in timeline" message = "No videos found in timeline"
raise ValueError(message) raise ValueError(message)
@@ -173,13 +180,14 @@ class MediaDownloader(QThread):
url = item['url'] url = item['url']
date = datetime.strptime(item['date'], "%Y-%m-%d %H:%M:%S") date = datetime.strptime(item['date'], "%Y-%m-%d %H:%M:%S")
formatted_date = date.strftime("%Y%m%d_%H%M%S") formatted_date = date.strftime("%Y%m%d_%H%M%S")
tweet_id = str(item.get('tweet_id', ''))
extension = 'mp4' if 'video.twimg.com' in url else 'jpg' extension = 'mp4' if 'video.twimg.com' in url else 'jpg'
if self.filename_format == "username_date": if self.filename_format == "username_date":
base_filename = f"{self.username}_{formatted_date}" base_filename = f"{self.username}_{formatted_date}_{tweet_id}"
else: else:
base_filename = f"{formatted_date}_{self.username}" base_filename = f"{formatted_date}_{self.username}_{tweet_id}"
filename = f"{base_filename}.{extension}" filename = f"{base_filename}.{extension}"
counter = 1 counter = 1
@@ -318,7 +326,7 @@ class TwitterMediaDownloaderGUI(QMainWindow):
self.media_type_combo = QComboBox() self.media_type_combo = QComboBox()
self.media_type_combo.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) self.media_type_combo.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
media_types = [('media', 'Media'), ('image', 'Image'), ('video', 'Video')] media_types = [('media', 'Media'), ('image', 'Image'), ('gif', 'GIF'), ('video', 'Video')]
for value, display in media_types: for value, display in media_types:
self.media_type_combo.addItem(display, value) self.media_type_combo.addItem(display, value)
self.media_type_combo.setFixedWidth(100) self.media_type_combo.setFixedWidth(100)