5
5
6
6
# > 3rd party dependencies
7
7
import asyncpraw
8
- import pandas as pd
9
8
10
9
# > Discord dependencies
11
10
import discord
12
- from discord .ext import commands
13
- from discord .ext .tasks import loop
11
+ import pandas as pd
14
12
15
13
# Local dependencies
16
14
import util .vars
17
- from util . vars import config , data_sources
18
- from util . disc_util import get_channel , get_webhook
15
+ from discord . ext import commands
16
+ from discord . ext . tasks import loop
19
17
from util .db import update_db
18
+ from util .disc_util import get_channel , get_webhook
19
+ from util .vars import config , data_sources
20
20
21
21
22
22
class Reddit (commands .Cog ):
@@ -132,17 +132,20 @@ async def wsb(self, reddit: asyncpraw.Reddit) -> None:
132
132
or url .endswith (".gif" )
133
133
):
134
134
img_url .append (url )
135
+ # If the post includes multiple images
135
136
elif "gallery" in url :
136
137
image_dict = submission .media_metadata
137
138
for image_item in image_dict .values ():
138
139
largest_image = image_item ["s" ]
139
140
img_url .append (largest_image ["u" ])
140
141
elif "v.redd.it" in url :
141
142
video = True
142
- descr = ""
143
-
144
- if descr == "" and not video and not img_url :
145
- continue
143
+ if "images" in submission .preview :
144
+ img_url .append (
145
+ submission .preview ["images" ][0 ]["source" ]["url" ]
146
+ )
147
+ else :
148
+ print ("No image found for video post" )
146
149
147
150
e = discord .Embed (
148
151
title = title ,
@@ -156,9 +159,9 @@ async def wsb(self, reddit: asyncpraw.Reddit) -> None:
156
159
if img_url :
157
160
e .set_image (url = img_url [0 ])
158
161
159
- # e.set_thumbnail(
160
- # url="https://styles.redditmedia.com/t5_2th52/styles/communityIcon_wzrl8s0hx8a81.png?width=256&s=dcbf830170c1e8237335a3f046b36f723c5d55e7"
161
- # )
162
+ # Add video emoji to the title
163
+ if video :
164
+ e . title = "🎥 " + e . title
162
165
163
166
e .set_footer (
164
167
text = f"🔼 { submission .score } | 💬 { submission .num_comments } " ,
@@ -181,12 +184,7 @@ async def wsb(self, reddit: asyncpraw.Reddit) -> None:
181
184
avatar_url = self .bot .user .avatar .url ,
182
185
)
183
186
else :
184
- if video :
185
- await self .channel .send (
186
- content = f"https://www.reddit.com{ submission .permalink } "
187
- )
188
- else :
189
- await self .channel .send (embed = e )
187
+ await self .channel .send (embed = e )
190
188
191
189
counter += 1
192
190
0 commit comments