diff options
author | Stefano <l.stickell@yahoo.it> | 2013-03-31 15:15:40 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2013-03-31 15:15:40 +0200 |
commit | f802d769fac6e1c2e296507df2a56ce4b79e9ec1 (patch) | |
tree | 54318d67d035cc80fe6c09eeeca3885b7b6ab396 /module | |
parent | RarefileNet: fixed url (diff) | |
download | pyload-f802d769fac6e1c2e296507df2a56ce4b79e9ec1.tar.xz |
New crypter plugin for Goo.gl
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/crypter/GooGl.py | 26 |
1 files changed, 26 insertions, 0 deletions
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') |