Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status code: 400. #36

Open
ylogachev opened this issue Jan 16, 2024 · 1 comment
Open

Status code: 400. #36

ylogachev opened this issue Jan 16, 2024 · 1 comment

Comments

@ylogachev
Copy link

python twitter-video-dl.py https://twitter.com/iamyomas/status/1745417287631347837 test_twitter/test.mp4
Traceback (most recent call last):
File "/Users/ylogachev/Development/fuckvpnbot/twitter-video-dl/twitter-video-dl.py", line 25, in
tvdl.download_video(args.twitter_url, file_name)
File "/Users/ylogachev/Development/fuckvpnbot/twitter-video-dl/src/twitter_video_dl/twitter_video_dl.py", line 347, in download_video
bearer_token, guest_token = get_tokens(tweet_url)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/ylogachev/Development/fuckvpnbot/twitter-video-dl/src/twitter_video_dl/twitter_video_dl.py", line 37, in get_tokens
assert html.status_code == 200, f'Failed to get tweet page. If you are using the correct Twitter URL this suggests a bug in the script. Please open a GitHub issue and copy and paste this message. Status code: {html.status_code}. Tweet url: {tweet_url}'
AssertionError: Failed to get tweet page. If you are using the correct Twitter URL this suggests a bug in the script. Please open a GitHub issue and copy and paste this message. Status code: 400. Tweet url: https://twitter.com/iamyomas/status/1745417287631347837

@7rikazhexde
Copy link

7rikazhexde commented Jan 17, 2024

@inteoryx @ylogachev

This issue is the same as 7rikazhexde#7.
Some of the error output is different, but the function(get_tokens) in issue is the same.

In other words, this problem is caused by the browser not supporting it. You can access the tweet page by specifying the User-Agent in the header of the GET request, as shown below.

    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0",
        "Accept": "*/*",
        "Accept-Language": "de,en-US;q=0.7,en;q=0.3",
        "Accept-Encoding": "gzip, deflate, br",
        "TE": "trailers"
    }

    html = requests.get(tweet_url, headers=headers)

Although I am proposing a fix in the pull request below along with other issues,
#33

There was a problem with the following fix. Therefore, I would like to update the pull request to fix it along with the above issue.

  1. Addition of URL detection pattern (x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants