This commit is contained in:
jeancf 2023-10-31 17:58:42 +01:00
commit 72f7f40a66

View File

@ -877,20 +877,8 @@ def process_attachments(nitter_url, attachments_container, status_id, author_acc
with open('gif_video.mp4', 'wb') as f: with open('gif_video.mp4', 'wb') as f:
for chunk in r.iter_content(chunk_size=16 * 1024): for chunk in r.iter_content(chunk_size=16 * 1024):
f.write(chunk) f.write(chunk)
# Initiate session
session = requests.Session()
# Get a copy of the default headers that requests would use logging.debug('Downloaded video of GIF animation from attachments')
headers = requests.utils.default_headers()
# Update default headers with randomly selected user agent
headers.update(
{
'User-Agent': USER_AGENTS[random.randint(0, len(USER_AGENTS) - 1)],
'Cookie': 'replaceTwitter=; replaceYouTube=; hlsPlayback=on; proxyVideos=',
}
)
ded video of GIF animation from attachments')
except: # Don't do anything if video can't be found or downloaded except: # Don't do anything if video can't be found or downloaded
logging.debug('Could not download video of GIF animation from attachments') logging.debug('Could not download video of GIF animation from attachments')
pass pass
@ -930,20 +918,8 @@ ded video of GIF animation from attachments')
logging.debug("Media is unavailable") logging.debug("Media is unavailable")
vid_in_tweet = True vid_in_tweet = True
else: else:
logging.debug("Media i # Initiate session logging.debug("Media is unavailable")
session = requests.Session() vid_in_tweet = True
# Get a copy of the default headers that requests would use
headers = requests.utils.default_headers()
# Update default headers with randomly selected user agent
headers.update(
{
'User-Agent': USER_AGENTS[random.randint(0, len(USER_AGENTS) - 1)],
'Cookie': 'replaceTwitter=; replaceYouTube=; hlsPlayback=on; proxyVideos=',
}
)
return pics, vid_in_tweet return pics, vid_in_tweet