|
|
@@ -154,11 +154,11 @@ class VideoPreviewCog(BaseCog, name='Video Link Previews'):
|
|
154
|
154
|
delay: timedelta = self.get_guild_setting(message.guild, Self.SETTING_DELAY)
|
|
155
|
155
|
await asyncio.sleep(delay.total_seconds())
|
|
156
|
156
|
# Look for embeds already showing the video
|
|
157
|
|
- self.log(message.guild, "Checking message for embeds")
|
|
|
157
|
+ # self.log(message.guild, "Checking message for embeds")
|
|
158
|
158
|
for embed in message.embeds:
|
|
159
|
159
|
if embed.video.url:
|
|
160
|
160
|
# If there's any video, skip downloading any previews
|
|
161
|
|
- self.log(message.guild, "Message already has a video. Skipping this message.")
|
|
|
161
|
+ # self.log(message.guild, "Message already has a video. Skipping this message.")
|
|
162
|
162
|
return
|
|
163
|
163
|
await self._fetch_previews(message, links)
|
|
164
|
164
|
|
|
|
@@ -181,25 +181,25 @@ class VideoPreviewCog(BaseCog, name='Video Link Previews'):
|
|
181
|
181
|
universal_newlines=True
|
|
182
|
182
|
)
|
|
183
|
183
|
if result.returncode != 0:
|
|
184
|
|
- self.log(message.guild, "Fetching link info JSON failed. Skipping preview.")
|
|
185
|
|
- self.log(message.guild, result.stderr)
|
|
|
184
|
+ # self.log(message.guild, "Fetching link info JSON failed. Skipping preview.")
|
|
|
185
|
+ # self.log(message.guild, result.stderr)
|
|
186
|
186
|
return
|
|
187
|
187
|
try:
|
|
188
|
188
|
info: dict = json.loads(result.stdout)
|
|
189
|
189
|
except Exception as e:
|
|
190
|
|
- self.log(message.guild, f"Error parsing info.json. Skipping preview. {e}")
|
|
|
190
|
+ # self.log(message.guild, f"Error parsing info.json. Skipping preview. {e}")
|
|
191
|
191
|
return
|
|
192
|
192
|
description = info.get('description') or ''
|
|
193
|
193
|
formats: list[dict] = info.get('formats') or []
|
|
194
|
|
- self.log(message.guild, f"Found {len(formats)} formats")
|
|
|
194
|
+ # self.log(message.guild, f"Found {len(formats)} formats")
|
|
195
|
195
|
formats = list(filter(filter_video_format, formats))
|
|
196
|
|
- self.log(message.guild, f"Filtered to {len(formats)} formats")
|
|
|
196
|
+ # self.log(message.guild, f"Filtered to {len(formats)} formats")
|
|
197
|
197
|
sorted_formats: list[dict] = sorted(formats, key=rank_video_format, reverse=True)
|
|
198
|
198
|
if len(sorted_formats) == 0:
|
|
199
|
|
- self.log(message.guild, f"No eligible formats for URL {link.url}")
|
|
|
199
|
+ # self.log(message.guild, f"No eligible formats for URL {link.url}")
|
|
200
|
200
|
return
|
|
201
|
201
|
best_format: dict = sorted_formats[0]
|
|
202
|
|
- self.log(message.guild, f"Best format is id {best_format.get('format_id')}")
|
|
|
202
|
+ # self.log(message.guild, f"Best format is id {best_format.get('format_id')}")
|
|
203
|
203
|
video_url: str = best_format.get('url')
|
|
204
|
204
|
link_description: str = "video"
|
|
205
|
205
|
if (best_format.get('width') or 0) > 0 and (best_format.get('height') or 0) > 0:
|
|
|
@@ -208,7 +208,7 @@ class VideoPreviewCog(BaseCog, name='Video Link Previews'):
|
|
208
|
208
|
link_description += f", {format_bytes(best_format.get('filesize'))}"
|
|
209
|
209
|
elif (best_format.get('filesize_approx') or 0) > 0:
|
|
210
|
210
|
link_description += f", {format_bytes(best_format.get('filesize_approx'))}"
|
|
211
|
|
- content = "Hmm, video preview didn't load. Let's try this."
|
|
|
211
|
+ content = "Here's a preview of that video link."
|
|
212
|
212
|
if len(description) > 0:
|
|
213
|
213
|
content += "\n\n" + blockquote_markdown(suppress_markdown_url_previews(description)) + "\n"
|
|
214
|
214
|
if link.spoiler:
|