Closed victor21813 closed 5 years ago
Seems like IDE problem, only change this part of code.
for media in feed_json:
if not taken_at:
taken_ts = None
else:
if media.get('imported_taken_at'):
taken_ts = datetime.datetime.utcfromtimestamp(media.get('taken_at', "")).strftime(
'%Y-%m-%d_%H-%M-%S') + "__" + datetime.datetime.utcfromtimestamp(
media.get('imported_taken_at', "")).strftime(
'%Y-%m-%d_%H-%M-%S')
else:
taken_ts = datetime.datetime.utcfromtimestamp(media.get('taken_at', "")).strftime(
'%Y-%m-%d_%H-%M-%S')
is_video = 'video_versions' in media and 'image_versions2' in media
if 'video_versions' in media:
list_video.append([media['video_versions'][0]['url'], taken_ts])
if 'image_versions2' in media:
if (is_video and not no_video_thumbs) or not is_video:
list_image.append([media['image_versions2']['candidates'][0]['url'], taken_ts])
for video in list_video:
filename = video[0].split('/')[-1]
if taken_at:
try:
final_filename = video[1] + ".mp4"
except:
final_filename = filename.split('.')[0] + ".mp4"
print("[E] Could not determine timestamp filename for this file, using default: ") + final_filename
else:
final_filename = filename.split('.')[0] + ".mp4"
save_path = os.getcwd() + "/stories/{}/".format(user_to_check) + final_filename
if not os.path.exists(save_path):
print("[I] Downloading video: {:s}".format(final_filename))
try:
urllib.urlretrieve(video[0], save_path)
list_video_new.append(save_path)
except Exception as e:
print("[W] An error occurred: " + str(e))
exit(1)
else:
print("[I] Story already exists: {:s}".format(final_filename))
for image in list_image:
filename = (image[0].split('/')[-1]).split('?', 1)[0]
if taken_at:
try:
final_filename = image[1] + ".jpg"
except:
final_filename = filename.split('.')[0] + ".jpg"
print("[E] Could not determine timestamp filename for this file, using default: ") + final_filename
else:
final_filename = filename.split('.')[0] + ".jpg"
save_path = os.getcwd() + "/stories/{}/".format(user_to_check) + final_filename
if not os.path.exists(save_path):
print("[I] Downloading image: {:s}".format(final_filename))
try:
urllib.urlretrieve(image[0], save_path)
list_image_new.append(save_path)
except Exception as e:
print("[W] An error occurred: " + str(e))
exit(1)
Thanks:)
File name will look like this when using
--taken-at
:2019-05-03_11-08-06__2019-05-03_09-33-27.mp4
2019-05-03_15-16-56.mp4