Skip to content

Commit

Permalink
Add caption to csv.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruebot committed Sep 3, 2024
1 parent c2b17eb commit c32b199
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "digfemig"
version = "0.0.2"
version = "0.0.3"
readme = "README.md"
requires-python = ">=3.9.9"
description = "Utility to collect media for Instagram hashtags for the DigFemNet Project."
Expand Down
5 changes: 3 additions & 2 deletions src/digfemig/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def download_media(hashtag, session_file, download_path, username, password):
csvwriter = csv.writer(csvfile)

if os.stat(csv_file_path).st_size == 0:
csvwriter.writerow(["file_name", "username", "post_url"])
csvwriter.writerow(["file_name", "username", "post_url", "caption"])

timestamp = time.strftime("%Y%m%d%H%M%S")

Expand All @@ -53,6 +53,7 @@ def download_media(hashtag, session_file, download_path, username, password):
media_path = os.path.join(download_path, media_filename)
post_url = f"https://www.instagram.com/p/{media.code}/"
ig_username = media.user.username
ig_caption = media.title

# Download the media.
if media.media_type == 1:
Expand All @@ -61,7 +62,7 @@ def download_media(hashtag, session_file, download_path, username, password):
cl.video_download_by_url(media.video_url, media_path)

# Write metadata.
csvwriter.writerow([media_filename, ig_username, post_url])
csvwriter.writerow([media_filename, ig_username, post_url, ig_caption])

image_url = media.thumbnail_url
image_path = os.path.join(
Expand Down

0 comments on commit c32b199

Please sign in to comment.