# -*- coding: UTF-8 -*- #/* # * Copyright (C) 2013 Libor Zoubek # * # * # * This Program is free software; you can redistribute it and/or modify # * it under the terms of the GNU General Public License as published by # * the Free Software Foundation; either version 2, 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 General Public License for more details. # * # * You should have received a copy of the GNU General Public License # * along with this program; see the file COPYING. If not, write to # * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # * http://www.gnu.org/copyleft/gpl.html # * # */ import sys import urllib import ulozto_search query = "your_query" file_type = "documents|videos|images|archives|audios" # optional kwargs = { "insecure": False, # disables SSL check, optional, default False "includeApproximate": False # also return approximate results } #Python 2 try: import cookielib import urllib2 #import sys reload(sys) # Reload does the trick! sys.setdefaultencoding('UTF8') #Python 3 except: import http.cookiejar cookielib = http.cookiejar urllib2 = urllib.request import re,random,util,os,traceback import json from base64 import b64decode from provider import ContentProvider from provider import ResolveException from provider import cached def loadurl(url, req, headers=None): print (url) req = urllib.parse.urlencode(req).encode('utf-8') if headers: req = urllib.request.Request(url, req, headers=headers) else: req = urllib.request.Request(url, req) with urllib.request.urlopen(req) as f: try: if f.getcode()==200: response = f.read() return response except: return False class UloztoContentProvider(ContentProvider): def __init__(self,username=None,password=None,filter=None): ContentProvider.__init__(self,'ulozto.cz','https://www.ulozto.cz/',username,password,filter) self.search_type='' self.cp = urllib2.HTTPCookieProcessor(cookielib.LWPCookieJar()) self.rh = UloztoHTTPRedirectHandler() self.rh.throw = False self.rh.location = None self.init_urllib() def init_urllib(self): opener = urllib2.build_opener(self.cp,self.rh) urllib2.install_opener(opener) def capabilities(self): return ['login','search','resolve','categories'] def categories(self): result = [] if not self.login(): return result data = util.request(self.base_url+'m/'+self.username) fav = re.search('