├── Custom Builds ├── LICENSE ├── README.md └── dok42 - Custom.py ├── LICENSE ├── README.md └── test.py /Custom Builds/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Rishi Tiku 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use the Software only, subject to the following conditions: 9 | 10 | 1. The code shall not be redistributed commercially by anyone other than the Copyright owner. 11 | 2. The user shall not copy/paste or modify the code and publish it him/herself in any way 12 | without the prior permission of the Copyright holder. 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /Custom Builds/README.md: -------------------------------------------------------------------------------- 1 | # InstagramJSONToReadableText 2 | This script can convert messages.json in your Instagram dump to readable separate text files for each user you've chatted with. 3 | 4 | Hi There, 5 | 6 | Dumped all of your Instagram data? Messages.json is unreadable? This Code is Built just for you! 7 | 8 | Just place the messages.json file in the same folder as the script and run any of the below scripts. You'll find separate .txt files for each user in perfectly readable format. 9 | Enjoy!!! 10 | 11 | # This is the Custom Builds Folder. 12 | 13 | # dok42 - Custom 14 | - This is used to group messages by sender. If multiple messages are sent by a sender without the interruption of another, they are clubbed together. When the other drops a message, their messages are seperated. 15 | For eg. A - XXXXXXXXXXXXXX 16 | A - YYYYYYYYYYYYYYYY 17 | A - ZZZZZZZZZZZZZ 18 | 19 | B - qqqqqqqqqqqqq 20 | B - WWWWWWWWW 21 | 22 | A - deffffffffffdfsd and so on. 23 | 24 | # More Scripts will get added for more custom solutions. 25 | 26 | # To user 27 | Place the messages.json file in this folder (Containing this README file). Open the desired .py file in IDLE (3.x or higher) and click on Run Module from Run Menu. 28 | -------------------------------------------------------------------------------- /Custom Builds/dok42 - Custom.py: -------------------------------------------------------------------------------- 1 | """MIT License 2 | Copyright (c) 2019 Rishi Tiku 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use the Software only, subject to the following conditions: 7 | 1. The code shall not be redistributed commercially by anyone other than the Copyright owner. 8 | 2. The user shall not copy/paste or modify the code and publish it him/herself in any way 9 | without the prior permission of the Copyright holder. 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 18 | SOFTWARE.""" 19 | 20 | import json 21 | import codecs 22 | import sys 23 | import os 24 | 25 | print("""Enter the time zone of your country here. 26 | Example: For INDIA time is +05:30 hours ahead of GMT. 27 | Check the time zone of your country with the +/- sign included.\n\t\t\t*****\n""") 28 | tzhh = int(input('Enter the HOURS part of YOUR Time Zone in hh format.\nPlease include the +/- sign.\nExample: For +05:30(+hh:mm) as for INDIA, Enter \"+05\" here.\n\t>>>')) 29 | tzmm = int(input('Enter the MINUTES part YOUR Time Zone in mm format.\nExample: For +05:30(+hh:mm) as for INDIA, Enter \"30\" here.\n\t>>>')) 30 | #tzhh = +05 31 | #tzmm = 30 32 | 33 | username = str(input('Enter Your Instagram Username here!!! Please enter correctly.\n\t>>>')) #gets your Instagram username here in string format 34 | #username = 'rishi.tiku' #My username, if you wish to, replace your username here, remove the '#' in front of this line and put a '#' in front of previous line. 35 | 36 | 37 | filename = "messages.json" #if editing this, specify either the full file location here or just keep the file in the same folder as this script. 38 | 39 | def Feb(yy): 40 | if(yy%4==0): 41 | if(yy%100==0): 42 | if(yy%400==0): 43 | leap = 1 44 | else: 45 | leap = 0 46 | else: 47 | leap = 1 48 | else: 49 | leap = 0 50 | 51 | if(leap==0): 52 | feb = 28 53 | else: 54 | feb = 29 55 | return feb 56 | 57 | def createDir(dir_name): 58 | try: 59 | os.mkdir(dir_name) 60 | return True; 61 | except: 62 | return False 63 | 64 | def folderExists(dir_name): 65 | ct=0 66 | while(True): 67 | if(os.path.exists(dir_name)): 68 | break 69 | else: 70 | check = createDir(username) 71 | if(check): 72 | break 73 | else: 74 | if(ct==3): 75 | print('Unable to Create Folder') 76 | sys.exit() 77 | ct+=1 78 | 79 | def fileExists(string): 80 | counter = 0 81 | while(1): 82 | try: 83 | if(counter == 0): 84 | f = open(os.path.join(username, "{}.txt".format(string)), 'r', encoding = 'utf-8-sig') 85 | else: 86 | f = open(os.path.join(username, "{} - {}.txt".format(string,counter)), 'r', encoding = 'utf-8-sig') 87 | f.close() 88 | except FileNotFoundError: 89 | return counter 90 | counter+=1 91 | 92 | def Pre(A): 93 | if(A<10): 94 | A = "0"+str(A) 95 | else: 96 | A = str(A) 97 | return A 98 | 99 | def DateTime(date): 100 | global tzhh 101 | global tzmm 102 | yy = int(date[0:4]) 103 | mn = int(date[5:7]) 104 | dd = int(date[8:10]) 105 | hh = int(date[11:13]) 106 | mm = int(date[14:16]) 107 | ss = int(date[17:19]) 108 | day31 = {1,3,5,7,8,10,12} 109 | 110 | daytime=((hh*3600)+(mm*60)+ss) 111 | if(tzhh<0): 112 | tz = ((tzhh*3600)-(tzmm*60)) 113 | else: 114 | tz = ((tzhh*3600)+(tzmm*60)) 115 | left = daytime + tz 116 | if((left%86400)<43200): 117 | st = 'AM' 118 | else: 119 | st = 'PM' 120 | 121 | if(tzhh<0): 122 | if(left<0): 123 | if(dd<=1): 124 | if(mn<=1): 125 | yy -= 1 126 | mn = 12 127 | dd = 31 128 | else: 129 | mn -= 1 130 | if(mn in day31): 131 | dd = 31 132 | elif(mn==2): 133 | dd = Feb(yy) 134 | else: 135 | dd = 30 136 | else: 137 | dd-=1 138 | left = 86400 + left 139 | 140 | elif(tzhh>=0): 141 | day = int(left/86400) 142 | left = (left%86400) 143 | if(day==1): 144 | if(mn in day31): 145 | if(dd==31): 146 | if(mn == 12): 147 | yy += 1 148 | mn = 1 149 | dd = 1 150 | else: 151 | mn+=1 152 | dd = 1 153 | else: 154 | dd+=1 155 | elif(mn==2): 156 | if(dd==Feb(yy)): 157 | dd = 1 158 | mn += 1 159 | else: 160 | dd += 1 161 | else: 162 | if(dd==30): 163 | dd = 1 164 | mn+=1 165 | else: 166 | dd+=1 167 | 168 | hh = int(left/3600) 169 | if(st=='PM'): 170 | hh = hh-12 171 | if(hh==0): 172 | hh = 12 173 | 174 | mm = int((left%3600)/60) 175 | ss = int(left%60) 176 | 177 | TimeStamp = Pre(hh)+':'+Pre(mm)+':'+Pre(ss)+' '+st+', '+Pre(dd)+'/'+Pre(mn)+'/'+Pre(yy) 178 | return(TimeStamp) 179 | 180 | with codecs.open(filename, encoding = 'utf-8-sig', errors = 'ignore') as f: 181 | data = json.load(f) 182 | global date 183 | global ctr 184 | global count 185 | ctr = 1 186 | count = 1 187 | previous="" 188 | current="" 189 | checked = False 190 | Name = False 191 | for participants in data: 192 | p = participants['participants'] 193 | previous='' 194 | if(not(checked)): 195 | for i in p: 196 | if(i==username): 197 | Name = True 198 | checked = True 199 | if(Name): 200 | createDir(username) 201 | else: 202 | print('The Instagram username you entered is incorrect. Please try again!') 203 | sys.exit() 204 | folderExists(username) 205 | if(len(p)==2): 206 | if(p[0]==username): 207 | value = 1 208 | elif(p[1] == username): 209 | value = 0 210 | else: 211 | print('The instagram username you entered is wrong. Try again or maybe change the username argument in source code.') 212 | sys.exit() 213 | result = fileExists(p[value]) 214 | if(result == 0): 215 | f = open(os.path.join(username, "{}.txt".format(p[value])), 'w', encoding = 'utf-8-sig') 216 | elif(result>=1): 217 | f = open(os.path.join(username, "{} - {}.txt".format(p[value],result)), 'w', encoding = 'utf-8-sig') 218 | for sender in reversed(participants['conversation']): 219 | dtime = sender['created_at'] 220 | date = dtime[0:19] 221 | if(sender['sender']!= None): 222 | current = sender['sender'] 223 | else: 224 | current = 'Anonymous' 225 | if(previous!=current and previous!=''): 226 | f.write('\n') 227 | previous=current 228 | f.write(DateTime(date)) 229 | f.write(" - ") 230 | f.write(current) 231 | f.write(": ") 232 | if('story_share' in sender): 233 | f.write("") 234 | if('text' in sender): 235 | if(sender['text']!= None): 236 | f.write(sender['text']) 237 | elif('heart' in sender): 238 | f.write('') 239 | else: 240 | f.write("") 241 | if('media_share_url' in sender): 242 | f.write('') 245 | f.write('\n') 246 | 247 | elif(len(p)>2): 248 | f = open(os.path.join(username, "Group{}.txt".format(ctr)),"w", encoding='utf-8-sig') 249 | for i in p: 250 | f.write(i) 251 | if i != p[-1]: 252 | f.write(" , ") 253 | else: 254 | f.write("\n\n\n") 255 | for sender in reversed(participants['conversation']): 256 | dtime = sender['created_at'] 257 | date = dtime[0:19] 258 | if(sender['sender']!= None): 259 | current = sender['sender'] 260 | else: 261 | current = 'Anonymous' 262 | if(previous!=current and previous!=''): 263 | f.write('\n') 264 | previous=current 265 | f.write(DateTime(date)) 266 | f.write(" - ") 267 | f.write(current) 268 | f.write(": ") 269 | if('story_share' in sender): 270 | f.write("") 271 | if('text' in sender): 272 | if(sender['text']!= None): 273 | f.write(sender['text']) 274 | elif('heart' in sender): 275 | f.write('') 276 | else: 277 | f.write("") 278 | if('media_share_url' in sender): 279 | f.write('') 282 | f.write('\n') 283 | if(previous!=current): 284 | f.write('\n') 285 | previous=current 286 | ctr = ctr + 1 287 | else: 288 | f = open(os.path.join(username, "AnonymousPerson{}.txt".format(count)),"w", encoding='utf-8-sig') 289 | for sender in reversed(participants['conversation']): 290 | dtime = sender['created_at'] 291 | date = dtime[0:19] 292 | if(sender['sender']!= None): 293 | current = sender['sender'] 294 | else: 295 | current = 'Anonymous' 296 | if(previous!=current and previous!=''): 297 | f.write('\n') 298 | previous=current 299 | f.write(DateTime(date)) 300 | f.write(" - ") 301 | f.write(current) 302 | f.write(": ") 303 | if('story_share' in sender): 304 | f.write("") 305 | if('text' in sender): 306 | if(sender['text']!= None): 307 | f.write(sender['text']) 308 | elif('heart' in sender): 309 | f.write('') 310 | else: 311 | f.write("") 312 | if('media_share_url' in sender): 313 | f.write('') 316 | f.write('\n') 317 | if(previous!=current): 318 | f.write('\n') 319 | previous=current 320 | count += 1 321 | f.close() 322 | print('All Done Correctly. Enjoy!!!') 323 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Rishi Tiku 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use the Software only, subject to the following conditions: 9 | 10 | 1. The code shall not be redistributed commercially by anyone other than the Copyright owner. 11 | 2. The user shall not copy/paste or modify the code and publish it him/herself in any way 12 | without the prior permission of the Copyright holder. 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # InstagramJSONToReadableText 2 | This script can convert messages.json in your Instagram dump to readable separate text files for each user you've chatted with. 3 | 4 | Hi There, 5 | 6 | Dumped all of your Instagram data? Messages.json is unreadable? This Code is Built just for you! 7 | 8 | Just place the messages.json file in the same folder as the script and run test.py. You'll find separate .txt files for each user in perfectly readable format. 9 | Enjoy!!! 10 | 11 | # To user 12 | Place the messages.json file in this folder (Containing this README file). Open the test.py file in IDLE (3.x or higher) and click on Run Module from Run Menu. 13 | -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | """MIT License 2 | Copyright (c) 2019 Rishi Tiku 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use the Software only, subject to the following conditions: 7 | 1. The code shall not be redistributed commercially by anyone other than the Copyright owner. 8 | 2. The user shall not copy/paste or modify the code and publish it him/herself in any way 9 | without the prior permission of the Copyright holder. 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 18 | SOFTWARE.""" 19 | 20 | import json 21 | import codecs 22 | import sys 23 | import os 24 | 25 | 26 | print("""Enter the time zone of your country here. 27 | Example: For INDIA time is +05:30 hours ahead of GMT. 28 | Check the time zone of your country with the +/- sign included.\n\t\t\t*****\n""") 29 | tzhh = int(input('Enter the HOURS part of YOUR Time Zone in hh format.\nPlease include the +/- sign.\nExample: For +05:30(+hh:mm) as for INDIA, Enter \"+05\" here.\n\t>>>')) 30 | tzmm = int(input('Enter the MINUTES part YOUR Time Zone in mm format.\nExample: For +05:30(+hh:mm) as for INDIA, Enter \"30\" here.\n\t>>>')) 31 | #tzhh = +05 32 | #tzmm = 30 33 | 34 | username = str(input('Enter Your Instagram Username here!!! Please enter correctly.\n\t>>>')) #gets your Instagram username here in string format 35 | #username = 'rishi.tiku' #My username, if you wish to, replace your username here, remove the '#' in front of this line and put a '#' in front of previous line. 36 | 37 | 38 | filename = "messages.json" #if editing this, specify either the full file location here or just keep the file in the same folder as this script. 39 | 40 | def Feb(yy): 41 | if(yy%4==0): 42 | if(yy%100==0): 43 | if(yy%400==0): 44 | leap = 1 45 | else: 46 | leap = 0 47 | else: 48 | leap = 1 49 | else: 50 | leap = 0 51 | 52 | if(leap==0): 53 | feb = 28 54 | else: 55 | feb = 29 56 | return feb 57 | 58 | def folderExists(dir_name): 59 | ct=0 60 | while(True): 61 | if(os.path.exists(dir_name)): 62 | break 63 | else: 64 | check = createDir(username) 65 | if(check): 66 | break 67 | else: 68 | if(ct==3): 69 | print('Unable to Create Folder') 70 | sys.exit() 71 | ct+=1 72 | 73 | 74 | def createDir(dir_name): 75 | try: 76 | os.mkdir(dir_name) 77 | return True 78 | except: 79 | return False 80 | 81 | def fileExists(string): 82 | counter = 0 83 | while(1): 84 | try: 85 | if(counter == 0): 86 | f = open(os.path.join(username, "{}.txt".format(string)), 'r', encoding = 'utf-8-sig') 87 | else: 88 | f = open(os.path.join(username, "{} - {}.txt".format(string,counter)), 'r', encoding = 'utf-8-sig') 89 | f.close() 90 | except FileNotFoundError: 91 | return counter 92 | counter+=1 93 | 94 | def Pre(A): 95 | if(A<10): 96 | A = "0"+str(A) 97 | else: 98 | A = str(A) 99 | return A 100 | 101 | def DateTime(date): 102 | global tzhh 103 | global tzmm 104 | yy = int(date[0:4]) 105 | mn = int(date[5:7]) 106 | dd = int(date[8:10]) 107 | hh = int(date[11:13]) 108 | mm = int(date[14:16]) 109 | ss = int(date[17:19]) 110 | day31 = {1,3,5,7,8,10,12} 111 | 112 | daytime=((hh*3600)+(mm*60)+ss) 113 | if(tzhh<0): 114 | tz = ((tzhh*3600)-(tzmm*60)) 115 | else: 116 | tz = ((tzhh*3600)+(tzmm*60)) 117 | left = daytime + tz 118 | if((left%86400)<43200): 119 | st = 'AM' 120 | else: 121 | st = 'PM' 122 | 123 | if(tzhh<0): 124 | if(left<0): 125 | if(dd<=1): 126 | if(mn<=1): 127 | yy -= 1 128 | mn = 12 129 | dd = 31 130 | else: 131 | mn -= 1 132 | if(mn in day31): 133 | dd = 31 134 | elif(mn==2): 135 | dd = Feb(yy) 136 | else: 137 | dd = 30 138 | else: 139 | dd-=1 140 | left = 86400 + left 141 | 142 | elif(tzhh>=0): 143 | day = int(left/86400) 144 | left = (left%86400) 145 | if(day==1): 146 | if(mn in day31): 147 | if(dd==31): 148 | if(mn == 12): 149 | yy += 1 150 | mn = 1 151 | dd = 1 152 | else: 153 | mn+=1 154 | dd = 1 155 | else: 156 | dd+=1 157 | elif(mn==2): 158 | if(dd==Feb(yy)): 159 | dd = 1 160 | mn += 1 161 | else: 162 | dd += 1 163 | else: 164 | if(dd==30): 165 | dd = 1 166 | mn+=1 167 | else: 168 | dd+=1 169 | 170 | hh = int(left/3600) 171 | if(st=='PM'): 172 | hh = hh-12 173 | if(hh==0): 174 | hh = 12 175 | 176 | mm = int((left%3600)/60) 177 | ss = int(left%60) 178 | 179 | TimeStamp = Pre(hh)+':'+Pre(mm)+':'+Pre(ss)+' '+st+', '+Pre(dd)+'/'+Pre(mn)+'/'+Pre(yy) 180 | return(TimeStamp) 181 | 182 | with codecs.open(filename, encoding = 'utf-8-sig', errors = 'ignore') as f: 183 | data = json.load(f) 184 | global date 185 | global ctr 186 | global count 187 | ctr = 1 188 | count = 1 189 | checked = False 190 | Name = False 191 | for participants in data: 192 | p = participants['participants'] 193 | if(not(checked)): 194 | for i in p: 195 | if(i==username): 196 | Name = True 197 | checked = True 198 | if(Name): 199 | createDir(username) 200 | else: 201 | print('The Instagram username you entered is incorrect. Please try again!') 202 | sys.exit() 203 | folderExists(username) 204 | if(len(p)==2): 205 | if(p[0]==username): 206 | value = 1 207 | elif(p[1] == username): 208 | value = 0 209 | else: 210 | print('The instagram username you entered is wrong. Try again or maybe change the username argument in source code.') 211 | sys.exit() 212 | result = fileExists(p[value]) 213 | if(result == 0): 214 | f = open(os.path.join(username, "{}.txt".format(p[value])), 'w', encoding = 'utf-8-sig') 215 | elif(result>=1): 216 | f = open(os.path.join(username, "{} - {}.txt".format(p[value],result)), 'w', encoding = 'utf-8-sig') 217 | for sender in reversed(participants['conversation']): 218 | dtime = sender['created_at'] 219 | date = dtime[0:19] 220 | f.write(DateTime(date)) 221 | f.write(" - ") 222 | if(sender['sender']!= None): 223 | f.write(sender['sender']) 224 | else: 225 | f.write("Anonymous") 226 | f.write(": ") 227 | if('story_share' in sender): 228 | f.write("") 229 | if('text' in sender): 230 | if(sender['text']!= None): 231 | f.write(sender['text']) 232 | elif('heart' in sender): 233 | f.write('') 234 | else: 235 | f.write("") 236 | if('media_share_url' in sender): 237 | f.write('') 240 | f.write('\n') 241 | elif(len(p)>2): 242 | f = open(os.path.join(username, "Group{}.txt".format(ctr)),"w", encoding='utf-8-sig') 243 | for i in p: 244 | f.write(i) 245 | if i != p[-1]: 246 | f.write(" , ") 247 | else: 248 | f.write("\n\n\n") 249 | for sender in reversed(participants['conversation']): 250 | dtime = sender['created_at'] 251 | date = dtime[0:19] 252 | f.write(DateTime(date)) 253 | f.write(" - ") 254 | if(sender['sender']!= None): 255 | f.write(sender['sender']) 256 | else: 257 | f.write("Anonymous") 258 | f.write(": ") 259 | if('story_share' in sender): 260 | f.write("") 261 | if('text' in sender): 262 | if(sender['text']!= None): 263 | f.write(sender['text']) 264 | elif('heart' in sender): 265 | f.write('') 266 | else: 267 | f.write("") 268 | if('media_share_url' in sender): 269 | f.write('') 272 | f.write('\n') 273 | ctr = ctr + 1 274 | else: 275 | f = open(os.path.join(username, "AnonymousPerson{}.txt".format(count)),"w", encoding='utf-8-sig') 276 | for sender in reversed(participants['conversation']): 277 | dtime = sender['created_at'] 278 | date = dtime[0:19] 279 | f.write(DateTime(date)) 280 | f.write(" - ") 281 | if(sender['sender']!= None): 282 | f.write(sender['sender']) 283 | else: 284 | f.write("Anonymous") 285 | f.write(": ") 286 | if('story_share' in sender): 287 | f.write("") 288 | if('text' in sender): 289 | if(sender['text']!= None): 290 | f.write(sender['text']) 291 | elif('heart' in sender): 292 | f.write('') 293 | else: 294 | f.write("") 295 | if('media_share_url' in sender): 296 | f.write('') 299 | f.write('\n') 300 | count += 1 301 | f.close() 302 | print('All Done Correctly. Enjoy!!!') 303 | --------------------------------------------------------------------------------