From f802d769fac6e1c2e296507df2a56ce4b79e9ec1 Mon Sep 17 00:00:00 2001 From: Stefano Date: Sun, 31 Mar 2013 15:15:40 +0200 Subject: New crypter plugin for Goo.gl --- module/plugins/crypter/GooGl.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 module/plugins/crypter/GooGl.py (limited to 'module/plugins/crypter/GooGl.py') diff --git a/module/plugins/crypter/GooGl.py b/module/plugins/crypter/GooGl.py new file mode 100644 index 000000000..07de5e008 --- /dev/null +++ b/module/plugins/crypter/GooGl.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +from module.plugins.Crypter import Crypter +from module.common.json_layer import json_loads + + +class GooGl(Crypter): + __name__ = "GooGl" + __type__ = "crypter" + __pattern__ = r"https?://(www\.)?goo\.gl/\w+" + __version__ = "0.01" + __description__ = """Goo.gl Crypter Plugin""" + __author_name__ = ("stickell") + __author_mail__ = ("l.stickell@yahoo.it") + + API_URL = 'https://www.googleapis.com/urlshortener/v1/url' + + def decrypt(self, pyfile): + rep = self.load(self.API_URL, get={'shortUrl': pyfile.url}) + self.logDebug('JSON data: ' + rep) + rep = json_loads(rep) + + if 'longUrl' in rep: + self.core.files.addLinks([rep['longUrl']], self.pyfile.package().id) + else: + self.fail('Unable to expand shortened link') -- cgit v1.2.3