inteoryx / twitter-video-dl Goto Github PK
View Code? Open in Web Editor NEWDownload twitter videos as mp4 files
License: The Unlicense
Download twitter videos as mp4 files
License: The Unlicense
/
Today I got this error while downloading a video:
AssertionError: Did not find container URLs.
Video-url:
https://twitter.com/nargas_coringa/status/1492546170895355912
Is there anyway to change the download location?
Jello there
Want to ask would it be possible to get this script work in loop monitoring users list and any new tweet contain a video from anyone name/user on the list the script will download that video
In downloads folder in this format
/home/downloads/usernick/video file - dated-ext
Thanks and hope this suggestion catch your eyes and made a road map to do it
Hi,
while playing with your code, I figured out that for this specific tweet it wouldn't download the actual tweet video but the one from the first showed reply.
My code :
tweet_url = "https://twitter.com/nocontexthumans/status/1641810447358631938"
tvdl.download_video(tweet_url, "tweetVideo2.mp4")
First frame of the tweet's video :
First frame of the downloaded video :
If you have some free time, please try to replicate this bug on your side to see if it's unique to my setup or if it's a global bug.
Thank you for keeping this repo alive.
I guess that I am the one wrong here. It looks like the author of the tweet I sent earlier just "reposted" a video and did not post it directly to twitter through its account as we can see here :
It could be a cool feature to download videos in such cases though, because we do not always think to open the original video's tweet.
So I wasn't totally wrong because I found this tweet while trying to code a solution.
This tweet still cause the bug to occur, even if it's not a repost.
It still downloads the first showed video in the replies but this tweet's video isn't reposted.
As you can see both tweets feature the same video (the first one is a repost) because my solution to this bug was to extract the url of the source tweet (that contain the non reposted video) and then to send it back to the download_video function, so I could get the video, even from a reposted tweet.
The bug actually come from the extract_mp4s
function. Your ext_tw_pattern
regular expression actually find the video url, but
the function automatically returns container urls if it find some :
It then skips any other video url, which in my case include the one I want.
In fact, in this tweet case the tweet video url is :
https://video.twimg.com/ext_tw_video/1641074057524174848/pu/vid/404x720/YvImuEf6bgC5P9jl.mp4?tag=12
While the first showed video in the replies has this url :
https://video.twimg.com/ext_tw_video/1634237199096123392/pu/pl/ig4YOUAgpgyowlbd.m3u8?tag=12&container=fmp4
Given that it's a container url, extract_mp4s
directly returns this video link which causes this bug.
Traceback (most recent call last):
File "C:\Users\Phantasm\Downloads\twitter-video-dl-main\twitter-video-dl-main\twitter-video-dl.py", line 25, in
tvdl.download_video(args.twitter_url, file_name)
File "C:\Users\Phantasm\Downloads\twitter-video-dl-main\twitter-video-dl-main\src\twitter_video_dl\twitter_video_dl.py", line 382, in download_video
assert len(
^^^^
AssertionError: Could not find any mp4s to download. Make sure you are using the correct url. If you are, then file a GitHub issue and copy and paste this message. Tweet url: https://twitter.com/0521MissA/status/1664475514055315456
AssertionError: Failed request to https://twitter.com/i/api/graphql/iXunlAxclfRgknK8bnaMvA/TweetDetail?variables=%7B%22focalTweetId%22%3A%221451361961782906889%22%2C%22with_rux_injections%22%3Afalse%2C%22includePromotedContent%22%3Atrue%2C%22withCommunity%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Atrue%2C%22withBirdwatchNotes%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22dont_mention_me_view_api_enabled%22%3Atrue%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Afalse%2C%22responsive_web_edit_tweet_api_enabled%22%3Afalse%2C%22vibe_tweet_context_enabled%22%3Atrue%7D. 400 {'errors': [{'message': 'The following features cannot be null: standardized_nudges_for_misinfo_nudges_enabled', 'extensions': {'name': 'BadRequestError', 'source': 'Client', 'code': 336, 'kind': 'Validation', 'tracing': {'trace_id': '2999ea54e07c1fc3'}}, 'code': 336, 'kind': 'Validation', 'name': 'BadRequestError', 'source': 'Client', 'tracing': {'trace_id': '2999ea54e07c1fc3'}}]}.
This happens regardless of which video I try. Is it just me?
AssertionError: Failed request to https://twitter.com/i/api/graphql/sPFwumWnbdt7IpB6a9krVQ/TweetDetail?variables=%7B%22focalTweetId%22%3A%221452460936116244482%22%2C%22with_rux_injections%22%3Afalse%2C%22includePromotedContent%22%3Atrue%2C%22withCommunity%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Afalse%2C%22withTweetQuoteCount%22%3Atrue%2C%22withBirdwatchNotes%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withUserResults%22%3Atrue%2C%22withNftAvatar%22%3Afalse%2C%22withBirdwatchPivots%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withVoice%22%3Atrue%7D. 400. Please submit an issue including this information.
python twitter-video-dl.py https://twitter.com/juliann38915202/status/1694734291752886589 output
The question is as follows:
assert details.status_code == 200, f'Failed to get tweet details. 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: {details.status_code}. Tweet url: {tweet_url}' AssertionError: Failed to get tweet details. 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: 404. Tweet url: https://twitter.com/juliann38915202/status/1694734291752886589
So I try to run the script just as the example says ->
$ python3 twitter-video-dl.py https://twitter.com/willowhalliwell/status/1452460936116244482 output
Instead of downloading, this is what I get:
Traceback (most recent call last):
File "/home/desktop/twitter-video-dl/twitter-video-dl.py", line 25, in
tvdl.download_video(args.twitter_url, file_name)
File "/home/desktop/twitter-video-dl/src/twitter_video_dl/twitter_video_dl.py", line 139, in download_video
status_resp = send_request(
File "/home/desktop/twitter-video-dl/src/twitter_video_dl/twitter_video_dl.py", line 23, in send_request
assert response.status_code == 200, f"Failed request to {url}. {response.status_code} {response_json}. Please submit an issue including this information."
AssertionError: Failed request to https://twitter.com/i/api/graphql/T0I8jIOz1Cfea00BjAXyfA/TweetDetail?variables=%7B%22focalTweetId%22%3A%221452460936116244482%22%2C%22with_rux_injections%22%3Afalse%2C%22includePromotedContent%22%3Atrue%2C%22withCommunity%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Atrue%2C%22withBirdwatchNotes%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22dont_mention_me_view_api_enabled%22%3Atrue%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Afalse%2C%22responsive_web_edit_tweet_api_enabled%22%3Afalse%2C%22vibe_tweet_context_enabled%22%3Atrue%2C%22standardized_nudges_for_misinfo_nudges_enabled%22%3Afalse%7D. 400 {'errors': [{'message': 'The following features cannot be null: responsive_web_enhance_cards_enabled, standardized_nudges_misinfo', 'extensions': {'name': 'BadRequestError', 'source': 'Client', 'code': 336, 'kind': 'Validation', 'tracing': {'trace_id': '98a7322fba760064'}}, 'code': 336, 'kind': 'Validation', 'name': 'BadRequestError', 'source': 'Client', 'tracing': {'trace_id': '98a7322fba760064'}}]}. Please submit an issue including this information.
copy and paste this message. Status code: 404. Tweet url: https://twitter.com/crazyclipsonly/status/1681119601055223808
I couldn't really find out why this is happening, is it because it's a subtweet?
AssertionError: Failed to get tweet details. 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: 404. Tweet url: https://twitter.com/ahmedyehia___/status/1749889932410208674
some videos need login to download
I tried to download some videos from the examples in the repo, but the saved MP4 doesn't play.
Even FFmpeg can't read it, it says:
$ ffmpeg -i output_file_name.mp4 a.mp4
ffmpeg version git-2020-07-25-7c8ad72 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --enable-nonfree --enable-cuda-nvcc --enable-libnpp --enable-gpl --enable-libx264 --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64
libavutil 56. 57.100 / 56. 57.100
libavcodec 58. 97.102 / 58. 97.102
libavformat 58. 49.100 / 58. 49.100
libavdevice 58. 11.101 / 58. 11.101
libavfilter 7. 87.100 / 7. 87.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x56196acbedc0] could not find corresponding trex (id 1)
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x56196acbedc0] could not find corresponding track id 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x56196acbedc0] trun track id unknown, no tfhd was found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x56196acbedc0] error reading header
output_file_name.mp4: Invalid data found when processing input
AssertionError: Failed to find main.js file. 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. Tweet url: https://twitter.com/seguemike/status/1575092234927894529
Bot is no longer working without account
Any suggestions to auth code? @inteoryx
It does not work with CSRF token either :(
When trying to download one of the example videos python3.8 twitter-video-dl.py https://twitter.com/crabcrawler1/status/1460400562176987145 output_file_name
, the output comes in four parts, and they are not in the correct order of the original video.
Traceback (most recent call last):
File "D:\twitterdl\twitter-video-dl-main\twitter-video-dl-main\twitter-video-dl.py", line 25, in
tvdl.download_video(args.twitter_url, file_name)
File "D:\twitterdl\twitter-video-dl-main\twitter-video-dl-main\src\twitter_video_dl\twitter_video_dl.py", line 347, in download_video
bearer_token, guest_token = get_tokens(tweet_url)
^^^^^^^^^^^^^^^^^^^^^
File "D:\twitterdl\twitter-video-dl-main\twitter-video-dl-main\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/i/status/1742984356245758033
Can't get guest token tonight. Everything works fine until today. The response cookie doesn't contain "gt" anymore.
Could not find any mp4s to download. Make sure you are using the correct url. If you are, then file a GitHub issue and copy and paste this message. Tweet url: https://twitter.com/gujarat_titans/status/1655207515162832897
assert query_id, f"Did not find query id. Are you sure you used the right twitter URL? {video_url}"
i have alot of issue regarding this
Reloaded modules: dl_video.twitter_video_dl, dl_video.twitter_video_dl.twitter_video_dl
Traceback (most recent call last):
File "C:\Users..\Twitter Project\download_videos.py", line 14, in
tvdl.download_video('https://twitter.com/willowhalliwell/status/1452460936116244482', '1522952577809223681.mp4')
File "C:\Users..\Twitter Project\dl_video\twitter_video_dl\twitter_video_dl.py", line 104, in download_video
f"{STATUS_ENDPOINT}{query_id}/{status_params}", session.get, headers)
File "C:\Users..\Twitter Project\dl_video\twitter_video_dl\twitter_video_dl.py", line 17, in send_request
assert response.status_code == 200, f"Failed request to {url}. {response.status_code}. Please submit an issue including this information."
AssertionError: Failed request to https://twitter.com/i/api/graphql/GKajRJ_uQ1wdg6Zs0xvIuA/TweetDetail?variables=%7B%22focalTweetId%22%3A%221452460936116244482%22%2C%22with_rux_injections%22%3Afalse%2C%22includePromotedContent%22%3Atrue%2C%22withCommunity%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Afalse%2C%22withTweetQuoteCount%22%3Atrue%2C%22withBirdwatchNotes%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withUserResults%22%3Atrue%2C%22withNftAvatar%22%3Afalse%2C%22withBirdwatchPivots%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%7D. 400. Please submit an issue including this information.
AssertionError: Did not find query id. Are you sure you used the right twitter URL? Query Id entered is right.
Still Getting this error.
Try this url: https://twitter.com/TheDeadDistrict/status/1551472547149058050
It can not return the content of this tweet.
Just return:
Age-restricted adult content. This content may not be suitable for users under the age of 18. To view this media, you need to be logged into Twitter. understand more
Couldn't download one of my own videos from twitter:
Status code: 404.
Tweet url: https://twitter.com/never_tomorrow/status/1327680318002900992
with some extra debug output below:
OUTPUT:
`(venv) C:[...]\PythonTwitterVideoScraper\Python>python twitter-video-dl.py https://twitter.com/never_tomorrow/status/1327680318002900992 test.mp4
args.twitter_url: https://twitter.com/never_tomorrow/status/1327680318002900992
file_name: test.mp4
get_tweet_details()
url:https://twitter.com/i/api/graphql/wTXkouwCKcMNQtY-NcDgAA/TweetDetail?variables=%7B%22with_rux_injections%22%3A%20false%2C%20%22includePromotedContent%22%3A%20true%2C%20%22withCommunity%22%3A%20true%2C%20%22withQuickPromoteEligibilityTweetFields%22%3A%20true%2C%20%22withBirdwatchNotes%22%3A%20true%2C%20%22withDownvotePerspective%22%3A%20false%2C%20%22withReactionsMetadata%22%3A%20false%2C%20%22withReactionsPerspective%22%3A%20false%2C%20%22withVoice%22%3A%20true%2C%20%22withV2Timeline%22%3A%20true%2C%20%22focalTweetId%22%3A%20%221327680318002900992%22%7D&features=%7B%22responsive_web_graphql_exclude_directive_enabled%22%3A%20true%2C%20%22verified_phone_label_enabled%22%3A%20false%2C%20%22responsive_web_graphql_timeline_navigation_enabled%22%3A%20true%2C%20%22responsive_web_graphql_skip_user_profile_image_extensions_enabled%22%3A%20false%2C%20%22tweetypie_unmention_optimization_enabled%22%3A%20true%2C%20%22vibe_api_enabled%22%3A%20false%2C%20%22responsive_web_edit_tweet_api_enabled%22%3A%20false%2C%20%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3A%20false%2C%20%22view_counts_everywhere_api_enabled%22%3A%20true%2C%20%22longform_notetweets_consumption_enabled%22%3A%20true%2C%20%22tweet_awards_web_tipping_enabled%22%3A%20false%2C%20%22freedom_of_speech_not_reach_fetch_enabled%22%3A%20false%2C%20%22standardized_nudges_misinfo%22%3A%20false%2C%20%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3A%20false%2C%20%22interactive_text_enabled%22%3A%20false%2C%20%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3A%20true%2C%20%22responsive_web_text_conversations_enabled%22%3A%20false%2C%20%22longform_notetweets_richtext_consumption_enabled%22%3A%20false%2C%20%22responsive_web_enhance_cards_enabled%22%3A%20false%7D
bearer_token:AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA
guest_token:1716764611653878046
details:<Response [404]>
details.status_code:404
Traceback (most recent call last):
File "twitter-video-dl.py", line 26, in
tvdl.download_video(args.twitter_url, file_name)
File "C:[...]\PythonTwitterVideoScraper\Python\src\twitter_video_dl\twitter_video_dl.py", line 365, in download_video
resp = get_tweet_details(tweet_url, guest_token, bearer_token)
File "C:[...]\PythonTwitterVideoScraper\Python\src\twitter_video_dl\twitter_video_dl.py", line 160, in get_tweet_details
assert details.status_code == 200, f'Failed to get tweet details. 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: {details.status_code}. Tweet url: {tweet_url}'
AssertionError: Failed to get tweet details. 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: 404. Tweet url: https://twitter.com/never_tomorrow/status/1327680318002900992`
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
twitter-video-dl.py https://twitter.com/jackposobiec/status/1644904637810573312?s=46&t=C4RATVnzrLTKmtxPwRNPQQ temp
The & operator is reserved for future use; wrap an ampersand in double
quotation marks ("&") to pass it as part of a string.
PS C:\Users\MicZon\twitter-video-dl> python twitter-video-dl.py https://twitter.com/i/status/1706676593261785178 output_file_name
Traceback (most recent call last):
get_tweet_details
assert details.status_code == 200, f'Failed to get tweet details. 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: {details.status_code}. Tweet url: {tweet_url}'
^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Failed to get tweet details. 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: 404. Tweet url: https://twitter.com/i/status/1706676593261785178
https://twitter.com/clownworld_/status/1655005892897808385
https://twitter.com/taxfreelt/status/1655103208027553792
logic breaks in repost_check method
Some links not working
I have a return value to return me a resolution for the video, but seems like method returns twice, and on second time return value become None.
@inteoryx could be a threading issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.