Skip to content
Snippets Groups Projects
Commit 37ad50b5 authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

cut off after 255 characters, remove last settings reference

parent 0e601209
Branches
No related tags found
2 merge requests!804Release,!795Cut off after 255 characters, remove last old settings reference
Pipeline #13715 passed
...@@ -6,10 +6,7 @@ from ...services import InstagramDownloadService ...@@ -6,10 +6,7 @@ from ...services import InstagramDownloadService
class Command(BaseCommand): class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
service = InstagramDownloadService( service = InstagramDownloadService()
app_id=settings.INSTAGRAM_APP_ID,
app_secret=settings.INSTAGRAM_APP_SECRET,
)
service.perform_update() service.perform_update()
self.stdout.write("\nInstagram post update finished.") self.stdout.write("\nInstagram post update finished.")
...@@ -46,7 +46,15 @@ class InstagramDownloadService: ...@@ -46,7 +46,15 @@ class InstagramDownloadService:
profile = instaloader.Profile.from_username(loader.context, username) profile = instaloader.Profile.from_username(loader.context, username)
post_position = 0
for remote_post in profile.get_posts(): for remote_post in profile.get_posts():
if post_position == 64:
# Don't go past 64 saved posts
return
post_position += 1
if remote_post.is_video: if remote_post.is_video:
logger.info( logger.info(
"Instagram post ID %s is a video, skipping.", remote_post.shortcode "Instagram post ID %s is a video, skipping.", remote_post.shortcode
...@@ -61,12 +69,17 @@ class InstagramDownloadService: ...@@ -61,12 +69,17 @@ class InstagramDownloadService:
continue continue
caption = remote_post.caption
if len(caption) > 255:
caption = caption[:255] + "..."
local_post_instance = InstagramPost( local_post_instance = InstagramPost(
remote_id=remote_post.shortcode, remote_id=remote_post.shortcode,
author_name=profile.full_name, author_name=profile.full_name,
author_username=profile.username, author_username=profile.username,
timestamp=remote_post.date_local, timestamp=remote_post.date_local,
caption=remote_post.caption, caption=caption,
url=f"https://instagram.com/p/{remote_post.shortcode}", url=f"https://instagram.com/p/{remote_post.shortcode}",
) )
...@@ -82,8 +95,6 @@ class InstagramDownloadService: ...@@ -82,8 +95,6 @@ class InstagramDownloadService:
remote_post.shortcode, remote_post.shortcode,
) )
post_position += 1
def perform_update(self) -> None: def perform_update(self) -> None:
for username in self.get_usernames(): for username in self.get_usernames():
self.parse_media_for_user(username) self.parse_media_for_user(username)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment