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 From d2cd60cc6dbaa7aceb1d1cd3019aa7089ddfdcd9 Mon Sep 17 00:00:00 2001 From: Stefano Date: Sat, 6 Apr 2013 21:50:25 +0200 Subject: Using SimpleCrypter to avoid repeating getPackageNameAndFolder. + licenses + cosmetics --- module/plugins/crypter/GooGl.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'module/plugins/crypter/GooGl.py') diff --git a/module/plugins/crypter/GooGl.py b/module/plugins/crypter/GooGl.py index 07de5e008..bcb1d7494 100644 --- a/module/plugins/crypter/GooGl.py +++ b/module/plugins/crypter/GooGl.py @@ -1,5 +1,20 @@ # -*- coding: utf-8 -*- +############################################################################ +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Affero General Public License as # +# published by the Free Software Foundation, either version 3 of the # +# License, or (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU Affero General Public License for more details. # +# # +# You should have received a copy of the GNU Affero General Public License # +# along with this program. If not, see . # +############################################################################ + from module.plugins.Crypter import Crypter from module.common.json_layer import json_loads -- cgit v1.2.3