mirror of
				https://github.com/KevinMidboe/escape-snapchat.git
				synced 2025-10-29 17:40:20 +00:00 
			
		
		
		
	Merge pull request #2 from KevinMidboe/fix/download-error
Fix/download error
This commit is contained in:
		| @@ -7,6 +7,7 @@ import json | ||||
| import requests | ||||
| import datetime | ||||
| import os | ||||
| import shutil | ||||
|  | ||||
| # Helper Functions | ||||
|  | ||||
| @@ -18,11 +19,19 @@ def get_datetime(memory_date): | ||||
|  | ||||
| def get_ext(memory_media_type): | ||||
|     ext = "mp4" | ||||
|     if memory["Media Type"] == "PHOTO": | ||||
|     if memory["Media Type"] == "Image" or memory["Media Type"] == "PHOTO": | ||||
|         ext = "jpg" | ||||
|     return ext | ||||
|  | ||||
| def download_file_from_url(url, filename): | ||||
|     with requests.get(url, stream=True) as r: | ||||
|         with open(filename, 'wb') as f: | ||||
|             shutil.copyfileobj(r.raw, f) | ||||
|  | ||||
|     return filename | ||||
|  | ||||
| overwrite = False # Overwrites existing useful memory metadata file | ||||
| st = datetime.datetime.now() | ||||
|  | ||||
| # Import Memories Data | ||||
|  | ||||
| @@ -77,7 +86,7 @@ for memory in memories: | ||||
|  | ||||
|     print("Downloading File {}:".format(filename), end=" ") | ||||
|     try: | ||||
|         urllib.request.urlretrieve(memory["url"], filename) | ||||
|         download_file_from_url(memory["url"], filename) | ||||
|         modtime = datetime.datetime.timestamp(memory_datetime) | ||||
|         os.utime(filename, (modtime, modtime)) | ||||
|         print("Success") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user