Python urlparse.parse_qsl() Examples

The following are code examples for showing how to use urlparse.parse_qsl(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: pyblish-win   Author: pyblish   File: cgi.py    GNU Lesser General Public License v3.0 6 votes vote down vote up
def read_multi(self, environ, keep_blank_values, strict_parsing):
        """Internal: read a part that is itself multipart."""
        ib = self.innerboundary
        if not valid_boundary(ib):
            raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,)
        self.list = []
        if self.qs_on_post:
            for key, value in urlparse.parse_qsl(self.qs_on_post,
                                self.keep_blank_values, self.strict_parsing):
                self.list.append(MiniFieldStorage(key, value))
            FieldStorageClass = None

        klass = self.FieldStorageClass or self.__class__
        part = klass(self.fp, {}, ib,
                     environ, keep_blank_values, strict_parsing)
        # Throw first part away
        while not part.done:
            headers = rfc822.Message(self.fp)
            part = klass(self.fp, headers, ib,
                         environ, keep_blank_values, strict_parsing)
            self.list.append(part)
        self.skip_lines() 
Example 2
Project: openhatch   Author: campbe13   File: views.py    GNU Affero General Public License v3.0 6 votes vote down vote up
def subscribe_to_bug_alert_do(request):
    confirmation_query_string_fragment = "&confirm_email_alert_signup=1"
    alert_form = mysite.search.forms.BugAlertSubscriptionForm(request.POST)
    query_string = request.POST.get('query_string', '')  # Lacks initial '?'
    query_string = query_string.replace(confirmation_query_string_fragment, '')
    next = reverse(search_index) + '?' + query_string
    if alert_form.is_valid():
        alert = alert_form.save()
        if request.user.is_authenticated():
            alert.user = request.user
            alert.save()
        next += confirmation_query_string_fragment
        return HttpResponseRedirect(next)
    elif query_string:
        # We want search_index to get the right query string but we can't exactly
        # do that. What we *can* do is fiddle with the request obj we're about
        # to pass to search_index.
        # Commence fiddling.
        request.GET = dict(parse_qsl(query_string))
        return search_index(request, alert_form)
    else:
        # If user tries to do a different bug search after invalid form input
        return HttpResponseRedirect(next + request.META['QUERY_STRING']) 
Example 3
Project: jawfish   Author: war-and-code   File: cgi.py    MIT License 6 votes vote down vote up
def read_multi(self, environ, keep_blank_values, strict_parsing):
        """Internal: read a part that is itself multipart."""
        ib = self.innerboundary
        if not valid_boundary(ib):
            raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,)
        self.list = []
        if self.qs_on_post:
            for key, value in urlparse.parse_qsl(self.qs_on_post,
                                self.keep_blank_values, self.strict_parsing):
                self.list.append(MiniFieldStorage(key, value))
            FieldStorageClass = None

        klass = self.FieldStorageClass or self.__class__
        part = klass(self.fp, {}, ib,
                     environ, keep_blank_values, strict_parsing)
        # Throw first part away
        while not part.done:
            headers = rfc822.Message(self.fp)
            part = klass(self.fp, headers, ib,
                         environ, keep_blank_values, strict_parsing)
            self.list.append(part)
        self.skip_lines() 
Example 4
Project: Pancas   Author: Sup3Roque   File: videomega.py    GNU General Public License v2.0 6 votes vote down vote up
def resolve(url):
    try:
        url = urlparse.urlparse(url).query
        url = urlparse.parse_qsl(url)[0][1]
        url = 'http://videomega.tv/cdn.php?ref=%s' % url
        #control.log("### VIDEOMEGA RES %s" % url)
        result = client.request(url, mobile=True)
        #control.log("### VIDEOMEGA RES %s" % result)
        result = re.compile('eval.*?{}\)\)').findall(result)[-1]
        #control.log("### VIDEOMEGA RES2 %s" % result)
        result = jsunpack.unpack(result)
        #control.log("### VIDEOMEGA RE3 %s" % result)
        #"src", "http://abo.cdn.vizplay.org/m2/769a65801d8e8a110452f2b74d4082d1.mp4?st=-A2O2o2soMR81Niiag5EyA&hash=Dw8Kth5gh-nNyMRbWLZMKA"
        url = re.compile('"src","(.*?)"').findall(result)[-1]
        #control.log("### VIDEOMEGA RE4 %s" % url)
        return url
    except:
        return 
Example 5
Project: Pancas   Author: Sup3Roque   File: __init__.py    GNU General Public License v2.0 6 votes vote down vote up
def sourcesResolve(self, url, provider):
        try:
            provider = provider.lower()

            if not provider.endswith(('_mv', '_tv', '_mv_tv')):
                sourceDict = []
                for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg))
                provider = [i[0] for i in sourceDict if i[1] == False and i[0].startswith(provider + '_')][0]

            source = __import__(provider, globals(), locals(), [], -1).source()
            url = source.resolve(url)
            #control.log("[suurces]   my url 1 ************ %s " % url)
            #url = resolvers.request(url)
            #control.log("[sources]   my url 2 ************ %s " % url)

            try: headers = dict(urlparse.parse_qsl(url.rsplit('|', 1)[1]))
            except: headers = dict('')

            result = client.request(url.split('|')[0], headers=headers, output='chunk', timeout='20')
            if result == None: raise Exception()
            #control.log("!!!!!!!!!!!!!!!!!!!  %s prov: %s" % (url,provider))
            self.url = url
            return url
        except:
            return 
Example 6
Project: Pancas   Author: Sup3Roque   File: videomega.py    GNU General Public License v2.0 6 votes vote down vote up
def resolve(url):
    try:
        url = urlparse.urlparse(url).query
        url = urlparse.parse_qsl(url)[0][1]
        url = 'http://videomega.tv/cdn.php?ref=%s' % url
        #control.log("### VIDEOMEGA RES %s" % url)
        result = client.request(url, mobile=True)
        #control.log("### VIDEOMEGA RES %s" % result)
        result = re.compile('eval.*?{}\)\)').findall(result)[-1]
        #control.log("### VIDEOMEGA RES2 %s" % result)
        result = jsunpack.unpack(result)
        #control.log("### VIDEOMEGA RE3 %s" % result)
        #"src", "http://abo.cdn.vizplay.org/m2/769a65801d8e8a110452f2b74d4082d1.mp4?st=-A2O2o2soMR81Niiag5EyA&hash=Dw8Kth5gh-nNyMRbWLZMKA"
        url = re.compile('"src","(.*?)"').findall(result)[-1]
        #control.log("### VIDEOMEGA RE4 %s" % url)
        return url
    except:
        return 
Example 7
Project: Pancas   Author: Sup3Roque   File: __init__.py    GNU General Public License v2.0 6 votes vote down vote up
def sourcesResolve(self, url, provider):
        try:
            provider = provider.lower()

            if not provider.endswith(('_mv', '_tv', '_mv_tv')):
                sourceDict = []
                for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg))
                provider = [i[0] for i in sourceDict if i[1] == False and i[0].startswith(provider + '_')][0]

            source = __import__(provider, globals(), locals(), [], -1).source()
            url = source.resolve(url)
            #control.log("[suurces]   my url 1 ************ %s " % url)
            #url = resolvers.request(url)
            #control.log("[sources]   my url 2 ************ %s " % url)

            try: headers = dict(urlparse.parse_qsl(url.rsplit('|', 1)[1]))
            except: headers = dict('')

            result = client.request(url.split('|')[0], headers=headers, output='chunk', timeout='20')
            if result == None: raise Exception()
            #control.log("!!!!!!!!!!!!!!!!!!!  %s prov: %s" % (url,provider))
            self.url = url
            return url
        except:
            return 
Example 8
Project: plugin.audio.subsonic   Author: basilfx   File: __init__.py    MIT License 6 votes vote down vote up
def _doBinReq(self, *args, **kwargs):
        """
        Intercept request URL to provide the URL of the item that is requested.

        If the URL is intercepted, the request is not executed. A username and
        password is added to provide direct access to the stream.
        """

        if self.intercept_url:
            parts = list(urlparse.urlparse(
                args[0].get_full_url() + "?" + args[0].data))
            parts[4] = dict(urlparse.parse_qsl(parts[4]))
            parts[4].update({"u": self.username, "p": self.password})
            parts[4] = urllib.urlencode(parts[4])

            return urlparse.urlunparse(parts)
        else:
            return super(SubsonicClient, self)._doBinReq(*args, **kwargs) 
Example 9
Project: lambdabot   Author: timokoola   File: facebook.py    GNU General Public License v2.0 6 votes vote down vote up
def facebook_compliance_fix(session):

    def _compliance_fix(r):
        # if Facebook claims to be sending us json, let's trust them.
        if 'application/json' in r.headers.get('content-type', {}):
            return r

        # Facebook returns a content-type of text/plain when sending their
        # x-www-form-urlencoded responses, along with a 200. If not, let's
        # assume we're getting JSON and bail on the fix.
        if 'text/plain' in r.headers.get('content-type', {}) and r.status_code == 200:
            token = dict(parse_qsl(r.text, keep_blank_values=True))
        else:
            return r

        expires = token.get('expires')
        if expires is not None:
            token['expires_in'] = expires
        token['token_type'] = 'Bearer'
        r._content = to_unicode(dumps(token)).encode('UTF-8')
        return r

    session.register_compliance_hook('access_token_response', _compliance_fix)
    return session 
Example 10
Project: rucio   Author: rucio   File: account.py    Apache License 2.0 6 votes vote down vote up
def GET(self):
        """ list all rucio accounts.

        HTTP Success:
            200 OK

        HTTP Error:
            401 Unauthorized
            406 Not Acceptable
            500 InternalError

        :param Rucio-Account: Account identifier.
        :param Rucio-Auth-Token: as an 32 character hex string.
        :returns: A list containing all account names as dict.
        """
        header('Content-Type', 'application/x-json-stream')
        filter = {}
        if ctx.query:
            filter = dict(parse_qsl(ctx.query[1:]))

        for account in list_accounts(filter=filter):
            yield render_json(**account) + "\n" 
Example 11
Project: rucio   Author: rucio   File: account.py    Apache License 2.0 6 votes vote down vote up
def GET(self):
        """ list all rucio accounts.

        HTTP Success:
            200 OK

        HTTP Error:
            401 Unauthorized
            406 Not Acceptable
            500 InternalError

        :param Rucio-Account: Account identifier.
        :param Rucio-Auth-Token: as an 32 character hex string.
        :returns: A list containing all account names as dict.
        """
        header('Content-Type', 'application/x-json-stream')
        filter = {}
        if ctx.query:
            filter = dict(parse_qsl(ctx.query[1:]))

        for account in list_accounts(filter=filter):
            yield render_json(**account) + "\n" 
Example 12
Project: TESTGIT   Author: B-ROY   File: request.py    Apache License 2.0 6 votes vote down vote up
def __init__(self, query_string, mutable=False, encoding=None):
        super(QueryDict, self).__init__()
        if not encoding:
            encoding = settings.DEFAULT_CHARSET
        self.encoding = encoding
        if six.PY3:
            if isinstance(query_string, bytes):
                # query_string contains URL-encoded data, a subset of ASCII.
                query_string = query_string.decode()
            for key, value in parse_qsl(query_string or '',
                                        keep_blank_values=True,
                                        encoding=encoding):
                self.appendlist(key, value)
        else:
            for key, value in parse_qsl(query_string or '',
                                        keep_blank_values=True):
                self.appendlist(force_text(key, encoding, errors='replace'),
                                force_text(value, encoding, errors='replace'))
        self._mutable = mutable 
Example 13
Project: dockerizeme   Author: dockerizeme   File: snippet.py    Apache License 2.0 6 votes vote down vote up
def render(self, context):
        urlp = list(urlparse(self.url.resolve(context)))
        qp = parse_qsl(urlp[4])
        for name, op, value in self.qs:
            name = smart_str(name)
            value = value.resolve(context)
            value = smart_str(value) if value is not None else None
            if op == '+=':
                qp = filter(lambda (n, v): not(n == name and v == value), qp)
                qp.append((name, value,))
            elif op == '-=':
                qp = filter(lambda (n, v): not(n == name and v == value), qp)
            elif op == '=':
                qp = filter(lambda (n, v): not(n == name), qp)
                if value is not None:
                    qp.append((name, value,))
 
        urlp[4] = urlencode(qp, True)
        url = urlunparse(urlp)
 
        if self.asvar:
            context[self.asvar] = url
            return ''
        else:
            return url 
Example 14
Project: plugin.video.streama   Author: HackerspaceBielefeld   File: addon.py    MIT License 6 votes vote down vote up
def router(paramstring):
    # Parse a URL-encoded paramstring to the dictionary of
    # {<parameter>: <value>} elements
    params = dict(parse_qsl(paramstring))
    # Check the parameters passed to the plugin
    if params:
        if params['action'] == 'listing':
            # Display the list of videos in a provided category.
            list_videos(params['category'], params['showid'])
        elif params['action'] == 'play':
            # Play a video from a provided URL.
            play_video(params['video'])
        else:
            # If the provided paramstring does not contain a supported action
            # we raise an exception. This helps to catch coding errors,
            # e.g. typos in action names.
            raise ValueError('Invalid paramstring: {0}!'.format(paramstring))
    else:
        # If the plugin is called from Kodi UI without any parameters,
        # display the list of video categories
        list_categories() 
Example 15
Project: open-recipe   Author: dspray95   File: facebook.py    The Unlicense 6 votes vote down vote up
def facebook_compliance_fix(session):

    def _compliance_fix(r):
        # if Facebook claims to be sending us json, let's trust them.
        if 'application/json' in r.headers.get('content-type', {}):
            return r

        # Facebook returns a content-type of text/plain when sending their
        # x-www-form-urlencoded responses, along with a 200. If not, let's
        # assume we're getting JSON and bail on the fix.
        if 'text/plain' in r.headers.get('content-type', {}) and r.status_code == 200:
            token = dict(parse_qsl(r.text, keep_blank_values=True))
        else:
            return r

        expires = token.get('expires')
        if expires is not None:
            token['expires_in'] = expires
        token['token_type'] = 'Bearer'
        r._content = to_unicode(dumps(token)).encode('UTF-8')
        return r

    session.register_compliance_hook('access_token_response', _compliance_fix)
    return session 
Example 16
Project: navitia_client   Author: leonardbinet   File: __init__.py    MIT License 5 votes vote down vote up
def assertURLEqual(self, first, second, msg=None):
        """Check that two arguments are equivalent URLs. Ignores the order of
        query arguments.
        """
        first_parsed = urlparse(first)
        second_parsed = urlparse(second)
        self.assertEqual(first_parsed[:3], second_parsed[:3], msg)

        first_qsl = sorted(parse_qsl(first_parsed.query))
        second_qsl = sorted(parse_qsl(second_parsed.query))
        self.assertEqual(first_qsl, second_qsl, msg) 
Example 17
Project: pyblish-win   Author: pyblish   File: cgi.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
    """Parse a query given as a string argument."""
    warn("cgi.parse_qsl is deprecated, use urlparse.parse_qsl instead",
         PendingDeprecationWarning, 2)
    return urlparse.parse_qsl(qs, keep_blank_values, strict_parsing) 
Example 18
Project: pyblish-win   Author: pyblish   File: cgi.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def read_urlencoded(self):
        """Internal: read data in query string format."""
        qs = self.fp.read(self.length)
        if self.qs_on_post:
            qs += '&' + self.qs_on_post
        self.list = list = []
        for key, value in urlparse.parse_qsl(qs, self.keep_blank_values,
                                            self.strict_parsing):
            list.append(MiniFieldStorage(key, value))
        self.skip_lines() 
Example 19
Project: pyblish-win   Author: pyblish   File: test_urlparse.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def test_qsl(self):
        for orig, expect in parse_qsl_test_cases:
            result = urlparse.parse_qsl(orig, keep_blank_values=True)
            self.assertEqual(result, expect, "Error parsing %r" % orig)
            expect_without_blanks = [v for v in expect if len(v[1])]
            result = urlparse.parse_qsl(orig, keep_blank_values=False)
            self.assertEqual(result, expect_without_blanks,
                    "Error parsing %r" % orig) 
Example 20
Project: mimic   Author: googlearchive   File: mimic.py    Apache License 2.0 5 votes vote down vote up
def GetProjectIdFromQueryParam(environ):
  """Returns the project id from the query string.

  Args:
    environ: The request environ.
  Returns:
    The project id or None.
  """

  qs = environ.get('QUERY_STRING')
  if not qs:
    return None
  # use strict_parsing=False to gracefully ignore bad query strings
  params = dict(urlparse.parse_qsl(qs, strict_parsing=False))
  return params.get(common.config.PROJECT_ID_QUERY_PARAM) 
Example 21
Project: ngo-addons-backport   Author: camptocamp   File: main.py    GNU Affero General Public License v3.0 5 votes vote down vote up
def db_redirect(req, match_first_only_if_unique):
    db = False
    redirect = False

    dbs = db_list(req, True)

    # 1 try the db in the url
    db_url = req.params.get('db')
    if db_url and db_url in dbs:
        return (db_url, False)

    # 2 use the database from the cookie if it's listable and still listed
    cookie_db = req.httprequest.cookies.get('last_used_database')
    if cookie_db in dbs:
        db = cookie_db

    # 3 use the first db if user can list databases
    if dbs and not db and (not match_first_only_if_unique or len(dbs) == 1):
        db = dbs[0]

    # redirect to the chosen db if multiple are available
    if db and len(dbs) > 1:
        query = dict(urlparse.parse_qsl(req.httprequest.query_string, keep_blank_values=True))
        query.update({'db': db})
        redirect = req.httprequest.path + '?' + urllib.urlencode(query)
    return (db, redirect) 
Example 22
Project: openhatch   Author: campbe13   File: http.py    GNU Affero General Public License v3.0 5 votes vote down vote up
def __init__(self, url):
        self.parts = urlparse(url)
        self.query = dict(parse_qsl(self.parts[4])) 
Example 23
Project: openhatch   Author: campbe13   File: compat.py    GNU Affero General Public License v3.0 5 votes vote down vote up
def parse_qsl_text(qs, encoding='utf-8'):
        qsl = parse_qsl(
            qs,
            keep_blank_values=True,
            strict_parsing=False
        )
        for (x, y) in qsl:
            yield (x.decode(encoding), y.decode(encoding)) 
Example 24
Project: jawfish   Author: war-and-code   File: cgi.py    MIT License 5 votes vote down vote up
def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
    """Parse a query given as a string argument."""
    warn("cgi.parse_qsl is deprecated, use urlparse.parse_qsl instead",
         PendingDeprecationWarning, 2)
    return urlparse.parse_qsl(qs, keep_blank_values, strict_parsing) 
Example 25
Project: jawfish   Author: war-and-code   File: cgi.py    MIT License 5 votes vote down vote up
def read_urlencoded(self):
        """Internal: read data in query string format."""
        qs = self.fp.read(self.length)
        if self.qs_on_post:
            qs += '&' + self.qs_on_post
        self.list = list = []
        for key, value in urlparse.parse_qsl(qs, self.keep_blank_values,
                                            self.strict_parsing):
            list.append(MiniFieldStorage(key, value))
        self.skip_lines() 
Example 26
Project: jawfish   Author: war-and-code   File: cgi.py    MIT License 5 votes vote down vote up
def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
    """Parse a query given as a string argument."""
    warn("cgi.parse_qsl is deprecated, use urlparse.parse_qsl instead",
         PendingDeprecationWarning, 2)
    return urlparse.parse_qsl(qs, keep_blank_values, strict_parsing) 
Example 27
Project: jawfish   Author: war-and-code   File: cgi.py    MIT License 5 votes vote down vote up
def read_urlencoded(self):
        """Internal: read data in query string format."""
        qs = self.fp.read(self.length)
        if self.qs_on_post:
            qs += '&' + self.qs_on_post
        self.list = list = []
        for key, value in urlparse.parse_qsl(qs, self.keep_blank_values,
                                            self.strict_parsing):
            list.append(MiniFieldStorage(key, value))
        self.skip_lines() 
Example 28
Project: Pancas   Author: Sup3Roque   File: genesisresolvers.py    GNU General Public License v2.0 5 votes vote down vote up
def worker(self, url):
        try:
            pz = premiumize().resolve(url)
            if not pz == None: return pz
            rd = realdebrid().resolve(url)
            if not rd == None: return rd

            if url.startswith('rtmp'):
                if len(re.compile('\s*timeout=(\d*)').findall(url)) == 0: url += ' timeout=10'
                return url

            u = urlparse.urlparse(url).netloc
            u = u.replace('www.', '').replace('embed.', '')
            u = u.lower()

            import sys, inspect
            r = inspect.getmembers(sys.modules[__name__], inspect.isclass)
            r = [i for i in r if hasattr(i[1], 'info') and u in eval(i[0])().info()['netloc']][0][0]
            r = eval(r)().resolve(url)

            if r == None: return r
            elif type(r) == list: return r
            elif not r.startswith('http'): return r

            try: h = dict(urlparse.parse_qsl(r.rsplit('|', 1)[1]))
            except: h = dict('')
            h.update({'Referer': url, 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; rv:34.0) Gecko/20100101 Firefox/34.0'})

            r = '%s|%s' % (r.split('|')[0], urllib.urlencode(h))
            return r
        except:
            return url 
Example 29
Project: Pancas   Author: Sup3Roque   File: genesisresolvers.py    GNU General Public License v2.0 5 votes vote down vote up
def resolve(self, url):
        try:
            url = urlparse.urlparse(url).query
            url = urlparse.parse_qsl(url)[0][1]
            url = 'http://videomega.tv/cdn.php?ref=%s' % url

            result = getUrl(url, mobile=True).result

            url = common.parseDOM(result, "source", ret="src", attrs = { "type": "video.+?" })[0]
            return url
        except:
            return 
Example 30
Project: Pancas   Author: Sup3Roque   File: hlsDownloader.py    GNU General Public License v2.0 5 votes vote down vote up
def init(self, out_stream, url, proxy=None,use_proxy_for_chunks=True,g_stopEvent=None, maxbitrate=0, auth=''):
        global clientHeader
        try:
            self.init_done=False
            self.init_url=url
            clientHeader=None
            self.status='init'
            self.proxy = proxy
            self.auth=auth
            if self.auth ==None or self.auth =='None' :
                self.auth=''
            if self.proxy and len(self.proxy)==0:
                self.proxy=None
            self.use_proxy_for_chunks=use_proxy_for_chunks
            self.out_stream=out_stream
            self.g_stopEvent=g_stopEvent
            self.maxbitrate=maxbitrate
            if '|' in url:
                sp = url.split('|')
                url = sp[0]
                clientHeader = sp[1]
                clientHeader= urlparse.parse_qsl(clientHeader)
                print 'header recieved now url and headers are',url, clientHeader 
            self.status='init done'
            self.url=url
            return self.preDownoload()
        except: 
            traceback.print_exc()
            self.status='finished'
        return False 
Example 31
Project: Pancas   Author: Sup3Roque   File: f4mDownloader.py    GNU General Public License v2.0 5 votes vote down vote up
def init(self, out_stream, url, proxy=None,use_proxy_for_chunks=True,g_stopEvent=None, maxbitrate=0, auth=''):
        try:
            self.init_done=False
            self.total_frags=0
            self.init_url=url
            self.clientHeader=None
            self.status='init'
            self.proxy = proxy
            self.auth=auth
            #self.auth="pvtoken=exp%3D9999999999%7Eacl%3D%252f%252a%7Edata%3DZXhwPTE0MDYzMDMxMTV+YWNsPSUyZip+ZGF0YT1wdmMsc35obWFjPWQxODA5MWVkYTQ4NDI3NjFjODhjOWQwY2QxNTk3YTI0MWQwOWYwNWI1N2ZmMDE0ZjcxN2QyMTVjZTJkNmJjMDQ%3D%2196e4sdLWrezE46RaCBzzP43/LEM5en2KujAosbeDimQ%3D%7Ehmac%3DACF8A1E4467676C9BCE2721CA5EFF840BD6ED1780046954039373A3B0D942ADC&hdntl=exp=1406303115~acl=%2f*~data=hdntl~hmac=4ab96fa533fd7c40204e487bfc7befaf31dd1f49c27eb1f610673fed9ff97a5f&als=0,2,0,0,0,NaN,0,0,0,37,f,52293145.57,52293155.9,t,s,GARWLHLMHNGA,2.11.3,37&hdcore=2.11.3" 
            if self.auth ==None or self.auth =='None' :
                self.auth=''
            if self.proxy and len(self.proxy)==0:
                self.proxy=None
            self.use_proxy_for_chunks=use_proxy_for_chunks
            self.out_stream=out_stream
            self.g_stopEvent=g_stopEvent
            self.maxbitrate=maxbitrate
            if '|' in url:
                sp = url.split('|')
                url = sp[0]
                self.clientHeader = sp[1]
                self.clientHeader= urlparse.parse_qsl(self.clientHeader)
                
                print 'header recieved now url and headers are',url, self.clientHeader 
            self.status='init done'
            self.url=url
            #self.downloadInternal(  url)
            return self.preDownoload()
            
            #os.remove(self.outputfile)
        except: 
            traceback.print_exc()
            self.status='finished'
        return False 
Example 32
Project: Pancas   Author: Sup3Roque   File: up2stream.py    GNU General Public License v2.0 5 votes vote down vote up
def resolve(url):
    try:
        url = urlparse.urlparse(url).query
        url = urlparse.parse_qsl(url)[0][1]
        url = 'http://up2stream.com/view.php?ref=%s' % url

        result = client.request(url, mobile=True)

        url = client.parseDOM(result, 'source', ret='src', attrs = {'type': 'video.+?'})[0]
        return url
    except:
        return 
Example 33
Project: Pancas   Author: Sup3Roque   File: videomega.py    GNU General Public License v2.0 5 votes vote down vote up
def check(url):
    try:
        url = urlparse.urlparse(url).query
        url = urlparse.parse_qsl(url)[0][1]
        url = 'http://videomega.tv/cdn.php?ref=%s' % url
        result = client.request(url, mobile=True)
        result = re.compile('eval.*?{}\)\)').findall(result)[-1]
        result = jsunpack.unpack(result)
        url = re.compile('"src","(.*?)"').findall(result)[-1]
        #control.log("### VIDEOMEGA RE3                   1111111111  %s" % url)
        if url.startswith('http://N/D/m/'): return False
        return True
    except:
        return False 
Example 34
Project: Pancas   Author: Sup3Roque   File: icefilms_mv_tv_null.py    GNU General Public License v2.0 5 votes vote down vote up
def resolve(self, url):
        try:
            post = urlparse.parse_qsl(urlparse.urlparse(url).query, True)
            post = [i for i in post if not i[0] == 'image']
            post = post

            query = urlparse.parse_qs(urlparse.urlparse(url).query)

            image = urllib.unquote(query['image'][0])

            ref = self.video_link % query['t'][0]

            url = urlparse.urlparse(url).path
            url += '?s=%s&t=%s&app_id=Specto505' % (query['id'][0], query['t'][0])

            links = [self.link_1]
            for base_link in links:
                referer = urlparse.urljoin(base_link, ref)
                cookie = client.request(referer, output='cookie')
                result = client.request(urlparse.urljoin(base_link, url), post=post, referer=referer, cookie=cookie)
                if 'com_iceplayer' in str(result): break

            self.img_parser(image, referer)

            url = urlparse.parse_qs(urlparse.urlparse(result).query)['url'][0]
            url = resolvers.request(url)

            return url
        except:
            return 
Example 35
Project: Pancas   Author: Sup3Roque   File: genesisresolvers.py    GNU General Public License v2.0 5 votes vote down vote up
def resolve(self, url):
        try:
            url = urlparse.urlparse(url).query
            url = urlparse.parse_qsl(url)[0][1]
            url = 'http://videomega.tv/cdn.php?ref=%s' % url

            result = getUrl(url, mobile=True).result

            url = common.parseDOM(result, "source", ret="src", attrs = { "type": "video.+?" })[0]
            return url
        except:
            return 
Example 36
Project: Pancas   Author: Sup3Roque   File: hlsDownloader.py    GNU General Public License v2.0 5 votes vote down vote up
def init(self, out_stream, url, proxy=None,use_proxy_for_chunks=True,g_stopEvent=None, maxbitrate=0, auth=''):
        global clientHeader
        try:
            self.init_done=False
            self.init_url=url
            clientHeader=None
            self.status='init'
            self.proxy = proxy
            self.auth=auth
            if self.auth ==None or self.auth =='None' :
                self.auth=''
            if self.proxy and len(self.proxy)==0:
                self.proxy=None
            self.use_proxy_for_chunks=use_proxy_for_chunks
            self.out_stream=out_stream
            self.g_stopEvent=g_stopEvent
            self.maxbitrate=maxbitrate
            if '|' in url:
                sp = url.split('|')
                url = sp[0]
                clientHeader = sp[1]
                clientHeader= urlparse.parse_qsl(clientHeader)
                print 'header recieved now url and headers are',url, clientHeader 
            self.status='init done'
            self.url=url
            return self.preDownoload()
        except: 
            traceback.print_exc()
            self.status='finished'
        return False 
Example 37
Project: Pancas   Author: Sup3Roque   File: f4mDownloader.py    GNU General Public License v2.0 5 votes vote down vote up
def init(self, out_stream, url, proxy=None,use_proxy_for_chunks=True,g_stopEvent=None, maxbitrate=0, auth=''):
        try:
            self.init_done=False
            self.total_frags=0
            self.init_url=url
            self.clientHeader=None
            self.status='init'
            self.proxy = proxy
            self.auth=auth
            #self.auth="pvtoken=exp%3D9999999999%7Eacl%3D%252f%252a%7Edata%3DZXhwPTE0MDYzMDMxMTV+YWNsPSUyZip+ZGF0YT1wdmMsc35obWFjPWQxODA5MWVkYTQ4NDI3NjFjODhjOWQwY2QxNTk3YTI0MWQwOWYwNWI1N2ZmMDE0ZjcxN2QyMTVjZTJkNmJjMDQ%3D%2196e4sdLWrezE46RaCBzzP43/LEM5en2KujAosbeDimQ%3D%7Ehmac%3DACF8A1E4467676C9BCE2721CA5EFF840BD6ED1780046954039373A3B0D942ADC&hdntl=exp=1406303115~acl=%2f*~data=hdntl~hmac=4ab96fa533fd7c40204e487bfc7befaf31dd1f49c27eb1f610673fed9ff97a5f&als=0,2,0,0,0,NaN,0,0,0,37,f,52293145.57,52293155.9,t,s,GARWLHLMHNGA,2.11.3,37&hdcore=2.11.3" 
            if self.auth ==None or self.auth =='None' :
                self.auth=''
            if self.proxy and len(self.proxy)==0:
                self.proxy=None
            self.use_proxy_for_chunks=use_proxy_for_chunks
            self.out_stream=out_stream
            self.g_stopEvent=g_stopEvent
            self.maxbitrate=maxbitrate
            if '|' in url:
                sp = url.split('|')
                url = sp[0]
                self.clientHeader = sp[1]
                self.clientHeader= urlparse.parse_qsl(self.clientHeader)
                
                print 'header recieved now url and headers are',url, self.clientHeader 
            self.status='init done'
            self.url=url
            #self.downloadInternal(  url)
            return self.preDownoload()
            
            #os.remove(self.outputfile)
        except: 
            traceback.print_exc()
            self.status='finished'
        return False 
Example 38
Project: Pancas   Author: Sup3Roque   File: interalSimpleDownloader.py    GNU General Public License v2.0 5 votes vote down vote up
def init(self, out_stream, url, proxy=None,g_stopEvent=None, maxbitRate=0):
        try:
            self.init_done=False
            self.init_url=url
            self.clientHeader=None
            self.status='init'
            self.proxy = proxy
            self.maxbitRate=maxbitRate
            if self.proxy and len(self.proxy)==0:
                self.proxy=None
            self.out_stream=out_stream
            self.g_stopEvent=g_stopEvent
            if '|' in url:
                sp = url.split('|')
                url = sp[0]
                self.clientHeader = sp[1]
                self.clientHeader= urlparse.parse_qsl(self.clientHeader)
                
            print 'header recieved now url and headers are',url, self.clientHeader 
            self.status='init done'
            self.url=url
            #self.downloadInternal(  url)
            return True
            
            #os.remove(self.outputfile)
        except: 
            traceback.print_exc()
            self.status='finished'
        return False 
Example 39
Project: Pancas   Author: Sup3Roque   File: videomega.py    GNU General Public License v2.0 5 votes vote down vote up
def check(url):
    try:
        url = urlparse.urlparse(url).query
        url = urlparse.parse_qsl(url)[0][1]
        url = 'http://videomega.tv/cdn.php?ref=%s' % url
        result = client.request(url, mobile=True)
        result = re.compile('eval.*?{}\)\)').findall(result)[-1]
        result = jsunpack.unpack(result)
        url = re.compile('"src","(.*?)"').findall(result)[-1]
        #control.log("### VIDEOMEGA RE3                   1111111111  %s" % url)
        if url.startswith('http://N/D/m/'): return False
        return True
    except:
        return False 
Example 40
Project: Pancas   Author: Sup3Roque   File: icefilms_mv_tv_null.py    GNU General Public License v2.0 5 votes vote down vote up
def resolve(self, url):
        try:
            post = urlparse.parse_qsl(urlparse.urlparse(url).query, True)
            post = [i for i in post if not i[0] == 'image']
            post = post

            query = urlparse.parse_qs(urlparse.urlparse(url).query)

            image = urllib.unquote(query['image'][0])

            ref = self.video_link % query['t'][0]

            url = urlparse.urlparse(url).path
            url += '?s=%s&t=%s&app_id=Specto505' % (query['id'][0], query['t'][0])

            links = [self.link_1]
            for base_link in links:
                referer = urlparse.urljoin(base_link, ref)
                cookie = client.request(referer, output='cookie')
                result = client.request(urlparse.urljoin(base_link, url), post=post, referer=referer, cookie=cookie)
                if 'com_iceplayer' in str(result): break

            self.img_parser(image, referer)

            url = urlparse.parse_qs(urlparse.urlparse(result).query)['url'][0]
            url = resolvers.request(url)

            return url
        except:
            return 
Example 41
Project: quiz-extensions   Author: ucfopen   File: tool_provider.py    MIT License 5 votes vote down vote up
def build_return_url(self):
        '''
        If the Tool Consumer sent a return URL, add any set messages to the
        URL.
        '''
        if not self.launch_presentation_return_url:
            return None

        lti_message_fields = ['lti_errormsg', 'lti_errorlog',
                              'lti_msg', 'lti_log']

        messages = dict([(key, getattr(self, key))
                         for key in lti_message_fields
                         if getattr(self, key, None)])

        # Disassemble original return URL and reassemble with our options added
        original = urlsplit(self.launch_presentation_return_url)

        combined = messages.copy()
        combined.update(dict(parse_qsl(original.query)))

        combined_query = urlencode(combined)

        return urlunsplit((
            original.scheme,
            original.netloc,
            original.path,
            combined_query,
            original.fragment
        )) 
Example 42
Project: Miscellaneous   Author: Shinpachi8   File: classSQL.py    Apache License 2.0 5 votes vote down vote up
def get_value(self, payload=None):
        # to check if the file upload, if uploaded, return directly
        self.to_check_list = []
        #self.aim_error_list = []
        if payload is None: payload=classSQL.payload
        if self.method == 'GET':
            _ = urlparse.urlparse(self.url)
            if not _.query:
                return
            values = dict(urlparse.parse_qsl(_.query))
            for p in payload:
                for param in values.keys():
                    temp_dict = copy.deepcopy(values)
                    temp_dict[param] =   p
                    temp_query = urllib.urlencode(temp_dict)
                    self.to_check_list.append(urlparse.urlunparse((_.scheme, _.netloc, _.path, _.params, temp_query, _.fragment)))
        elif self.method == 'POST':
            jsondata = False
            try:
                values = dict(urlparse.parse_qsl(self.data))
            except Exception as e:
                print repr(e)
                try:
                    values = json.loads(self.data)
                    jsondata = True
                except:
                    return
            for p in payload:
                for param in values.keys():
                    temp_dict = copy.deepcopy(values)
                    temp_dict[param] =  p
                    if jsondata:
                        self.to_check_list.append(json.dumps(temp_dict))
                    else:
                        temp_query = urllib.urlencode(temp_dict)
                        self.to_check_list.append(temp_query)


        #print "self.to_check_list = {}".format(self.to_check_list) 
Example 43
Project: Miscellaneous   Author: Shinpachi8   File: common.py    Apache License 2.0 5 votes vote down vote up
def qs_parse(qs):
        return dict(urlparse.parse_qsl(qs, keep_blank_values=True)) 
Example 44
Project: Miscellaneous   Author: Shinpachi8   File: common.py    Apache License 2.0 5 votes vote down vote up
def get_dict_query(self):
        """
        return the dict type query
        """
        return dict(urlparse.parse_qsl(self.query)) 
Example 45
Project: Miscellaneous   Author: Shinpachi8   File: common.py    Apache License 2.0 5 votes vote down vote up
def pollut(self):
        if self.isjson:
            query_dict = dict(urlparse.parse_qsl(self.query, keep_blank_values=True))
        else:
            query_dict = dict(urlparse.parse_qsl(self.query, keep_blank_values=True))

        for key in query_dict.keys():
            for payload in self.payloads:
                tmp_qs = query_dict.copy()
                if self.replace:
                    tmp_qs[key] = payload
                else:
                    tmp_qs[key] = tmp_qs[key] + payload
                self.polluted_urls.append(tmp_qs) 
Example 46
Project: Miscellaneous   Author: Shinpachi8   File: common.py    Apache License 2.0 5 votes vote down vote up
def qs_parse(qs):
        return dict(urlparse.parse_qsl(qs, keep_blank_values=True)) 
Example 47
Project: Quiver-alfred   Author: danielecook   File: db_url.py    MIT License 5 votes vote down vote up
def parseresult_to_dict(parsed):

    # urlparse in python 2.6 is broken so query will be empty and instead
    # appended to path complete with '?'
    path_parts = parsed.path[1:].split('?')
    try:
        query = path_parts[1]
    except IndexError:
        query = parsed.query

    connect_kwargs = {'database': path_parts[0]}
    if parsed.username:
        connect_kwargs['user'] = parsed.username
    if parsed.password:
        connect_kwargs['password'] = parsed.password
    if parsed.hostname:
        connect_kwargs['host'] = parsed.hostname
    if parsed.port:
        connect_kwargs['port'] = parsed.port

    # Adjust parameters for MySQL.
    if parsed.scheme == 'mysql' and 'password' in connect_kwargs:
        connect_kwargs['passwd'] = connect_kwargs.pop('password')
    elif 'sqlite' in parsed.scheme and not connect_kwargs['database']:
        connect_kwargs['database'] = ':memory:'

    # Get additional connection args from the query string
    connect_kwargs.update(parse_qsl(query))

    return connect_kwargs 
Example 48
Project: wpt-sync   Author: mozilla   File: wptfyi.py    Mozilla Public License 2.0 5 votes vote down vote up
def __init__(self, initial_url):
        if initial_url:
            parts = urlparse.urlsplit(initial_url)
            self.scheme = parts.scheme
            self.host = parts.netloc
            self.path = parts.path
            self.query = urlparse.parse_qsl(parts.query, keep_blank_values=True)
            self.fragment = parts.fragment
        else:
            self.scheme = ""
            self.host = ""
            self.path = ""
            self.query = []
            self.fragment = "" 
Example 49
Project: httpie-plex   Author: MediaMath   File: httpie_plex.py    Apache License 2.0 5 votes vote down vote up
def add_to_query(url, query):
    url_parts = list(urlparse.urlparse(url))
    old_query = dict(urlparse.parse_qsl(url_parts[4]))
    old_query.update(query)
    url_parts[4] = urlencode(old_query)
    return urlparse.urlunparse(url_parts) 
Example 50
Project: yosbot   Author: craisins   File: http.py    The Unlicense 5 votes vote down vote up
def prepare_url(url, queries):
    if queries:
        scheme, netloc, path, query, fragment = urlparse.urlsplit(url)

        query = dict(urlparse.parse_qsl(query))
        query.update(queries)
        query = urllib.urlencode(dict((to_utf8(key), to_utf8(value))
                                      for key, value in query.iteritems()))

        url = urlparse.urlunsplit((scheme, netloc, path, query, fragment))

    return url