I realized that Tumblr revision URLs (_r#) weren't being recognized, so this adjustment should fix that. Also VERY slight fixes.
If anyone can improve on this code, feel free. As when I originally wrote it, my goal was to get the downloadable media dynamically. Using the Google Carousel object, it determines image(s) in the page, as well as composing the video URL should one exist in the page. (Tumblr allows images with videos.) It also has a fallback to og:image if for some reason the format changes. These functionalities should be retained.
I'd appreciate cleaner code. I have not been satisfied with how I obtain the video URL (building it from various identifiers in the page instead of finding it as a whole), but videos are presented in iframes and would require making the code more complicated to grab from there. I do know that the video URL will direct to a URL formatted "https://vt.tumblr.com/tumblr_[a-zA-Z\d]+(_r\d+)?.mp4", but since the URL I use is more concise, I assume it should be used to obtain the correct URL. If it is found to be better to use the redirect URL, it can be used.
I realized that Tumblr revision URLs (_r#) weren't being recognized, so this adjustment should fix that. Also VERY slight fixes.
If anyone can improve on this code, feel free. As when I originally wrote it, my goal was to get the downloadable media dynamically. Using the Google Carousel object, it determines image(s) in the page, as well as composing the video URL should one exist in the page. (Tumblr allows images with videos.) It also has a fallback to og:image if for some reason the format changes. These functionalities should be retained.
I'd appreciate cleaner code. I have not been satisfied with how I obtain the video URL (building it from various identifiers in the page instead of finding it as a whole), but videos are presented in iframes and would require making the code more complicated to grab from there. I do know that the video URL will direct to a URL formatted "https://vt.tumblr.com/tumblr_[a-zA-Z\d]+(_r\d+)?.mp4", but since the URL I use is more concise, I assume it should be used to obtain the correct URL. If it is found to be better to use the redirect URL, it can be used.