File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 44
55import re
66import json
7+ from datetime import datetime
78from html import unescape
89from urllib .parse import urlparse
910
@@ -57,6 +58,10 @@ def get_episodes_from_data(data):
5758 if timeline ["page_info" ]["has_next_page" ]:
5859 end_cursor = timeline ["page_info" ]["end_cursor" ]
5960 return reversed (eps ), end_cursor
61+
62+ def ts_to_date (ts ):
63+ dt = datetime .fromtimestamp (ts )
64+ return dt .strftime ("%y-%m-%d" )
6065
6166def get_episodes (html , url ):
6267 if match := re .match (r"https://www\.instagram\.com/([^/]+)/" , url ):
@@ -71,8 +76,12 @@ def get_episodes(html, url):
7176 body = json .loads (html )
7277 result = []
7378 for item in body ["items" ]:
79+ try :
80+ ts = item ["taken_at" ]
81+ except KeyError :
82+ ts = item ["caption" ]["created_at" ]
7483 result .append (Episode (
75- str ( item [" code" ]) ,
84+ f" { ts_to_date ( ts ) } { item [' code' ] } " ,
7685 f"https://www.instagram.com/p/{ item ['code' ]} /"
7786 ))
7887
You can’t perform that action at this time.
0 commit comments