Skip to content

Commit

Permalink
Fix for _r# Tumblr URLs
Browse files Browse the repository at this point in the history
Noticed that _r# Tumblr URLs didn't work, so this code should fix that.
Also VERY slight adjustments.
  • Loading branch information
MegaScience authored and poke committed Oct 9, 2016
1 parent 1a00cc3 commit 09f530b
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions plugins/sandboxes/tumblr.com-post.resolve.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
(function() {
"use strict";
try {
var ogI = responseText.match(
/<meta property="og:image" content="(.+?)"/i);
var type = responseText.match(
/<meta property="og:type" content="(?:.+?:)?(.+?)"/i)[1];
var obj = responseText.match(
/<script.*?type="application\/ld\+json">(.+?)<\/script>/i);
var ogI = responseText.match(/<meta property="og:image" content="(.+?)"/i);
var type = responseText.match(/<meta property="og:type" content="(?:.+?:)?(.+?)"/i)[1];
var obj = responseText.match(/<script.*?type="application\/ld\+json">(.+?)<\/script>/i);
var url = null;
var name = null;
if (!!obj && !!obj[1]) {
Expand All @@ -21,13 +18,12 @@
}
}
if (type === "video") {
name = "tumblr_" + ogI[1].match(/\/tumblr_([a-zA-Z0-9]+)_frame/)[1];
url = "https://www.tumblr.com/video_file/" +
baseURL.match(/\/post\/([0-9]+)/)[1] + "/" + name;
name = ogI[1].match(/\/(tumblr_[a-zA-Z\d]+)(?:_r\d+)?_frame/)[1];
url = "https://www.tumblr.com/video_file/" + baseURL.match(/\/post\/(\d+)/)[1] + "/" + name;
name = name + ".mp4";
}
else {
throw new Error("Media not located in object.");
throw new Error("Media not located in object.");
}
}
else if (!!ogI && !!ogI[1]) {
Expand Down

0 comments on commit 09f530b

Please sign in to comment.