mirror of
https://gitlab.com/jeancf/twoot.git
synced 2024-11-23 20:11:11 +00:00
parent
d8e2c9fcee
commit
509c3dad86
32
twoot.py
32
twoot.py
|
@ -658,7 +658,7 @@ def get_timeline(session, nitter_url):
|
|||
|
||||
# Download twitter page of user
|
||||
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:
|
||||
logging.fatal('Host did not respond when trying to download ' + url)
|
||||
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:
|
||||
for chunk in r.iter_content(chunk_size=16 * 1024):
|
||||
f.write(chunk)
|
||||
# Initiate session
|
||||
session = requests.Session()
|
||||
|
||||
# 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=',
|
||||
}
|
||||
)
|
||||
ded video of GIF animation from attachments')
|
||||
logging.debug('Downloaded video of GIF animation from attachments')
|
||||
except: # Don't do anything if video can't be found or downloaded
|
||||
logging.debug('Could not download video of GIF animation from attachments')
|
||||
pass
|
||||
|
@ -930,20 +918,8 @@ ded video of GIF animation from attachments')
|
|||
logging.debug("Media is unavailable")
|
||||
vid_in_tweet = True
|
||||
else:
|
||||
logging.debug("Media i # Initiate session
|
||||
session = requests.Session()
|
||||
|
||||
# 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=',
|
||||
}
|
||||
)
|
||||
|
||||
logging.debug("Media is unavailable")
|
||||
vid_in_tweet = True
|
||||
|
||||
return pics, vid_in_tweet
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user