Revert "Fixed"

This reverts commit d8e2c9fcee.
This commit is contained in:
jeancf 2023-10-31 16:24:54 +01:00
parent d8e2c9fcee
commit 509c3dad86

View File

@ -658,7 +658,7 @@ def get_timeline(session, nitter_url):
# Download twitter page of user # Download twitter page of user
try: try:
twit_account_page = session.get(url, timeout=HTTPS_REQ_TIMEOUT) twit_account_page = session.get(url, headers=headers, timeout=HTTPS_REQ_TIMEOUT)
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
logging.fatal('Host did not respond when trying to download ' + url) logging.fatal('Host did not respond when trying to download ' + url)
shutdown(-1) shutdown(-1)
@ -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