mirror of
https://github.com/Alvin-Zilverstand/Twitter-X-Media-Batch-Downloader.git
synced 2026-12-02 02:51:29 +01:00
Update v1.2
This commit is contained in:
1 parent
e98cd51cf4
commit
aa89fda847
1 file changed
+15
-7
@@ -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)
|
||||||
|
|||||||
Reference in new issue
Block a user