Comments (5)
Thank you very much for all this. Excellent bug report and, even better, it came with a fix. I have pulled in your fix and updated the test cases file. Seems to all be working now. I really appreciate your contribution.
from twitter-video-dl.
I'm working on a fix, I'll share it here later this day or tomorrow.
from twitter-video-dl.
Fix commited to my fork.
Code might be messy, and we might have to do further checking before assuming it works correctly.
It's an early fix that worked for the case I explained earlier.
For more details about what's modified and what's added please read my comment.
from twitter-video-dl.
Awesome, thanks very much for finding this issue and submitting a fix. There is an issue with your fix which is that it can download lower resolution than the max available, for example try your code with https://twitter.com/Queen__Deshda/status/1452467693517426697 - it downloads a lower resolution version of the video than the mainline. Ideally I would like to keep the max resolution behavior.
When I have a chance I will try to update your code to keep the max resolution version and merge it. Or, if you want to take that on, that would be great. From the tests directory you can run "python TestVideoDownloader.py" and it will catch errors like this.
I really do appreciate your PR and will merge it soon once this issue is ironed out - thanks again.
from twitter-video-dl.
Hi, thank you for your feedback. I took time to find what causes the bug you describe here and it looks like it does not come from my update. The bug occurs because sometime ext_tw_pattern
and amplitude_pattern
do not find the highest resolution video link.
I looked into the json data received from requesting https://twitter.com/Queen__Deshda/status/1452467693517426697 and manually found those 3 video links (+ 1 container) :
{
"bitrate": 256000,
"content_type": "video/mp4",
"url": "https://video.twimg.com/ext_tw_video/1452467633727627271/pu/vid/480x270/mJYI0tdF0rk4Boxq.mp4?tag=12"
},
{
"bitrate": 2176000,
"content_type": "video/mp4",
"url": "https://video.twimg.com/ext_tw_video/1452467633727627271/pu/vid/1280x720/-Rk-UWbHoRufnCUr.mp4?tag=12"
},
{
"bitrate": 832000,
"content_type": "video/mp4",
"url": "https://video.twimg.com/ext_tw_video/1452467633727627271/pu/vid/640x360/JSZJP1JdQJDhuEdr.mp4?tag=12"
}
In this case only https://video.twimg.com/ext_tw_video/1452467633727627271/pu/vid/480x270/mJYI0tdF0rk4Boxq.mp4?tag=12
and https://video.twimg.com/ext_tw_video/1452467633727627271/pu/vid/640x360/JSZJP1JdQJDhuEdr.mp4?tag=12
are matched by your regular expression, so I started comparing links and spotted a difference.
In fact, the highest resolution link contains '-' in its field just after its resolution (1280x720) : -Rk-UWbHoRufnCUr
. Comparing these fields for the 3 video links we have :
mJYI0tdF0rk4Boxq
-Rk-UWbHoRufnCUr
JSZJP1JdQJDhuEdr
Next step was to look at how this field is handled by your regular expression :
ext_tw_pattern = re.compile(r'(https://video.twimg.com/ext_tw_video/(\d+)/pu/vid/(\d+x\d+)/\w+.mp4\?tag=\d+)')
By quickly looking at it, ext_tw_pattern
handles the previously described field with the \w+
statement.
According to google : \w
(lowercase w) matches a "word" character: a letter or digit or underbar [a-zA-Z0-9_].
So the bug occurs because \w
does not match a "word" with a '-'.
I then updated the regular expression to :
ext_tw_pattern = re.compile(r'(https://video.twimg.com/ext_tw_video/(\d+)/pu/vid/(\d+x\d+)/[^.]+.mp4\?tag=\d+)')
replacing \w
by [^.]
which means anything except a '.' .
And ran a quick test comparing deprecated regular expression and the updated one on the 3 above links.
Bingo, highest resolution matched ! The new pattern should fix that bug.
So I changed both ext_tw_pattern
and amplitude_pattern
because they were using \w
.
You can see that fix on my fork's last commit.
from twitter-video-dl.
Related Issues (20)
- add login features HOT 5
- Does not work with links that have & HOT 4
- Help!!! HOT 1
- 'NoneType' object has no attribute 'split' HOT 1
- 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 HOT 2
- emm HOT 1
- Change Download Location HOT 2
- No longer working HOT 5
- /
- Bug: Status 404 HOT 1
- Status code: 404. HOT 1
- How I download twitter video using url with using python
- statuscode 404 HOT 2
- Failed to get tweet details
- assert html.status_code == 200
- Status code: 400. HOT 1
- Error 404
- Status code: 400. Tweet url: https://x.com/_akhaliq/status/1757239969423175839?s=20
- 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 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twitter-video-dl.