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

[tumblr] update regex for video subdomain #133

Merged
merged 1 commit into from
Dec 9, 2018
Merged

[tumblr] update regex for video subdomain #133

merged 1 commit into from
Dec 9, 2018

Conversation

Hrxn
Copy link
Contributor

@Hrxn Hrxn commented Dec 8, 2018

There seems to be another sub-domain for videos, apparently..
Not just
vt(.media).tumblr
vtt(media).tumblr
But also
ve(.media).tumblr

Two examples pulled via \posts\ endpoint on Web API Console:

"video_url": "https://ve.media.tumblr.com/tumblr_n1zsb87J961ts7u0r.mp4",
"video_url": "https://ve.media.tumblr.com/tumblr_n1zsdjVyDf1ts7u0r.mp4",

Note that both return 403, that old issue with videos on Tumblr etc. pp.
I think I've only seen one at ve.media.tumblr.com so far, but that was working.
So this exists 😄

Please comment/change/edit as you see fit.

@mikf I've only tested these changes with the regex101.com tool (Python mode) and not via local Python interpreter or something, but I think this should work.
Also, a question just for understanding:
Do I get this right, that this regex was only intended to match URLs returned from the API that contain something like _540, _720 etc.? Because the regex seems not to match at all otherwise. But I think this is intentional, right (The URL does not need to be changed/"improved" here)?

Edit:

I mean, just like these two example URLs returned from the Tumblr API above.
The regex does not match at all, and it doesn't need to.

Only for URLs like this (fictional example):

"video_url": "https://ve.media.tumblr.com/tumblr_n1zsb87J961ts7u0r_540.mp4",
"video_url": "https://ve.media.tumblr.com/tumblr_n1zsdjVyDf1ts7u0r_720.mp4",

But in this case it should work as expected 😄

There seems to be another sub-domain for videos, apparently..
Not just
`vt(.media).tumblr`
`vtt(media).tumblr`
But also
`ve(.media).tumblr`
@mikf
Copy link
Owner

mikf commented Dec 9, 2018

Do I get this right, that this regex was only intended to match URLs returned from the API that contain something like _540, _720 etc.?

The regex is used to strip size suffixes like _720 from video URLs to make them point to the original or at least highest available quality version. If it doesn't match, because it doesn't contain a _720 and therefore doesn't need to be improved as you said, the URL is returned as is.

@mikf mikf merged commit e80ee77 into mikf:master Dec 9, 2018
@Hrxn Hrxn deleted the patch-1 branch December 9, 2018 17:23
@Hrxn
Copy link
Contributor Author

Hrxn commented Dec 9, 2018

Thanks. That's what I figured. It was only my initial reaction that I thought I had something wrong because the regex did not match, and I started to doubt myself - because how hard can it be to copy a short regex expression from a source file? But then I realized, yeah, no it is exactly doing what's supposed to be doing.

Not sure how common this alternative sub-domain in conjunction with a size suffix really is, so this is probably somewhat of an edge case. But it can't hurt either, so why not..

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

Successfully merging this pull request may close these issues.

2 participants