diff --git a/src/newsreader/news/collection/reddit.py b/src/newsreader/news/collection/reddit.py
index 1e2837b..128131f 100644
--- a/src/newsreader/news/collection/reddit.py
+++ b/src/newsreader/news/collection/reddit.py
@@ -42,6 +42,8 @@ REDDIT_API_URL = "https://oauth.reddit.com"
RATE_LIMIT = 60
RATE_LIMIT_DURATION = timedelta(seconds=60)
+REDDIT_IMAGE_EXTENSIONS = (".jpg", ".png", ".gif")
+
def get_reddit_authorization_url(user):
state = str(uuid4())
@@ -120,7 +122,9 @@ class RedditBuilder(Builder):
remote_identifier = post["data"]["id"]
title = truncate_text(Post, "title", post["data"]["title"])
author = truncate_text(Post, "author", post["data"]["author"])
- url_fragment = f"{post['data']['permalink']}"
+ post_url_fragment = post["data"]["permalink"]
+ direct_url = post["data"]["url"]
+ is_text_post = post["data"]["is_self"]
if remote_identifier in results:
continue
@@ -139,6 +143,13 @@ class RedditBuilder(Builder):
else ""
)
+ if not is_text_post and direct_url.endswith(REDDIT_IMAGE_EXTENSIONS):
+ body = f"

"
+ elif not is_text_post and post["data"]["is_video"]:
+ video_info = post["data"]["secure_media"]["reddit_video"]
+
+ body = f""
+
try:
parsed_date = datetime.fromtimestamp(post["data"]["created_utc"])
created_date = pytz.utc.localize(parsed_date)
@@ -151,7 +162,7 @@ class RedditBuilder(Builder):
"title": title,
"body": body,
"author": author,
- "url": f"{REDDIT_URL}{url_fragment}",
+ "url": f"{REDDIT_URL}{post_url_fragment}",
"publication_date": created_date,
"rule": rule,
}
diff --git a/src/newsreader/news/collection/tests/reddit/builder/tests.py b/src/newsreader/news/collection/tests/reddit/builder/tests.py
index eb8182a..da1525a 100644
--- a/src/newsreader/news/collection/tests/reddit/builder/tests.py
+++ b/src/newsreader/news/collection/tests/reddit/builder/tests.py
@@ -1,4 +1,5 @@
from datetime import datetime
+from unittest import skip
from unittest.mock import MagicMock
from django.test import TestCase
@@ -219,3 +220,23 @@ class RedditBuilderTestCase(TestCase):
duplicate_post.title,
"Linux Experiences/Rants or Education/Certifications thread - July 06, 2020",
)
+
+ @skip("Not implemented")
+ def test_image_post(self):
+ pass
+
+ @skip("Not implemented")
+ def test_external_image_post(self):
+ pass
+
+ @skip("Not implemented")
+ def test_video_post(self):
+ pass
+
+ @skip("Not implemented")
+ def test_external_video_post(self):
+ pass
+
+ @skip("Not implemented")
+ def test_link_only_post(self):
+ pass
diff --git a/src/newsreader/scss/components/post/_post.scss b/src/newsreader/scss/components/post/_post.scss
index 46d389d..6b41844 100644
--- a/src/newsreader/scss/components/post/_post.scss
+++ b/src/newsreader/scss/components/post/_post.scss
@@ -68,14 +68,9 @@
margin: 20px 0 5px 0;
}
- & img {
- padding: 10px 10px 30px 10px;
-
- max-width: 70%;
- width: inherit;
- height: 100%;
-
- align-self: center;
+ & img, video {
+ padding: 10px 0;
+ max-width: 100%;
}
}