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.com post plugin needs update #132

Open
thelastfantasy opened this issue Nov 15, 2016 · 3 comments
Open

tumblr.com post plugin needs update #132

thelastfantasy opened this issue Nov 15, 2016 · 3 comments

Comments

@thelastfantasy
Copy link

Now it can only grab the first image of the post.

@thelastfantasy thelastfantasy changed the title tumblr.com post plugin need update tumblr.com post plugin needs update Nov 15, 2016
@thelastfantasy
Copy link
Author

thelastfantasy commented Dec 24, 2016

(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(/\t?({".+?)<\/script>/i);
		//var obj = responseText.match(/<script.*?type=\"application\/ld\\+json\">(.+?)<\/script>/i);
		var url = null;
		var name = null;
		if(!!obj && !!obj[1]) {
			obj = JSON.parse(obj[1].replace(/\n/g,"\\n"));
			//obj = JSON.parse(obj[1]);
			var obT = typeof obj.image;
			if(obT === "string") {
				queueDownload(obj.image);
			} else if(obT === "object") {
				for(var i of obj.image["@list"]) {
					queueDownload(i);
				}
			}
			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 = name + ".mp4";
			} else {
				throw new Error("Media not located in object.");
			}
		} else if(!!ogI && !!ogI[1]) {
			url = ogI[1];
		} else {
			throw new Error("Media not located in page.");
		}
		setURL(url, name);
	} catch(e) {
		log(e.message);
	} finally {
		finish();
	}
})();

My fix.

@MegaScience
Copy link
Contributor

As I mentioned in #130 the issue was that new lines were added which were not accounted in my original code, and my fix in the issue post takes care of that.

@marcellog
Copy link

Hi, I have the same problem... tried updating with the new code above, but didn't work... the "post" plugin is not downloading all pictures from the post, only the first one. Can this be fixed?

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

No branches or pull requests

3 participants